Skip to content

Commit

Permalink
Midi: Fix MIDI byte out using 3 bytes structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Sep 16, 2018
1 parent f0ad077 commit e3cea72
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion Source/PluginProcessorReceive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit e3cea72

Please sign in to comment.