JUCE 框架中 MIDI 音符打开和音符关闭消息之间的延迟
Delay between midi note on and note off message in JUCE framework
我正在使用 JUCE 框架在 C++ 中制作一个小工具。
它发出 MIDI 但我遇到了问题。
我想向我的 DAW 发送和弦,方法是先发送消息注释,然后发送消息关闭消息。 noteOn 代码如下所示:
void MainContentComponent::handleNoteOn (MidiKeyboardState*, int
midiChannel, int midiNoteNumber, float velocity)
{
timestamp = (Time::getMillisecondCounterHiRes() * 0.001);
MidiMessage m (MidiMessage::noteOn (midiChannel, midiNoteNumber , velocity));
MidiMessage m2 (MidiMessage::noteOn (midiChannel, midiNoteNumber + 3, velocity));
MidiMessage m3 (MidiMessage::noteOn (midiChannel, midiNoteNumber + 7, velocity));
m.setTimeStamp (timestamp);
m2.setTimeStamp (timestamp);
m3.setTimeStamp (timestamp);
sendToOutputs (m);
sendToOutputs (m2);
sendToOutputs (m3);
handleNoteOff(midiChannel, midiNoteNumber, velocity)
}
问题是,note off 消息紧跟在 note on 消息之后。我想要音符打开和音符关闭消息之间的延迟。
关于如何做到这一点的任何想法?我在考虑延迟选项,但据我所知它们会冻结整个程序。 JUCE 有什么内置的东西可以帮助我吗?我没能在网上找到它。
JUCE 的 Tutorial: The MidiMessage class 展示了如何延迟发送消息:
The MidiBuffer
class provides functions for iterating over buffers of MIDI messages based on their timestamps. To illustrate this we will set up a simple scheduling system where we add MidiMessage
objects with specific timestamps to a MidiBuffer
object. Then we use a Timer
object that checks regularly whether any MIDI messages are due to be delivered.
Warning
The Timer
class is not suitable for high-precision timing. This is used to keep the example simple by keeping all function calls on the message thread. For more robust timing you should use another thread (in most cases the audio thread is appropriate for rendering MidiBuffer
objects in to audio).
我正在使用 JUCE 框架在 C++ 中制作一个小工具。 它发出 MIDI 但我遇到了问题。 我想向我的 DAW 发送和弦,方法是先发送消息注释,然后发送消息关闭消息。 noteOn 代码如下所示:
void MainContentComponent::handleNoteOn (MidiKeyboardState*, int
midiChannel, int midiNoteNumber, float velocity)
{
timestamp = (Time::getMillisecondCounterHiRes() * 0.001);
MidiMessage m (MidiMessage::noteOn (midiChannel, midiNoteNumber , velocity));
MidiMessage m2 (MidiMessage::noteOn (midiChannel, midiNoteNumber + 3, velocity));
MidiMessage m3 (MidiMessage::noteOn (midiChannel, midiNoteNumber + 7, velocity));
m.setTimeStamp (timestamp);
m2.setTimeStamp (timestamp);
m3.setTimeStamp (timestamp);
sendToOutputs (m);
sendToOutputs (m2);
sendToOutputs (m3);
handleNoteOff(midiChannel, midiNoteNumber, velocity)
}
问题是,note off 消息紧跟在 note on 消息之后。我想要音符打开和音符关闭消息之间的延迟。 关于如何做到这一点的任何想法?我在考虑延迟选项,但据我所知它们会冻结整个程序。 JUCE 有什么内置的东西可以帮助我吗?我没能在网上找到它。
JUCE 的 Tutorial: The MidiMessage class 展示了如何延迟发送消息:
The
MidiBuffer
class provides functions for iterating over buffers of MIDI messages based on their timestamps. To illustrate this we will set up a simple scheduling system where we addMidiMessage
objects with specific timestamps to aMidiBuffer
object. Then we use aTimer
object that checks regularly whether any MIDI messages are due to be delivered.Warning
The
Timer
class is not suitable for high-precision timing. This is used to keep the example simple by keeping all function calls on the message thread. For more robust timing you should use another thread (in most cases the audio thread is appropriate for renderingMidiBuffer
objects in to audio).