简体   繁体   English

如何将时钟消息从 arduino 发送到 MIDI 合成器?

[英]How to send clock message from arduino to MIDI synth?

I'm trying to send periodically clock from arduino to Electron Digitakt synth with 120 bpm .我正在尝试以120 bpm定期将时钟从 arduino 发送到 Electron Digitakt 合成器。 It means I need to send 0xF8 every 21ms ( 60000/bpm/ppq -> ppq = 24 pulses per quarter )这意味着我需要每 21 毫秒发送一次0xF860000/bpm/ppq -> ppq = 24 pulses per quarter

My code looks like我的代码看起来像

void setup() 
{
  Serial.begin(31250);

  for (int i=0; i<10; i++) { Serial.write(byte(0xFF)); } // reset the slave
  
  Serial.write(byte(0xFA)); // send start command
  delay(10);

}

void loop () {
    Serial.write(byte(0xF8));
    delay(21);
}

But I see that my synth switches to Play but BPM doesn't change.但我看到我的合成器切换到 Play 但BPM没有改变。 I use logic analyser to check the output, it shows that this byte sends every 21ms (+- 1.2ms, usually a half of ms).我使用逻辑分析仪检查输出,它显示这个字节每 21 毫秒发送一次(+- 1.2 毫秒,通常是半毫秒)。 Tried several libs for arduino with midi management, nothing helped用 midi 管理为 arduino 尝试了几个库,没有任何帮助

Could you help me to understand where is an issue?你能帮我理解问题出在哪里吗?

From this MIDI tutorial for programmers it seems the Reset message should be used cautiously:从这个面向程序员的 MIDI 教程看来,应该谨慎使用 Reset 消息:

  • MIDI Reset message MIDI 重置信息
    • This is a one status byte message 0xFF, without data bytes.这是一个状态字节消息 0xFF,没有数据字节。 It should reset the synthesizer to its power-on default, so it also stops all notes playing.它应该将合成器重置为其开机默认设置,因此它也会停止所有音符的播放。 Use this message sparingly, as it reset the full synthesizer, not only the notes playing.谨慎使用此消息,因为它会重置完整的合成器,而不仅仅是播放的音符。

I would suggest:我会建议:

  • Sending only one reset message仅发送一条重置消息
  • Adding a delay after sending it.发送后添加延迟。 You will have to test an appropriate value您将不得不测试一个适当的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM