diff --git a/NuEVI.ino b/NuEVI.ino index 64ce176..1ba42d3 100644 --- a/NuEVI.ino +++ b/NuEVI.ino @@ -325,7 +325,7 @@ int mainState; // The state of the main state machine int initial_breath_value; // The breath value at the time we observed the transition -byte activeMIDIchannel=1; // MIDI channel +byte activeMIDIchannel; // MIDI channel byte activePatch=0; byte doPatchUpdate=0; @@ -625,8 +625,8 @@ void setup() { doPatchUpdate=1; } - Serial3.begin(31250); // start serial with midi baudrate 31250 - Serial3.flush(); + activeMIDIchannel = MIDIchannel; + midiInitialize(MIDIchannel); //Serial.begin(9600); // debug diff --git a/midi.h b/midi.h index 0f81a3b..21c7794 100644 --- a/midi.h +++ b/midi.h @@ -6,8 +6,8 @@ #define USE_MIDI_SERIAL //Set / get current midi channel -void midiSetChannel(int channel); -int midiGetChannel(); +void midiSetChannel(byte channel); +byte midiGetChannel(); void midiSendProgramChange(int patch); void midiSendControlChange(int ccParam, int ccValue); @@ -20,7 +20,6 @@ void midiSendPitchBend(int value); void midiReset(); // reset controllers void midiPanic(); // turn all notes off -void dinMIDIsendPitchBend(int pb, byte ch); // Send din pitchbend -void dinMIDIsendAfterTouch(byte value, byte ch); // Send din aftertouch +void midiInitialize(byte channel=1); #endif \ No newline at end of file diff --git a/midi.ino b/midi.ino index 933076a..63327f8 100644 --- a/midi.ino +++ b/midi.ino @@ -1,14 +1,14 @@ #include "midi.h" #include "hardware.h" -int midiChannel = 1; +int midiChannel; -void midiSetChannel(int channel) { +void midiSetChannel(byte channel) { midiChannel = constrain(channel, 1, 16); } -int midiGetChannel() { +byte midiGetChannel() { return midiChannel; } @@ -63,6 +63,12 @@ void midiPanic() { // all notes off } } +void midiInitialize(byte channel) { + MIDI_SERIAL.begin(31250); // start serial with midi baudrate 31250 + MIDI_SERIAL.flush(); + midiSetChannel(channel); +} + //Serial midi functions