|
|
|
@ -64,7 +64,7 @@ AudioConnection patchCord8(modchorus_filter, 0, master_mixer_l, 3); |
|
|
|
|
AudioConnection patchCord9(modchorus, 0, master_mixer_r, 3); |
|
|
|
|
AudioConnection patchCord10(modchorus, 0, master_mixer_l, 3); |
|
|
|
|
#endif |
|
|
|
|
#ifdef USE_REVERB |
|
|
|
|
#if defined(USE_REVERB) |
|
|
|
|
AudioEffectFreeverbStereo freeverbs1; |
|
|
|
|
AudioConnection patchCord11(queue1, 0, freeverbs1, 0); |
|
|
|
|
AudioConnection patchCord12(queue1, 0, freeverbs1, 1); |
|
|
|
@ -125,15 +125,9 @@ uint8_t midi_timing_counter = 0; // 24 per qarter |
|
|
|
|
elapsedMillis midi_timing_timestep; |
|
|
|
|
uint16_t midi_timing_quarter = 0; |
|
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
|
SoftenValue <float> soften_volume; |
|
|
|
|
SoftenValue <float> soften_filter_res[NUM_DEXED]; |
|
|
|
|
SoftenValue <float> soften_filter_cut[NUM_DEXED]; |
|
|
|
|
uint8_t effect_filter_cutoff = 0; |
|
|
|
|
uint8_t effect_filter_resonance = 0; |
|
|
|
|
uint8_t effect_delay_time = 0; |
|
|
|
|
uint8_t effect_delay_feedback = 0; |
|
|
|
|
uint8_t effect_delay_volume = 0; |
|
|
|
|
bool effect_delay_sync = 0; |
|
|
|
|
SoftenValue <uint8_t> soften_volume; |
|
|
|
|
SoftenValue <uint8_t> soften_filter_res[NUM_DEXED]; |
|
|
|
|
SoftenValue <uint8_t> soften_filter_cut[NUM_DEXED]; |
|
|
|
|
elapsedMicros fill_audio_buffer; |
|
|
|
|
elapsedMillis control_rate; |
|
|
|
|
uint8_t active_voices = 0; |
|
|
|
@ -142,11 +136,11 @@ elapsedMillis cpu_mem_millis; |
|
|
|
|
#endif |
|
|
|
|
config_t configuration = { |
|
|
|
|
0xffff, |
|
|
|
|
DEFAULT_SYSEXBANK, |
|
|
|
|
DEFAULT_SYSEXSOUND, |
|
|
|
|
VOLUME, |
|
|
|
|
0.5f, // pan
|
|
|
|
|
0, // mono
|
|
|
|
|
SYSEXBANK_DEFAULT, |
|
|
|
|
SYSEXSOUND_DEFAULT, |
|
|
|
|
VOLUME_DEFAULT, |
|
|
|
|
PANORAMA_DEFAULT, // pan
|
|
|
|
|
MONO_DEFAULT, // mono
|
|
|
|
|
DEFAULT_MIDI_CHANNEL, |
|
|
|
|
REVERB_ROOMSIZE_DEFAULT, |
|
|
|
|
REVERB_DAMPING_DEFAULT, |
|
|
|
@ -154,7 +148,10 @@ config_t configuration = { |
|
|
|
|
CHORUS_FREQUENCY_DEFAULT, |
|
|
|
|
CHORUS_WAVEFORM_DEFAULT, |
|
|
|
|
CHORUS_DEPTH_DEFAULT, |
|
|
|
|
CHORUS_LEVEL_DEFAULT |
|
|
|
|
CHORUS_LEVEL_DEFAULT, |
|
|
|
|
FILTER_CUTOFF_DEFAULT, |
|
|
|
|
FILTER_RESONANCE_DEFAULT, |
|
|
|
|
LOUDNESS_DEFAULT |
|
|
|
|
}; |
|
|
|
|
bool eeprom_update_flag = false; |
|
|
|
|
|
|
|
|
@ -370,7 +367,7 @@ void setup() |
|
|
|
|
|
|
|
|
|
// set initial volume and pan (read from EEPROM)
|
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
soften_volume.init(configuration.vol, 0.0, 1.0); |
|
|
|
|
soften_volume.init(configuration.vol, VOLUME_MIN, VOLUME_MAX); |
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
|
// Initialize processor and memory measurements
|
|
|
|
@ -430,10 +427,6 @@ void loop() |
|
|
|
|
if (peak1.read() > 0.99) |
|
|
|
|
peak++; |
|
|
|
|
} |
|
|
|
|
#ifndef TEENSY_AUDIO_BOARD |
|
|
|
|
for (uint8_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
|
audio_buffer[i] *= configuration.vol; |
|
|
|
|
#endif |
|
|
|
|
queue1.playBuffer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -506,7 +499,7 @@ void loop() |
|
|
|
|
set_volume(soften_volume.value(), configuration.pan); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Volume: ")); |
|
|
|
|
Serial.print(configuration.vol, 5); |
|
|
|
|
Serial.print(configuration.vol, DEC); |
|
|
|
|
Serial.print(F(" step: ")); |
|
|
|
|
Serial.print(soften_volume.steps()); |
|
|
|
|
Serial.print(F(" diff: ")); |
|
|
|
@ -563,73 +556,107 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
MicroDexed[0]->controllers.modwheel_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.modwheel_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
MicroDexed[0]->controllers.breath_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.breath_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
MicroDexed[0]->controllers.foot_cc = inValue; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.foot_cc = inValue; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 7: // Volume
|
|
|
|
|
configuration.vol = float(inValue) / 0x7f; |
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
configuration.vol = map(inValue, 0, 0x7f, VOLUME_MIN, VOLUME_MAX); |
|
|
|
|
soften_volume.update(configuration.vol, SOFTEN_VALUE_CHANGE_STEPS); |
|
|
|
|
break; |
|
|
|
|
case 10: // Pan
|
|
|
|
|
configuration.pan = float(inValue) / 128; |
|
|
|
|
configuration.pan = map(inValue, 0, 0x7f, PANORAMA_MIN, PANORAMA_MAX); |
|
|
|
|
set_volume(configuration.vol, configuration.pan); |
|
|
|
|
break; |
|
|
|
|
case 32: // BankSelect LSB
|
|
|
|
|
configuration.bank = inValue; |
|
|
|
|
break; |
|
|
|
|
case 64: |
|
|
|
|
MicroDexed[0]->setSustain(inValue > 63); |
|
|
|
|
if (!MicroDexed[0]->getSustain()) { |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setSustain(inValue > 63); |
|
|
|
|
if (!MicroDexed[i]->getSustain()) { |
|
|
|
|
for (uint8_t note = 0; note < MicroDexed[0]->getMaxNotes(); note++) { |
|
|
|
|
if (MicroDexed[0]->voices[note].sustained && !MicroDexed[0]->voices[note].keydown) { |
|
|
|
|
MicroDexed[0]->voices[note].dx7_note->keyup(); |
|
|
|
|
MicroDexed[0]->voices[note].sustained = false; |
|
|
|
|
if (MicroDexed[i]->voices[note].sustained && !MicroDexed[i]->voices[note].keydown) { |
|
|
|
|
MicroDexed[i]->voices[note].dx7_note->keyup(); |
|
|
|
|
MicroDexed[i]->voices[note].sustained = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 103: // CC 103: filter resonance
|
|
|
|
|
effect_filter_resonance = map(inValue, 0, 127, 0, ENC_FILTER_RES_STEPS); |
|
|
|
|
MicroDexed[0]->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS; |
|
|
|
|
configuration.filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Reso = configuration.filter_resonance / 100.0; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 104: // CC 104: filter cutoff
|
|
|
|
|
effect_filter_cutoff = map(inValue, 0, 127, 0, ENC_FILTER_CUT_STEPS); |
|
|
|
|
MicroDexed[0]->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS; |
|
|
|
|
configuration.filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->fx.Cutoff = configuration.filter_cutoff / 100.0; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 105: // CC 105: delay time
|
|
|
|
|
effect_delay_time = map(inValue, 0, 127, 0, ENC_DELAY_TIME_STEPS); |
|
|
|
|
////delay.delay(0, mapfloat(effect_delay_time, 0, ENC_DELAY_TIME_STEPS, 0.0, DELAY_MAX_TIME));
|
|
|
|
|
break; |
|
|
|
|
configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); |
|
|
|
|
delay1.delay(0, configuration.delay_time * 10); |
|
|
|
|
case 106: // CC 106: delay feedback
|
|
|
|
|
effect_delay_feedback = map(inValue, 0, 127, 0, ENC_DELAY_FB_STEPS); |
|
|
|
|
////delay_mixer_r.gain(1, mapfloat(float(effect_delay_feedback), 0, ENC_DELAY_FB_STEPS, 0.0, 1.0));
|
|
|
|
|
configuration.delay_feedback = map(inValue, 0, 0x7f, DELAY_FEEDBACK_MIN , DELAY_FEEDBACK_MAX); |
|
|
|
|
delay_fb_mixer.gain(1, configuration.delay_feedback / 100.0 ); // amount of feedback
|
|
|
|
|
delay_fb_mixer.gain(0, 1.0 - configuration.delay_feedback / 100.0); // original signalbreak;
|
|
|
|
|
break; |
|
|
|
|
case 107: // CC 107: delay volume
|
|
|
|
|
effect_delay_volume = map(inValue, 0, 127, 0, ENC_DELAY_VOLUME_STEPS); |
|
|
|
|
////delay_mixer_l.gain(1, mapfloat(effect_delay_volume, 0, ENC_DELAY_VOLUME_STEPS, 0.0, 1.0)); // delay tap1 signal (with added feedback)
|
|
|
|
|
configuration.delay_level = map(inValue, 0, 0x7f, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); |
|
|
|
|
master_mixer_r.gain(2, configuration.delay_level / 100.0); |
|
|
|
|
master_mixer_l.gain(2, configuration.delay_level / 100.0); |
|
|
|
|
break; |
|
|
|
|
case 120: |
|
|
|
|
MicroDexed[0]->panic(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->panic(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 121: |
|
|
|
|
MicroDexed[0]->resetControllers(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->resetControllers(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 123: |
|
|
|
|
MicroDexed[0]->notesOff(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->notesOff(); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 126: |
|
|
|
|
MicroDexed[0]->setMonoMode(true); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setMonoMode(true); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 127: |
|
|
|
|
MicroDexed[0]->setMonoMode(false); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->setMonoMode(false); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -637,13 +664,19 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) |
|
|
|
|
|
|
|
|
|
void handleAfterTouch(byte inChannel, byte inPressure) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[0]->controllers.aftertouch_cc = inPressure; |
|
|
|
|
MicroDexed[0]->controllers.refresh(); |
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.aftertouch_cc = inPressure; |
|
|
|
|
MicroDexed[i]->controllers.refresh(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handlePitchBend(byte inChannel, int inPitch) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[0]->controllers.values_[kControllerPitch] = inPitch + 0x2000; // -8192 to +8191 --> 0 to 16383
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DEXED; i++) |
|
|
|
|
{ |
|
|
|
|
MicroDexed[i]->controllers.values_[kControllerPitch] = inPitch + 0x2000; // -8192 to +8191 --> 0 to 16383
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void handleProgramChange(byte inChannel, byte inProgram) |
|
|
|
@ -934,19 +967,23 @@ bool checkMidiChannel(byte inChannel) |
|
|
|
|
VOLUME HELPER |
|
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
void set_volume(float v, float p) |
|
|
|
|
void set_volume(uint8_t v, int8_t p) |
|
|
|
|
{ |
|
|
|
|
configuration.vol = v; |
|
|
|
|
configuration.pan = p; |
|
|
|
|
|
|
|
|
|
MicroDexed[0]->fx.Gain = v; |
|
|
|
|
|
|
|
|
|
uint16_t tmp = v * 1023.0 + 0.5; |
|
|
|
|
float tmp2 = configuration.pan; |
|
|
|
|
uint16_t tmp = v / 100.0 * 1023.0 + 0.5; |
|
|
|
|
float tmp2 = mapfloat(configuration.pan, PANORAMA_MIN, PANORAMA_MAX, 0.0, 1.0); |
|
|
|
|
float tmp3 = (float)(tmp * (tmp + 2)) / (float)(1 << 20); |
|
|
|
|
#ifdef SHOW_DEBUG |
|
|
|
|
|
|
|
|
|
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
|
|
|
|
|
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
|
|
|
|
|
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2)); |
|
|
|
|
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2)); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Setting volume: VOL=")); |
|
|
|
|
Serial.print(value, DEC); |
|
|
|
|
Serial.print(configuration.vol, DEC); |
|
|
|
|
Serial.print(F("[")); |
|
|
|
|
Serial.print(tmp3, 3); |
|
|
|
|
Serial.print(F("] PAN=")); |
|
|
|
@ -959,15 +996,21 @@ void set_volume(float v, float p) |
|
|
|
|
Serial.println(tmp3 * cosf(tmp2 * PI / 2), 3); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
|
|
|
|
|
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
|
|
|
|
|
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2)); |
|
|
|
|
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2)); |
|
|
|
|
|
|
|
|
|
if (configuration.mono == 2) |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(1.0); |
|
|
|
|
volume_l.gain(0.0); |
|
|
|
|
} |
|
|
|
|
else if (configuration.mono == 3) |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(0.0); |
|
|
|
|
volume_l.gain(1.0); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
volume_r.gain(1.0); |
|
|
|
|
volume_l.gain(1.0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// https://www.dr-lex.be/info-stuff/volumecontrols.html#table1
|
|
|
|
@ -1011,10 +1054,8 @@ void initial_values_from_eeprom(void) |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (configuration.vol > 1.0) |
|
|
|
|
configuration.vol = 1.0; |
|
|
|
|
else if (configuration.vol < 0.0) |
|
|
|
|
configuration.vol = 0.0; |
|
|
|
|
if (configuration.vol > 100) |
|
|
|
|
configuration.vol = 100; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void eeprom_write(void) |
|
|
|
|