Im making a little tool in C++ using the JUCE framework. Its sending out MIDI but I've come to a problem. I'd like to send out chords to my DAW, by sending a note on message followed by a note off message. The noteOn code looks like this:
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)
}
The problem is, that the note off message follows directly after the note on message. I'd like a delay between the note on and note off message. Any idea's on how to do that? I was thinking about delay options, but as far as I know they will freeze the entire program. Does JUCE have anything built in that can help me? I wasn't able to find it online.