I have a plugin host sequencer software sending notes to a plugin, but for some reason, the notes sometimes don’t get to their destination, resulting with unheard notes, and stuck notes.
I checked through the console and it appears all the appropriate note messages are getting out from the sequencer, Meaning it must be something in the way I fill the MidiBuffer of the plugin.
void PluginInstrument::noteIn(int note, int velocity)
{
MidiMessage event;
event = MidiMessage::noteOn(1, note, ((float)velocity)/127);
m_midiBuffer.addEvent(event, m_midiMessagePosition); m_midiMessagePosition += 10;
}
void PluginInstrument::getNextAudioBlock (const AudioSourceChannelInfo &bufferToFill)
{
if (currentPlugin== nullptr)
bufferToFill.clearActiveBufferRegion();
else
{
m_midiBufferOutput = m_midiBuffer;
currentPlugin->processBlock(*bufferToFill.buffer, m_midiBufferOutput);
m_midiBuffer.clear();
m_midiMessagePosition = 0;
}
};
I tried different things including raising each incoming note message timing by 10 samples interval, separating the input buffer and output buffer, and try different plugins… The only thing worked out when I filled the MidiBuffer of the plugin with one note message for each processBlock function. But then, the delay time between each note was highly perceivable.
Truly appreciate any kind of help.