Changed to MIDI library event dispatching.

pull/4/head
Holger Wirtz 6 years ago
parent 9edc7ddd4c
commit bff073ceb3
  1. 546
      MicroDexed.ino
  2. 4
      config.h
  3. 134
      dexed.cpp
  4. 13
      dexed.h
  5. 44
      midi_devices.hpp

@ -116,10 +116,6 @@ uint8_t effect_delay_volume = 0;
bool effect_delay_sync = 0;
elapsedMicros fill_audio_buffer;
#ifdef MASTER_KEY_MIDI
bool master_key_enabled = false;
#endif
#ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis;
#endif
@ -359,7 +355,7 @@ void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
{
if (checkMidiChannel(inChannel))
{
;
dexed->keydown(inNumber, inVelocity);
}
}
@ -367,15 +363,119 @@ void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
{
if (checkMidiChannel(inChannel))
{
;
dexed->keyup(inNumber);
}
}
void handleControlChange(byte inChannel, byte inData1, byte inData2)
void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
{
if (checkMidiChannel(inChannel))
{
;
switch (inCtrl) {
case 0: // ignore BankSelect MSB
break;
case 1:
dexed->controllers.modwheel_cc = inValue;
dexed->controllers.refresh();
break;
case 2:
dexed->controllers.breath_cc = inValue;
dexed->controllers.refresh();
break;
case 4:
dexed->controllers.foot_cc = inValue;
dexed->controllers.refresh();
break;
case 7: // Volume
vol = float(inValue) / 0x7f;
set_volume(vol, vol_left, vol_right);
break;
case 10: // Pan
if (inValue < 64)
{
vol_left = 1.0;
vol_right = float(inValue) / 0x40;
set_volume(vol, vol_left, vol_right);
}
else if (inValue > 64)
{
vol_left = float(0x7f - inValue) / 0x40;
vol_right = 1.0;
set_volume(vol, vol_left, vol_right);
}
else
{
vol_left = 1.0;
vol_right = 1.0;
set_volume(vol, vol_left, vol_right);
}
break;
case 32: // BankSelect LSB
bank = inValue;
break;
case 64:
dexed->setSustain(inValue > 63);
if (!dexed->getSustain()) {
for (uint8_t note = 0; note < dexed->getMaxNotes(); note++) {
if (dexed->voices[note].sustained && !dexed->voices[note].keydown) {
dexed->voices[note].dx7_note->keyup();
dexed->voices[note].sustained = false;
}
}
}
break;
case 0x66: // CC 102: filter frequency
effect_filter_frq = map(inValue, 0, 127, 0, ENC_FILTER_FRQ_STEPS);
if (effect_filter_frq == ENC_FILTER_FRQ_STEPS)
{
// turn "off" filter
mixer1.gain(0, 0.0); // filtered signal off
mixer1.gain(3, 1.0); // original signal on
}
else
{
// turn "on" filter
mixer1.gain(0, 1.0); // filtered signal on
mixer1.gain(3, 0.0); // original signal off
}
filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0);
break;
case 0x67: // CC 103: filter resonance
effect_filter_resonance = map(inValue, 0, 127, 0, ENC_FILTER_RES_STEPS);
filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61);
break;
case 0x68: // CC 104: filter octave
effect_filter_octave = map(inValue, 0, 127, 0, ENC_FILTER_OCT_STEPS);
filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0));
break;
case 0x69: // CC 105: delay time
effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS);
delay1.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
break;
case 0x6A: // CC 106: delay feedback
effect_delay_feedback = map(inValue, 0, 127, 0, ENC_DELAY_FB_STEPS);
mixer1.gain(1, mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0));
break;
case 0x6B: // CC 107: delay volume
effect_delay_volume = map(inValue, 0, 127, 0, ENC_DELAY_VOLUME_STEPS);
mixer2.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delay tap1 signal (with added feedback)
break;
case 120:
dexed->panic();
break;
case 121:
dexed->resetControllers();
break;
case 123:
dexed->notesOff();
break;
case 126:
dexed->setMonoMode(true);
break;
case 127:
dexed->setMonoMode(false);
break;
}
}
}
@ -396,14 +496,68 @@ void handleProgramChange(byte inChannel, byte inProgram)
;
}
void handleSystemExclusive(byte *data, uint len)
void handleSystemExclusive(byte *sysex, uint len)
{
handle_sysex_parameter(data, len);
}
if (sysex[1] != 0x43) // check for Yamaha sysex
{
#ifdef DEBUG
Serial.println(F("E: SysEx vendor not Yamaha."));
#endif
return;
}
void handleSystemExclusiveChunk(const byte *data, uint16_t len, bool last)
{
;
// parse parameter change
if (len == 7)
{
if ((sysex[3] & 0x7c) != 0 || (sysex[3] & 0x7c) != 2)
{
#ifdef DEBUG
Serial.println(F("E: Not a SysEx parameter or function parameter change."));
#endif
return;
}
if (sysex[6] != 0xf7)
{
#ifdef DEBUG
Serial.println(F("E: SysEx end status byte not detected."));
#endif
return;
}
if ((sysex[3] & 0x7c) == 0)
{
dexed->data[sysex[4]] = sysex[5]; // set parameter
dexed->doRefreshVoice();
}
else
{
dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET - 63 + sysex[4]] = sysex[5]; // set function parameter
dexed->controllers.values_[kControllerPitchRange] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE];
dexed->controllers.values_[kControllerPitchStep] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP];
dexed->controllers.wheel.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE]);
dexed->controllers.wheel.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN]);
dexed->controllers.foot.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE]);
dexed->controllers.foot.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN]);
dexed->controllers.breath.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE]);
dexed->controllers.breath.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN]);
dexed->controllers.at.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE]);
dexed->controllers.at.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN]);
dexed->controllers.masterTune = (dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] * 0x4000 << 11) * (1.0 / 12);
dexed->controllers.refresh();
}
#ifdef DEBUG
Serial.print(F("SysEx"));
if ((sysex[3] & 0x7c) == 0)
Serial.print(F(" function"));
Serial.print(F(" parameter "));
Serial.print(sysex[4], DEC);
Serial.print(F(" = "));
Serial.println(sysex[5], DEC);
#endif
}
#ifdef DEBUG
else
Serial.println(F("E: SysEx parameter length wrong."));
#endif
}
void handleTimeCodeQuarterFrame(byte data)
@ -428,7 +582,21 @@ void handleTuneRequest(void)
void handleClock(void)
{
;
midi_timing_counter++;
if (midi_timing_counter % 24 == 0)
{
midi_timing_quarter = midi_timing_timestep;
midi_timing_counter = 0;
midi_timing_timestep = 0;
// Adjust delay control here
#ifdef DEBUG
Serial.print(F("MIDI Timing: "));
Serial.print(60000 / midi_timing_quarter, DEC);
Serial.print(F("bpm ("));
Serial.print(midi_timing_quarter, DEC);
Serial.println(F("ms per quarter)"));
#endif
}
}
void handleStart(void)
@ -453,12 +621,12 @@ void handleActiveSensing(void)
void handleSystemReset(void)
{
;
}
void handleRealTimeSystem(void)
{
;
#ifdef DEBUG
Serial.println(F("MIDI SYSEX RESET"));
#endif
dexed->notesOff();
dexed->panic();
dexed->resetControllers();
}
bool checkMidiChannel(byte inChannel)
@ -482,241 +650,6 @@ bool checkMidiChannel(byte inChannel)
return (true);
}
#ifdef MASTER_KEY_MIDI
bool handle_master_key(uint8_t data)
{
int8_t num = num_key_base_c(data);
#ifdef DEBUG
Serial.print(F("Master-Key: "));
Serial.println(num, DEC);
#endif
if (num > 0)
{
// a white key!
if (num <= 32)
{
if (load_sysex(bank, num))
{
#ifdef DEBUG
Serial.print(F("Loading voice number "));
Serial.println(num, DEC);
#endif
eeprom_write(EEPROM_UPDATE_VOICE);
#ifdef I2C_DISPLAY
lcd.show(1, 0, 2, voice + 1);
lcd.show(1, 2, 1, " ");
lcd.show(1, 3, 10, voice_names[voice]);
#endif
}
#ifdef DEBUG
else
{
Serial.print(F("E: cannot load voice number "));
Serial.println(num, DEC);
}
#endif
}
return (true);
}
else
{
// a black key!
num = abs(num);
if (num <= 10)
{
set_volume(float(num * 0.1), vol_left, vol_right);
}
else if (num > 10 && num <= 20)
{
bank = num - 10;
#ifdef DEBUG
Serial.print(F("Bank switch to: "));
Serial.println(bank, DEC);
#endif
eeprom_write(EEPROM_UPDATE_BANK);
#ifdef I2C_DISPLAY
if (get_voice_names_from_bank(bank))
{
strip_extension(bank_names[bank], bank_name);
lcd.show(0, 0, 2, bank);
lcd.show(0, 2, 1, " ");
lcd.show(0, 3, 10, bank_name);
}
else
{
lcd.show(0, 0, 2, bank);
lcd.show(0, 2, 10, " *ERROR*");
}
#endif
return (true);
}
}
return (false);
}
#endif
bool queue_midi_event(uint8_t type, uint8_t data1, uint8_t data2)
{
bool ret = false;
// check for MIDI channel
if (midi_channel != MIDI_CHANNEL_OMNI)
{
uint8_t c = type & 0x0f;
if (c != midi_channel - 1)
{
#ifdef DEBUG
Serial.print(F("Ignoring MIDI data on channel "));
Serial.print(c);
Serial.print(F("(listening on "));
Serial.print(midi_channel);
Serial.println(F(")"));
#endif
return (false);
}
}
// now throw away the MIDI channel information
type &= 0xf0;
#ifdef MASTER_KEY_MIDI
if (type == 0x80 && data1 == MASTER_KEY_MIDI) // Master key released
{
master_key_enabled = false;
#ifdef DEBUG
Serial.println(F("Master key disabled"));
#endif
}
else if (type == 0x90 && data1 == MASTER_KEY_MIDI) // Master key pressed
{
master_key_enabled = true;
#ifdef DEBUG
Serial.println(F("Master key enabled"));
#endif
}
else
{
if (master_key_enabled)
{
if (type == 0x80) // handle when note is released
{
dexed->notesOff();
handle_master_key(data1);
}
}
else
#endif
{
if (type == 0xb0)
{
switch (data1)
{
case 0x66: // CC 102: filter frequency
effect_filter_frq = map(data2, 0, 127, 0, ENC_FILTER_FRQ_STEPS);
if (effect_filter_frq == ENC_FILTER_FRQ_STEPS)
{
// turn "off" filter
mixer1.gain(0, 0.0); // filtered signal off
mixer1.gain(3, 1.0); // original signal on
}
else
{
// turn "on" filter
mixer1.gain(0, 1.0); // filtered signal on
mixer1.gain(3, 0.0); // original signal off
}
filter1.frequency(EXP_FUNC((float)map(effect_filter_frq, 0, ENC_FILTER_FRQ_STEPS, 0, 1024) / 150.0) * 10.0 + 80.0);
break;
case 0x67: // CC 103: filter resonance
effect_filter_resonance = map(data2, 0, 127, 0, ENC_FILTER_RES_STEPS);
filter1.resonance(EXP_FUNC(mapfloat(effect_filter_resonance, 0, ENC_FILTER_RES_STEPS, 0.7, 5.0)) * 0.044 + 0.61);
break;
case 0x68: // CC 104: filter octave
effect_filter_octave = map(data2, 0, 127, 0, ENC_FILTER_OCT_STEPS);
filter1.octaveControl(mapfloat(effect_filter_octave, 0, ENC_FILTER_OCT_STEPS, 0.0, 7.0));
break;
case 0x69: // CC 105: delay time
effect_delay_time = map(data2, 0, 127, 0, ENC_DELAY_TIME_STEPS);
delay1.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
break;
case 0x6A: // CC 106: delay feedback
effect_delay_feedback = map(data2, 0, 127, 0, ENC_DELAY_FB_STEPS);
mixer1.gain(1, mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0));
break;
case 0x6B: // CC 107: delay volume
effect_delay_volume = map(data2, 0, 127, 0, ENC_DELAY_VOLUME_STEPS);
mixer2.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delay tap1 signal (with added feedback)
break;
default:
ret = dexed->processMidiMessage(type, data1, data2);
break;
}
}
else
ret = dexed->processMidiMessage(type, data1, data2);
}
#ifdef MASTER_KEY_MIDI
}
#endif
return (ret);
}
#ifdef MASTER_KEY_MIDI
int8_t num_key_base_c(uint8_t midi_note)
{
int8_t num = 0;
switch (midi_note % 12)
{
// positive numbers are white keys, negative black ones
case 0:
num = 1;
break;
case 1:
num = -1;
break;
case 2:
num = 2;
break;
case 3:
num = -2;
break;
case 4:
num = 3;
break;
case 5:
num = 4;
break;
case 6:
num = -3;
break;
case 7:
num = 5;
break;
case 8:
num = -4;
break;
case 9:
num = 6;
break;
case 10:
num = -5;
break;
case 11:
num = 7;
break;
}
if (num > 0)
return (num + (((midi_note - MASTER_NUM1) / 12) * 7));
else
return (num + ((((midi_note - MASTER_NUM1) / 12) * 5) * -1));
}
#endif
void set_volume(float v, float vr, float vl)
{
vol = v;
@ -759,107 +692,6 @@ void set_volume(float v, float vr, float vl)
#endif
}
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len)
{
if (sysex[0] != 240)
{
switch (sysex[0])
{
case 241: // MIDI Time Code Quarter Frame
break;
case 248: // Timing Clock (24 frames per quarter note)
midi_timing_counter++;
if (midi_timing_counter % 24 == 0)
{
midi_timing_quarter = midi_timing_timestep;
midi_timing_counter = 0;
midi_timing_timestep = 0;
// Adjust delay control here
#ifdef DEBUG
Serial.print(F("MIDI Timing: "));
Serial.print(60000 / midi_timing_quarter, DEC);
Serial.print(F("bpm ("));
Serial.print(midi_timing_quarter, DEC);
Serial.println(F("ms per quarter)"));
#endif
}
break;
case 255: // Reset To Power Up
#ifdef DEBUG
Serial.println(F("MIDI SYSEX RESET"));
#endif
dexed->notesOff();
dexed->panic();
dexed->resetControllers();
break;
}
}
else
{
if (sysex[1] != 0x43) // check for Yamaha sysex
{
#ifdef DEBUG
Serial.println(F("E: SysEx vendor not Yamaha."));
#endif
return;
}
// parse parameter change
if (len == 7)
{
if ((sysex[3] & 0x7c) != 0 || (sysex[3] & 0x7c) != 2)
{
#ifdef DEBUG
Serial.println(F("E: Not a SysEx parameter or function parameter change."));
#endif
return;
}
if (sysex[6] != 0xf7)
{
#ifdef DEBUG
Serial.println(F("E: SysEx end status byte not detected."));
#endif
return;
}
if ((sysex[3] & 0x7c) == 0)
{
dexed->data[sysex[4]] = sysex[5]; // set parameter
dexed->doRefreshVoice();
}
else
{
dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET - 63 + sysex[4]] = sysex[5]; // set function parameter
dexed->controllers.values_[kControllerPitchRange] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE];
dexed->controllers.values_[kControllerPitchStep] = dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP];
dexed->controllers.wheel.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE]);
dexed->controllers.wheel.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN]);
dexed->controllers.foot.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE]);
dexed->controllers.foot.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN]);
dexed->controllers.breath.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE]);
dexed->controllers.breath.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN]);
dexed->controllers.at.setRange(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE]);
dexed->controllers.at.setTarget(dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN]);
dexed->controllers.masterTune = (dexed->data[DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE] * 0x4000 << 11) * (1.0 / 12);
dexed->controllers.refresh();
}
#ifdef DEBUG
Serial.print(F("SysEx"));
if ((sysex[3] & 0x7c) == 0)
Serial.print(F(" function"));
Serial.print(F(" parameter "));
Serial.print(sysex[4], DEC);
Serial.print(F(" = "));
Serial.println(sysex[5], DEC);
#endif
}
#ifdef DEBUG
else
Serial.println(F("E: SysEx parameter length wrong."));
#endif
}
}
void initial_values_from_eeprom(void)
{
uint32_t crc_eeprom = read_eeprom_checksum();

@ -74,10 +74,6 @@
// EFFECTS
#define FILTER_MAX_FREQ 10000
// Master key handling (comment for disabling)
//#define MASTER_KEY_MIDI MIDI_C7
#define MASTER_NUM1 MIDI_C2
// Debug output
#define SERIAL_SPEED 38400
#define DEBUG 1

@ -190,119 +190,6 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
}
}
bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)
{
switch (type & 0xf0) {
case 0x80 :
keyup(data1);
return (false);
break;
case 0x90 :
keydown(data1, data2);
return (false);
break;
case 0xb0 : {
uint8_t ctrl = data1;
uint8_t value = data2;
switch (ctrl) {
case 0: // ignore BankSelect MSB
break;
case 1:
controllers.modwheel_cc = value;
controllers.refresh();
break;
case 2:
controllers.breath_cc = value;
controllers.refresh();
break;
case 4:
controllers.foot_cc = value;
controllers.refresh();
break;
case 7: // Volume
vol = float(value) / 0x7f;
set_volume(vol, vol_left, vol_right);
break;
case 10: // Pan
if (value < 64)
{
vol_left = 1.0;
vol_right = float(value) / 0x40;
set_volume(vol, vol_left, vol_right);
}
else if (value > 64)
{
vol_left = float(0x7f - value) / 0x40;
vol_right = 1.0;
set_volume(vol, vol_left, vol_right);
}
else
{
vol_left = 1.0;
vol_right = 1.0;
set_volume(vol, vol_left, vol_right);
}
break;
case 32: // BankSelect LSB
bank = data2;
break;
case 64:
sustain = value > 63;
if (!sustain) {
for (uint8_t note = 0; note < max_notes; note++) {
if (voices[note].sustained && !voices[note].keydown) {
voices[note].dx7_note->keyup();
voices[note].sustained = false;
}
}
}
break;
case 120:
panic();
return (true);
break;
case 121:
resetControllers();
return (true);
break;
case 123:
notesOff();
return (true);
break;
case 126:
setMonoMode(true);
return (true);
break;
case 127:
setMonoMode(false);
return (true);
break;
}
break;
}
case 0xc0 : // ProgramChange
load_sysex(bank, data1);
break;
// channel aftertouch
case 0xd0 :
controllers.aftertouch_cc = data1;
controllers.refresh();
break;
// pitchbend
case 0xe0 :
controllers.values_[kControllerPitch] = data1 | (data2 << 7);
break;
default:
break;
}
return (false);
}
void Dexed::keydown(uint8_t pitch, uint8_t velo) {
if ( velo == 0 ) {
keyup(pitch);
@ -400,6 +287,7 @@ void Dexed::doRefreshVoice(void)
{
refreshVoice = true;
}
void Dexed::setOPs(uint8_t ops)
{
controllers.opSwitch = ops;
@ -530,6 +418,19 @@ void Dexed::setMonoMode(bool mode) {
monoMode = mode;
}
void Dexed::setSustain(bool s)
{
if (sustain == s)
return;
sustain = s;
}
bool Dexed::getSustain(void)
{
return sustain;
}
void Dexed::panic(void) {
for (uint8_t i = 0; i < MAX_ACTIVE_NOTES; i++)
{
@ -574,6 +475,11 @@ void Dexed::setMaxNotes(uint8_t n) {
}
}
uint8_t Dexed::getMaxNotes(void)
{
return max_notes;
}
bool Dexed::loadSysexVoice(uint8_t* new_data)
{
uint8_t* p_data = data;
@ -680,7 +586,7 @@ bool Dexed::loadSysexVoice(uint8_t* new_data)
//activate();
strncpy(voice_name, (char *)&data[145], sizeof(voice_name) - 1);
#ifdef DEBUG
//char voicename[11];
//memset(voicename, 0, sizeof(voicename));

@ -37,7 +37,6 @@
#include <Audio.h>
#include "config.h"
extern uint8_t bank;
extern uint32_t overload;
extern bool load_sysex(uint8_t bank, uint8_t voice_number);
extern AudioControlSGTL5000 sgtl5000_1;
@ -149,15 +148,20 @@ class Dexed
bool isMonoMode(void);
void setMonoMode(bool mode);
void getSamples(uint16_t n_samples, int16_t* buffer);
bool processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2);
void panic(void);
void notesOff(void);
void resetControllers(void);
void setMaxNotes(uint8_t n);
uint8_t getMaxNotes(void);
void doRefreshVoice(void);
void setOPs(uint8_t ops);
bool loadSysexVoice(uint8_t* data);
void keyup(uint8_t pitch);
void keydown(uint8_t pitch, uint8_t velo);
void setSustain(bool sustain);
bool getSustain(void);
ProcessorVoice voices[MAX_NOTES];
Controllers controllers;
uint8_t data[173] = {
@ -179,13 +183,8 @@ class Dexed
}; // FM-Piano
protected:
//void onParam(uint8_t param_num,float param_val);
void keyup(uint8_t pitch);
void keydown(uint8_t pitch, uint8_t velo);
static const uint8_t MAX_ACTIVE_NOTES = MAX_NOTES;
uint8_t max_notes = MAX_ACTIVE_NOTES;
ProcessorVoice voices[MAX_ACTIVE_NOTES];
uint8_t currentNote;
bool sustain;
bool monoMode;

@ -25,7 +25,6 @@
#define MIDI_DEVICES_H
#include "config.h"
#include <MIDI.h>
#if defined(MIDI_DEVICE_USB)
#include <midi_UsbTransport.h>
@ -280,7 +279,7 @@ void handleTimeCodeQuarterFrame_MIDI_DEVICE_DIN(byte data)
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.sendTimeCodeQuarterFrame(data);
midi_usb.sendTimeCodeQuarterFrame(0xF1, data);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
@ -299,7 +298,7 @@ void handleTimeCodeQuarterFrame_MIDI_DEVICE_DIN(byte data)
void handleAfterTouchPoly_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity)
{
handleAfterTouch(inChannel, inNumber, inVelocity);
handleAfterTouchPoly(inChannel, inNumber, inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_DIN] AT-Poly"));
#endif
@ -424,7 +423,7 @@ void handleStart_MIDI_DEVICE_DIN(void)
void handleContinue_MIDI_DEVICE_DIN(void)
{
handle();
handleContinue();
#ifdef DEBUG
Serial.print(F("[MIDI_DIN] Continue"));
#endif
@ -521,6 +520,7 @@ void handleSystemReset_MIDI_DEVICE_DIN(void)
#endif
#endif
}
void handlRealTimeSysteme_MIDI_DEVICE_DIN(byte inRealTime)
{
handleRealTimeSystem();
@ -535,9 +535,9 @@ void handlRealTimeSysteme_MIDI_DEVICE_DIN(byte inRealTime)
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.sendRealTime(inRealTIme);
//midi_onboard_usb.sendRealTime(inRealTIme);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
Serial.print(F(" THRU->MIDI_USB[NOTSUPPORTED]"));
#endif
#endif
#ifdef DEBUG
@ -1244,7 +1244,7 @@ void handleTimeCodeQuarterFrame_MIDI_DEVICE_USB(midi::DataByte data)
#endif
#endif
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.sendTimeCodeQuarterFrame(0xF1,data);
midi_usb.sendTimeCodeQuarterFrame(0xF1, data);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
@ -1487,7 +1487,7 @@ void handleRealTimeSystem_MIDI_DEVICE_USB(byte inRealTime)
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.sendRealTime(inRealTime);
midi_serial.sendRealTime((midi::MidiType)inRealTime);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
@ -1520,32 +1520,32 @@ void setup_midi_devices(void)
midi_serial.setHandlePitchBend(handlePitchBend_MIDI_DEVICE_DIN);
midi_serial.setHandleProgramChange(handleProgramChange_MIDI_DEVICE_DIN);
midi_serial.setHandleSystemExclusive(handleSystemExclusive_MIDI_DEVICE_DIN);
midi_serial.setHandleSystemExclusiveChunk(handleSystemExclusiveChunk_MIDI_DEVICE_DIN);
//midi_serial.setHandleSystemExclusiveChunk(handleSystemExclusiveChunk_MIDI_DEVICE_DIN);
midi_serial.setHandleTimeCodeQuarterFrame(handleTimeCodeQuarterFrame_MIDI_DEVICE_DIN);
midi_serial.setHandleAfterTouchPoly(handleAfterTouchPoly_MIDI_DEVICE_DIN);
midi_Serial.setHandleSongSelect(handleSongSelect_MIDI_DEVICE_DIN);
midi_Serial.setHandleTuneRequest(handleTuneRequest_MIDI_DEVICE_DIN);
midi_Serial.setHandleClock(handleClock_MIDI_DEVICE_DIN);
midi_Serial.setHandleStart(handleStart_MIDI_DEVICE_DIN);
midi_Serial.setHandleContinue(handleContinue_MIDI_DEVICE_DIN);
midi_Serial.setHandleStop(handleStop_MIDI_DEVICE_DIN);
midi_Serial.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_DIN);
midi_Serial.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_DIN);
midi_Serial.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_DIN);
midi_serial.setHandleSongSelect(handleSongSelect_MIDI_DEVICE_DIN);
midi_serial.setHandleTuneRequest(handleTuneRequest_MIDI_DEVICE_DIN);
midi_serial.setHandleClock(handleClock_MIDI_DEVICE_DIN);
midi_serial.setHandleStart(handleStart_MIDI_DEVICE_DIN);
midi_serial.setHandleContinue(handleContinue_MIDI_DEVICE_DIN);
midi_serial.setHandleStop(handleStop_MIDI_DEVICE_DIN);
midi_serial.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_DIN);
midi_serial.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_DIN);
//midi_serial.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_DIN);
Serial.println(F("MIDI_DEVICE_DIN enabled"));
#endif
// start up USB host
#ifdef MIDI_DEVICE_DIN
#ifdef MIDI_DEVICE_USB_HOST
usb_host.begin();
midi_usb.setHandleNoteOn(handleNoteOn_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleNoteOff(handleNoteOff_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleControlChange(handleControlChange_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleAfterTouchChannel(handleAfterTouch_MIDI_DEVICE_USB_HOST);
midi_usb.setHandlePitchBend(handlePitchBend_MIDI_DEVICE_USB_HOST);
//midi_usb.setHandlePitchBend(handlePitchBend_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleProgramChange(handleProgramChange_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleSystemExclusive(handleSystemExclusive_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleSystemExclusiveChunk(handleSystemExclusiveChunk_MIDI_DEVICE_USB_HOST);
//midi_usb.setHandleSystemExclusiveChunk(handleSystemExclusiveChunk_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleTimeCodeQuarterFrame(handleTimeCodeQuarterFrame_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleAfterTouchPoly(handleAfterTouchPoly_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleSongSelect(handleSongSelect_MIDI_DEVICE_USB_HOST);
@ -1556,7 +1556,7 @@ void setup_midi_devices(void)
midi_usb.setHandleStop(handleStop_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleActiveSensing(handleActiveSensing_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleSystemReset(handleSystemReset_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB_HOST);
//midi_usb.setHandleRealTimeSystem(handleRealTimeSystem_MIDI_DEVICE_USB_HOST);
Serial.println(F("MIDI_DEVICE_USB_HOST enabled."));
#endif

Loading…
Cancel
Save