diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 7579669d..2be8f982 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -156,6 +156,11 @@ void CamomileAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBloc m_midi_buffer_in.clear(); m_midi_buffer_out.clear(); m_midi_buffer_temp.clear(); + + m_midibyte_index = 0; + m_midibyte_buffer[0] = 0; + m_midibyte_buffer[1] = 0; + m_midibyte_buffer[2] = 0; startDSP(); processMessages(); processPrints(); @@ -298,6 +303,10 @@ void CamomileAudioProcessor::processInternal() ////////////////////////////////////////////////////////////////////////////////////////// if(m_produces_midi) { + m_midibyte_index = 0; + m_midibyte_buffer[0] = 0; + m_midibyte_buffer[1] = 0; + m_midibyte_buffer[2] = 0; m_midi_buffer_out.clear(); processMidi(); } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index bc2d4ff2..3146263d 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -135,6 +135,8 @@ class CamomileAudioProcessor : public AudioProcessor, public pd::Instance, publi MidiBuffer m_midi_buffer_in; MidiBuffer m_midi_buffer_out; MidiBuffer m_midi_buffer_temp; + int m_midibyte_buffer[3]; + int m_midibyte_index; int m_program_current = 0; diff --git a/Source/PluginProcessorReceive.cpp b/Source/PluginProcessorReceive.cpp index 913ea9d2..0692d91d 100644 --- a/Source/PluginProcessorReceive.cpp +++ b/Source/PluginProcessorReceive.cpp @@ -50,7 +50,20 @@ void CamomileAudioProcessor::receivePolyAftertouch(const int channel, const int void CamomileAudioProcessor::receiveMidiByte(const int port, const int byte) { - m_midi_buffer_out.addEvent(MidiMessage(byte), m_audio_advancement); +#if 0 + if(m_midibyte_index == 0) + { + add(ConsoleLevel::Error, "Process Send Midi Bytes ----"); + } + add(ConsoleLevel::Error, std::to_string(byte)); +#endif + + m_midibyte_buffer[m_midibyte_index++] = byte; + if(m_midibyte_index >= 3) + { + m_midi_buffer_out.addEvent(MidiMessage(m_midibyte_buffer[0], m_midibyte_buffer[1], m_midibyte_buffer[2]), m_audio_advancement); + m_midibyte_index = 0; + } } //////////////////////////////////////////////////////////////////////////////////////////////