Nicer MIDI initialization
This commit is contained in:
parent
c70858709e
commit
a56cddf5e4
3 changed files with 15 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
7
midi.h
7
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
|
12
midi.ino
12
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue