Master key reworked (now only working when hold and using a command key).

Fixes.
pull/4/head
Holger Wirtz 7 years ago
parent 0adb5eb3eb
commit 95c783fab6
  1. 64
      MicroDexed.ino
  2. 1
      config.h
  3. 8
      dexed.cpp
  4. 2
      dexed_sysex.cpp

@ -44,9 +44,10 @@ AudioControlSGTL5000 sgtl5000_1; //xy=507,403
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
Dexed* dexed = new Dexed(SAMPLE_RATE);
IntervalTimer sched_master_key_auto_disable;
bool sd_card_available = false;
#ifdef MASTER_KEY_MIDI
bool master_key_enabled = false;
#endif
#ifdef SHOW_CPU_LOAD_MSEC
IntervalTimer sched_show_cpu_usage;
@ -257,10 +258,28 @@ void note_off(void)
}
#endif
#ifdef SHOW_MIDI_EVENT
void print_midi_event(uint8_t type, uint8_t data1, uint8_t data2)
{
Serial.print("MIDI event type: 0x");
if (type < 16)
Serial.print(F("0"));
Serial.print(type, HEX);
Serial.print(" data1: ");
Serial.print(data1, DEC);
Serial.print(" data2: ");
Serial.println(data2, DEC);
}
#endif
#ifdef MASTER_KEY_MIDI
bool handle_master_key(uint8_t data)
{
int8_t num = num_key_base_c(data);
Serial.print(F("Key->Number: "));
Serial.println(num);
if (num > 0)
{
// a white key!
@ -293,41 +312,39 @@ bool handle_master_key(uint8_t data)
}
return (false);
}
#endif
bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2)
{
bool ret = false;
#ifdef SHOW_MIDI_EVENT
Serial.print("MIDI event type: ");
Serial.print(type, DEC);
Serial.print(" data1: ");
Serial.print(data1, DEC);
Serial.print(" data2: ");
Serial.println(data2, DEC);
print_midi_event(type, data1, data2);
#endif
if (master_key_enabled == true)
#ifdef MASTER_KEY_MIDI
if (master_key_enabled == true && type == 0x80)
{
master_key_enabled = handle_master_key(data1);
if (master_key_enabled == false)
Serial.println("Master key disabled");
}
else
if (type == 0x80 && data1 == MASTER_KEY_MIDI)
{
if (type == 0x80 && data1 == MASTER_KEY_MIDI) // ignore Master key up
return (false);
master_key_enabled = false;
Serial.println("Master key disabled");
}
else if (type == 0x90 && data1 == MASTER_KEY_MIDI) // Master key pressed
{
sched_master_key_auto_disable.begin(master_key_auto_disable, MASTER_KEY_AUTO_DISABLE_MSEC * 1000);
master_key_enabled = true;
Serial.println("Master key enabled");
}
else
return (dexed->processMidiMessage(type, data1, data2));
}
return (false);
#endif
ret = dexed->processMidiMessage(type, data1, data2);
return (ret);
}
#ifdef MASTER_KEY_MIDI
int8_t num_key_base_c(uint8_t midi_note)
{
switch (midi_note % 12)
@ -360,6 +377,7 @@ int8_t num_key_base_c(uint8_t midi_note)
}
return (0);
}
#endif
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len)
{
@ -415,16 +433,6 @@ void handle_sysex_parameter(const uint8_t* sysex, uint8_t len)
Serial.println(F("E: SysEx parameter length wrong."));
}
void master_key_auto_disable(void)
{
if (master_key_enabled == true)
{
master_key_enabled = false;
Serial.println("Auto disabling master key");
}
sched_master_key_auto_disable.end();
}
#ifdef SHOW_CPU_LOAD_MSEC
void show_cpu_and_mem_usage(void)
{

@ -44,7 +44,6 @@
#define DEFAULT_SYSEXSOUND 0
#define MASTER_KEY_MIDI 84 // C6
#define MASTER_KEY_AUTO_DISABLE_MSEC 5000
#define MASTER_NUM1 24 // C1
#define MASTER_BANK_SELECT 83 // B5

@ -155,14 +155,6 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)
{
#ifdef SHOW_MIDI_EVENT
Serial.print("MIDI event type: ");
Serial.print(type, DEC);
Serial.print(" data1: ");
Serial.print(data1, DEC);
Serial.print(" data2: ");
Serial.println(data2, DEC);
#endif
switch (type & 0xf0) {
case 0x80 :
keyup(data1);

@ -57,8 +57,6 @@ bool load_sysex(char *name, uint8_t voice_number)
{
if (!entry.isDirectory())
{
Serial.println(entry.name());
if (strcmp(name, entry.name()) == 0)
{
uint8_t data[128];

Loading…
Cancel
Save