Added midi_channel.

Added showing MIDI channel in debug data.
Added checking for necessary write to EEPROM.
pull/4/head
Holger Wirtz 7 years ago
parent f1f406fdb9
commit dfc0644659
  1. 34
      MicroDexed.ino
  2. 5
      config.h

@ -47,6 +47,7 @@ MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE, MIDI);
Dexed* dexed = new Dexed(SAMPLE_RATE);
bool sd_card_available = false;
uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR);
uint8_t midi_channel = DEFAULT_MIDI_CHANNEL;
uint32_t xrun = 0;
uint32_t overload = 0;
@ -183,7 +184,7 @@ void handle_midi_input(void)
#ifdef DEBUG
Serial.println(F("MIDI-USB"));
#endif
if (MIDI.getType() == 0xF0) // SysEX
if (MIDI.getType() >= 0xf0) // SysEX
{
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength());
}
@ -195,9 +196,9 @@ void handle_midi_input(void)
while (MIDI.read())
{
#ifdef DEBUG
Serial.println(F("MIDI-Serial"));
Serial.print(F("[MIDI-Serial] "));
#endif
if (MIDI.getType() == 0xF0) // SYSEX
if (MIDI.getType() >= 0xf0) // SYSEX
{
handle_sysex_parameter(MIDI.getSysExArray(), MIDI.getSysExArrayLength());
}
@ -261,13 +262,18 @@ void note_off(void)
#ifdef SHOW_MIDI_EVENT
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)
Serial.print(F("0"));
Serial.print(type, HEX);
Serial.print(F(" data1: "));
Serial.print(F(", data1: "));
Serial.print(data1, DEC);
Serial.print(F(" data2: "));
Serial.print(F(", data2: "));
Serial.println(data2, DEC);
}
#endif
@ -294,8 +300,7 @@ bool handle_master_key(uint8_t data)
{
Serial.print(F("Loading voice number "));
Serial.println(num, DEC);
EEPROM.write(EEPROM_VOICE_ADDR, num);
EEPROM.write(EEPROM_BANK_ADDR, bank);
store_voice_number(bank, num);
}
}
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);
#endif
#ifdef SHOW_MIDI_EVENT
print_midi_event(type, data1, data2);
#endif
type = type & 0xf0;
#ifdef MASTER_KEY_MIDI
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
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)
{
// parse parameter change

@ -36,6 +36,7 @@
#define MAX_NOTES 16 // Yes
#endif
#define AUDIO_MEM 2
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
#define DEFAULT_SYSEXBANK 0
#define DEFAULT_SYSEXSOUND 0
@ -45,7 +46,7 @@
// Debug output
#define SERIAL_SPEED 38400
#define SHOW_DEXED_TIMING 1
//#define SHOW_DEXED_TIMING 1
#define DEBUG 1
#define SHOW_MIDI_EVENT 1
#define SHOW_XRUN 1
@ -57,7 +58,7 @@
#define REDUCE_LOUDNESS 2
// Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard
#define TEST_NOTE MIDI_E2
//#define TEST_NOTE MIDI_E2
#define TEST_VEL_MIN 60
#define TEST_VEL_MAX 110

Loading…
Cancel
Save