|
|
@ -47,6 +47,7 @@ MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE, MIDI); |
|
|
|
Dexed* dexed = new Dexed(SAMPLE_RATE); |
|
|
|
Dexed* dexed = new Dexed(SAMPLE_RATE); |
|
|
|
bool sd_card_available = false; |
|
|
|
bool sd_card_available = false; |
|
|
|
uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR); |
|
|
|
uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR); |
|
|
|
|
|
|
|
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL; |
|
|
|
uint32_t xrun = 0; |
|
|
|
uint32_t xrun = 0; |
|
|
|
uint32_t overload = 0; |
|
|
|
uint32_t overload = 0; |
|
|
|
|
|
|
|
|
|
|
@ -183,7 +184,7 @@ void handle_midi_input(void) |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("MIDI-USB")); |
|
|
|
Serial.println(F("MIDI-USB")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (MIDI.getType() == 0xF0) // SysEX
|
|
|
|
if (MIDI.getType() >= 0xf0) // SysEX
|
|
|
|
{ |
|
|
|
{ |
|
|
|
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength()); |
|
|
|
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength()); |
|
|
|
} |
|
|
|
} |
|
|
@ -195,9 +196,9 @@ void handle_midi_input(void) |
|
|
|
while (MIDI.read()) |
|
|
|
while (MIDI.read()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("MIDI-Serial")); |
|
|
|
Serial.print(F("[MIDI-Serial] ")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (MIDI.getType() == 0xF0) // SYSEX
|
|
|
|
if (MIDI.getType() >= 0xf0) // SYSEX
|
|
|
|
{ |
|
|
|
{ |
|
|
|
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength()); |
|
|
|
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength()); |
|
|
|
} |
|
|
|
} |
|
|
@ -261,13 +262,18 @@ void note_off(void) |
|
|
|
#ifdef SHOW_MIDI_EVENT |
|
|
|
#ifdef SHOW_MIDI_EVENT |
|
|
|
void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.print(F("MIDI event type: 0x")); |
|
|
|
Serial.print(F("MIDI-Channel: ")); |
|
|
|
|
|
|
|
if (midi_channel == MIDI_CHANNEL_OMNI) |
|
|
|
|
|
|
|
Serial.print(F("OMNI")); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Serial.print(midi_channel, DEC); |
|
|
|
|
|
|
|
Serial.print(F(", MIDI event type: 0x")); |
|
|
|
if (type < 16) |
|
|
|
if (type < 16) |
|
|
|
Serial.print(F("0")); |
|
|
|
Serial.print(F("0")); |
|
|
|
Serial.print(type, HEX); |
|
|
|
Serial.print(type, HEX); |
|
|
|
Serial.print(F(" data1: ")); |
|
|
|
Serial.print(F(", data1: ")); |
|
|
|
Serial.print(data1, DEC); |
|
|
|
Serial.print(data1, DEC); |
|
|
|
Serial.print(F(" data2: ")); |
|
|
|
Serial.print(F(", data2: ")); |
|
|
|
Serial.println(data2, DEC); |
|
|
|
Serial.println(data2, DEC); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -294,8 +300,7 @@ bool handle_master_key(uint8_t data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Serial.print(F("Loading voice number ")); |
|
|
|
Serial.print(F("Loading voice number ")); |
|
|
|
Serial.println(num, DEC); |
|
|
|
Serial.println(num, DEC); |
|
|
|
EEPROM.write(EEPROM_VOICE_ADDR, num); |
|
|
|
store_voice_number(bank, num); |
|
|
|
EEPROM.write(EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
@ -329,6 +334,11 @@ bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2) |
|
|
|
print_midi_event(type, data1, data2); |
|
|
|
print_midi_event(type, data1, data2); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_MIDI_EVENT |
|
|
|
|
|
|
|
print_midi_event(type, data1, data2); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
type = type & 0xf0; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
#ifdef MASTER_KEY_MIDI |
|
|
|
if (type == 0x80 && data1 == MASTER_KEY_MIDI) // Master key released
|
|
|
|
if (type == 0x80 && data1 == MASTER_KEY_MIDI) // Master key released
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -409,6 +419,14 @@ int8_t num_key_base_c(uint8_t midi_note) |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void store_voice_number(uint8_t bank, uint8_t voice) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (EEPROM.read(EEPROM_BANK_ADDR) != bank) |
|
|
|
|
|
|
|
EEPROM.write(EEPROM_BANK_ADDR, bank); |
|
|
|
|
|
|
|
if (EEPROM.read(EEPROM_VOICE_ADDR) != voice) |
|
|
|
|
|
|
|
EEPROM.write(EEPROM_VOICE_ADDR, voice); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len) |
|
|
|
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// parse parameter change
|
|
|
|
// parse parameter change
|
|
|
|