Fixed overload problem.

New audio stack is not working cleanly.
pull/32/head
Holger Wirtz 5 years ago
parent c8afc7fa09
commit ff48558d29
  1. 204
      MicroDexed.ino
  2. 14
      UI.hpp
  3. 16
      config.h

@ -61,32 +61,34 @@ AudioConnection patchCord3(delay_l, 0, delay_fb_mixer_l, 1); // feedba
AudioConnection patchCord4(delay_fb_mixer_l, 0, master_mixer_l, DELAY); AudioConnection patchCord4(delay_fb_mixer_l, 0, master_mixer_l, DELAY);
AudioMixer4 chorus_send_mixer_l; AudioMixer4 chorus_send_mixer_l;
AudioEffectModulatedDelay modchorus_l; AudioEffectModulatedDelay modchorus_l;
AudioConnection patchCord5(chorus_modulator, 0, modchorus_l, 1); AudioConnection patchCord5(chorus_send_mixer_l, modchorus_l);
AudioConnection patchCord6(chorus_modulator, 0, modchorus_l, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter_l; AudioFilterBiquad modchorus_filter_l;
AudioConnection patchCord6(modchorus_l, modchorus_filter_l); AudioConnection patchCord7(modchorus_l, modchorus_filter_l);
AudioConnection patchCord7(modchorus_filter_l, modchorus_inverter); AudioConnection patchCord8(modchorus_filter_l, modchorus_inverter);
AudioConnection patchCord8(modchorus_inverter_l, 0, master_mixer_l, CHORUS ); AudioConnection patchCord9(modchorus_inverter_l, 0, master_mixer_l, CHORUS );
#else #else
AudioConnection patchCord9(modchorus_l, modchorus_inverter); AudioConnection patchCord7(modchorus_l, modchorus_inverter);
AudioConnection patchCord10(modchorus_inverter, 0, master_mixer_l, CHORUS); AudioConnection patchCord8(modchorus_inverter, 0, master_mixer_l, CHORUS);
#endif #endif
#if defined(USE_REVERB) #if defined(USE_REVERB)
AudioMixer4 reverb_send_mixer_l; AudioMixer4 reverb_send_mixer_l;
AudioEffectFreeverb freeverb_l; AudioEffectFreeverb freeverb_l;
AudioConnection patchCord11(reverb_send_mixer_l, freeverb_l); AudioConnection patchCord10(reverb_send_mixer_l, freeverb_l);
AudioConnection patchCord12(freeverb_l, 0, master_mixer_r, REVERB); AudioConnection patchCord11(freeverb_l, 0, master_mixer_r, REVERB);
#endif #endif
// FX chain right // FX chain right
AudioMixer4 delay_send_mixer_r; AudioMixer4 delay_send_mixer_r;
AudioMixer4 delay_fb_mixer_r; AudioMixer4 delay_fb_mixer_r;
AudioEffectDelay delay_r; AudioEffectDelay delay_r;
AudioConnection patchCord13(delay_send_mixer_r, 0, delay_fb_mixer_r, 0); AudioConnection patchCord12(delay_send_mixer_r, 0, delay_fb_mixer_r, 0);
AudioConnection patchCord14(delay_fb_mixer_r, delay_r); AudioConnection patchCord13(delay_fb_mixer_r, delay_r);
AudioConnection patchCord15(delay_r, 0, delay_fb_mixer_r, 1); // feedback-loop AudioConnection patchCord14(delay_r, 0, delay_fb_mixer_r, 1); // feedback-loop
AudioConnection patchCord16(delay_fb_mixer_r, 0, master_mixer_r, DELAY); AudioConnection patchCord15(delay_fb_mixer_r, 0, master_mixer_r, DELAY);
AudioMixer4 chorus_send_mixer_r; AudioMixer4 chorus_send_mixer_r;
AudioConnection patchCord16(chorus_send_mixer_r, modchorus_r);
AudioEffectModulatedDelay modchorus_r; AudioEffectModulatedDelay modchorus_r;
AudioConnection patchCord17(chorus_modulator, 0, modchorus_r, 1); AudioConnection patchCord17(chorus_modulator, 0, modchorus_r, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
@ -94,13 +96,13 @@ AudioFilterBiquad modchorus_filter_r;
AudioConnection patchCord18(modchorus_r, modchorus_filter_r); AudioConnection patchCord18(modchorus_r, modchorus_filter_r);
AudioConnection patchCord19(modchorus_filter_r, 0, master_mixer_r, CHORUS ); AudioConnection patchCord19(modchorus_filter_r, 0, master_mixer_r, CHORUS );
#else #else
AudioConnection patchCord20(modchorus_r, 0, master_mixer_r, CHORUS); AudioConnection patchCord18(modchorus_r, 0, master_mixer_r, CHORUS);
#endif #endif
#if defined(USE_REVERB) #if defined(USE_REVERB)
AudioMixer4 reverb_send_mixer_r; AudioMixer4 reverb_send_mixer_r;
AudioEffectFreeverb freeverb_r; AudioEffectFreeverb freeverb_r;
AudioConnection patchCord21(reverb_send_mixer_r, freeverb_r); AudioConnection patchCord20(reverb_send_mixer_r, freeverb_r);
AudioConnection patchCord22(freeverb_r, 0, master_mixer_r, REVERB); AudioConnection patchCord21(freeverb_r, 0, master_mixer_r, REVERB);
#endif #endif
// FX chain tail // FX chain tail
@ -113,50 +115,50 @@ AudioAmplifier volume_l;
AudioEffectStereoMono stereo2mono; AudioEffectStereoMono stereo2mono;
AudioAnalyzePeak master_peak_r; AudioAnalyzePeak master_peak_r;
AudioAnalyzePeak master_peak_l; AudioAnalyzePeak master_peak_l;
AudioConnection patchCord23(dexed_mixer_r, 0, master_mixer_r, DEXED); AudioConnection patchCord22(dexed_mixer_r, 0, master_mixer_r, DEXED);
AudioConnection patchCord24(dexed_mixer_l, 0, master_mixer_l, DEXED); AudioConnection patchCord23(dexed_mixer_l, 0, master_mixer_l, DEXED);
AudioConnection patchCord25(master_mixer_r, volume_r); AudioConnection patchCord24(master_mixer_r, volume_r);
AudioConnection patchCord26(master_mixer_l, volume_l); AudioConnection patchCord25(master_mixer_l, volume_l);
AudioConnection patchCord27(volume_r, 0, stereo2mono, 0); AudioConnection patchCord26(volume_r, 0, stereo2mono, 0);
AudioConnection patchCord28(volume_l, 0, stereo2mono, 1); AudioConnection patchCord27(volume_l, 0, stereo2mono, 1);
AudioConnection patchCord29(volume_r, master_peak_r); AudioConnection patchCord28(volume_r, master_peak_r);
AudioConnection patchCord30(volume_l, master_peak_l); AudioConnection patchCord29(volume_l, master_peak_l);
AudioConnection patchCord31(microdexed_peak_mixer, microdexed_peak); AudioConnection patchCord30(microdexed_peak_mixer, microdexed_peak);
// Outputs // Outputs
#ifdef AUDIO_DEVICE_USB #ifdef AUDIO_DEVICE_USB
AudioOutputUSB usb1; AudioOutputUSB usb1;
AudioConnection patchCord32(stereo2mono, 0, usb1, 0); AudioConnection patchCord31(stereo2mono, 0, usb1, 0);
AudioConnection patchCord33(stereo2mono, 1, usb1, 1); AudioConnection patchCord32(stereo2mono, 1, usb1, 1);
#endif #endif
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord34(stereo2mono, 0, i2s1, 0); AudioConnection patchCord33(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord35(stereo2mono, 1, i2s1, 1); AudioConnection patchCord34(stereo2mono, 1, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; AudioControlSGTL5000 sgtl5000_1;
#elif defined (I2S_AUDIO_ONLY) #elif defined (I2S_AUDIO_ONLY)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord36(stereo2mono, 0, i2s1, 0); AudioConnection patchCord33(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord37(stereo2mono, 1, i2s1, 1); AudioConnection patchCord34(stereo2mono, 1, i2s1, 1);
#elif defined(TGA_AUDIO_BOARD) #elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord38(stereo2mono, 0, i2s1, 0); AudioConnection patchCord33(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord39(stereo2mono, 1, i2s1, 1); AudioConnection patchCord34(stereo2mono, 1, i2s1, 1);
AudioControlWM8731master wm8731_1; AudioControlWM8731master wm8731_1;
#elif defined(PT8211_AUDIO) #elif defined(PT8211_AUDIO)
AudioOutputPT8211 pt8211_1; AudioOutputPT8211 pt8211_1;
AudioConnection patchCord40(stereo2mono, 0, pt8211_1, 0); AudioConnection patchCord33(stereo2mono, 0, pt8211_1, 0);
AudioConnection patchCord41(stereo2mono, 1, pt8211_1, 1); AudioConnection patchCord34(stereo2mono, 1, pt8211_1, 1);
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioMixer4 invMixer; AudioMixer4 invMixer;
AudioConnection patchCord42(stereo2mono, 0, dacOut , 0); AudioConnection patchCord33(stereo2mono, 0, dacOut , 0);
AudioConnection patchCord43(stereo2mono, 1, invMixer, 0); AudioConnection patchCord34(stereo2mono, 1, invMixer, 0);
AudioConnection patchCord44(invMixer, 0, dacOut , 1); AudioConnection patchCord35(invMixer, 0, dacOut , 1);
#else #else
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioConnection patchCord45(stereo2mono, 0, dacOut, 0); AudioConnection patchCord33(stereo2mono, 0, dacOut, 0);
AudioConnection patchCord46(stereo2mono, 1, dacOut, 1); AudioConnection patchCord34(stereo2mono, 1, dacOut, 1);
#endif #endif
// //
@ -198,7 +200,7 @@ uint16_t midi_timing_quarter = 0;
elapsedMillis long_button_pressed; elapsedMillis long_button_pressed;
//elapsedMicros fill_audio_buffer; //elapsedMicros fill_audio_buffer;
elapsedMillis control_rate; elapsedMillis control_rate;
uint8_t active_voices = 0; uint8_t active_voices[NUM_DEXED];
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
#endif #endif
@ -301,7 +303,8 @@ void setup()
lcd.print(F("EEPROM")); lcd.print(F("EEPROM"));
initial_values_from_eeprom(true); initial_values_from_eeprom(true);
} }
else*/ else
initial_values_from_eeprom(false); */
initial_values_from_eeprom(false); initial_values_from_eeprom(false);
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
@ -348,6 +351,9 @@ void setup()
Serial.println(F("Internal DAC enabled.")); Serial.println(F("Internal DAC enabled."));
#endif #endif
// Load values from EEPROM
//initial_values_from_eeprom(false);
// start SD card // start SD card
#ifndef TEENSY4 #ifndef TEENSY4
SPI.setMOSI(SDCARD_MOSI_PIN); SPI.setMOSI(SDCARD_MOSI_PIN);
@ -420,8 +426,7 @@ void setup()
Serial.println(F(" samples")); Serial.println(F(" samples"));
#endif #endif
master_mixer_r.gain(DEXED, 1.0); set_master_mixer_gain(DEXED, 1.0);
master_mixer_l.gain(DEXED, 1.0);
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -429,22 +434,22 @@ void setup()
microdexed_peak_mixer.gain(instance_id, 1.0); microdexed_peak_mixer.gain(instance_id, 1.0);
// INIT DEXED MIXER // INIT DEXED MIXER
dexed_mixer_r.gain(instance_id, 0.5); dexed_mixer_r.gain(instance_id, 1.0);
dexed_mixer_l.gain(instance_id, 0.5); dexed_mixer_l.gain(instance_id, 1.0);
#ifdef USE_REVERB #ifdef USE_REVERB
// INIT REVERB // INIT REVERB
reverb_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 0.5)); reverb_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0));
reverb_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 0.5)); reverb_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].reverb_send, REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0));
#endif #endif
// INIT DELAY // INIT DELAY
delay_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 0.5)); delay_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0));
delay_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 0.5)); delay_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].delay_send, DELAY_SEND_MIN, DELAY_SEND_MAX, 0.0, 1.0));
// INIT CHORUS // INIT CHORUS
chorus_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 0.5)); chorus_send_mixer_r.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0));
chorus_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 0.5)); chorus_send_mixer_l.gain(instance_id, mapfloat(configuration.dexed[instance_id].chorus_send, CHORUS_SEND_MIN, CHORUS_SEND_MAX, 0.0, 1.0));
// DEXED FILTER // DEXED FILTER
MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 1.0); MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 1.0);
@ -456,17 +461,8 @@ void setup()
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
} }
// REVERB
master_mixer_r.gain(REVERB, 0.0);
master_mixer_l.gain(REVERB, 0.0);
freeverb_r.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
// DELAY // DELAY
master_mixer_r.gain(DELAY, 0.0); set_master_mixer_gain(DELAY, configuration.delay_level / 100.0);
master_mixer_l.gain(DELAY, 0.0);
delay_r.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX))); delay_r.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX)));
delay_l.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX))); delay_l.delay(0, mapfloat(configuration.delay_time * 10, DELAY_TIME_MIN, DELAY_TIME_MAX, 0.0, float(DELAY_TIME_MAX)));
// delay_fb_mixer is the feedback-adding mixer // delay_fb_mixer is the feedback-adding mixer
@ -474,8 +470,7 @@ void setup()
delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
// CHORUS // CHORUS
master_mixer_r.gain(CHORUS, 0.0); set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0);
master_mixer_l.gain(CHORUS, 0.0);
switch (configuration.chorus_waveform) switch (configuration.chorus_waveform)
{ {
case 0: case 0:
@ -507,6 +502,15 @@ void setup()
modchorus_filter_l.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3); modchorus_filter_l.setLowpass(3, MOD_FILTER_CUTOFF_HZ, 1.3);
#endif #endif
#if defined(USE_REVERB)
// REVERB
set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0);
freeverb_r.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_r.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
freeverb_l.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
freeverb_l.damping(mapfloat(configuration.reverb_damping, REVERB_DAMPING_MIN, REVERB_DAMPING_MAX, 0.0, 1.0));
#endif
// MONO/STEREO // MONO/STEREO
if (configuration.mono == 0) if (configuration.mono == 0)
modchorus_inverter.gain(-1.0); // stereo mode modchorus_inverter.gain(-1.0); // stereo mode
@ -522,17 +526,17 @@ void setup()
AudioMemoryUsageMaxReset(); AudioMemoryUsageMaxReset();
#endif #endif
#ifdef DEBUG
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
#ifdef DEBUG
Serial.print(F("Bank/Voice from EEPROM [")); Serial.print(F("Bank/Voice from EEPROM ["));
Serial.print(configuration.dexed[instance_id].bank, DEC); Serial.print(configuration.dexed[instance_id].bank, DEC);
Serial.print(F("/")); Serial.print(F("/"));
Serial.print(configuration.dexed[instance_id].voice, DEC); Serial.print(configuration.dexed[instance_id].voice, DEC);
Serial.println(F("]")); Serial.println(F("]"));
show_patch(instance_id); show_patch(instance_id);
#endif
} }
#endif
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.print(AUDIO_BLOCK_SAMPLES); Serial.print(AUDIO_BLOCK_SAMPLES);
@ -605,7 +609,6 @@ void loop()
#endif #endif
// EEPROM update handling // EEPROM update handling
//if (autostore >= AUTOSTORE_MS && active_voices == 0 && eeprom_update_flag == true)
if (autostore >= AUTOSTORE_MS && eeprom_update_flag == true) if (autostore >= AUTOSTORE_MS && eeprom_update_flag == true)
{ {
// only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore // only store configuration data to EEPROM when AUTOSTORE_MS is reached and no voices are activated anymore
@ -615,7 +618,7 @@ void loop()
// check for value changes and unused voices // check for value changes and unused voices
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
active_voices = MicroDexed[instance_id]->getNumNotesPlaying(); active_voices[instance_id] = MicroDexed[instance_id]->getNumNotesPlaying();
} }
} }
@ -784,8 +787,7 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
break; break;
case 107: // CC 107: delay volume case 107: // CC 107: delay volume
configuration.dexed[instance_id].delay_send = map(inValue, 0, 0x7f, DELAY_SEND_MIN, DELAY_SEND_MAX); configuration.dexed[instance_id].delay_send = map(inValue, 0, 0x7f, DELAY_SEND_MIN, DELAY_SEND_MAX);
master_mixer_r.gain(DELAY, configuration.dexed[instance_id].delay_send / 200.0); set_master_mixer_gain(DELAY, configuration.delay_level / 100.0);
master_mixer_l.gain(DELAY, configuration.dexed[instance_id].delay_send / 200.0);
eeprom_write(); eeprom_write();
break; break;
case 120: case 120:
@ -1204,8 +1206,8 @@ void set_volume(uint8_t v, uint8_t m)
Serial.println(v, DEC); Serial.println(v, DEC);
#endif #endif
volume_r.gain(v); volume_r.gain(v / 100.0);
volume_l.gain(v); volume_l.gain(v / 100.0);
switch (m) switch (m)
{ {
@ -1244,12 +1246,6 @@ void set_volume(uint8_t v, uint8_t m)
} }
} }
// https://www.dr-lex.be/info-stuff/volumecontrols.html#table1
inline float logvol(float x)
{
return (0.001 * expf(6.908 * x));
}
/****************************************************************************** /******************************************************************************
EEPROM HELPER EEPROM HELPER
******************************************************************************/ ******************************************************************************/
@ -1283,6 +1279,7 @@ void initial_values_from_eeprom(bool init)
else else
{ {
EEPROM.get(EEPROM_START_ADDRESS, configuration); EEPROM.get(EEPROM_START_ADDRESS, configuration);
check_configuration();
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -1293,19 +1290,37 @@ void initial_values_from_eeprom(bool init)
MicroDexed[instance_id]->setATController(configuration.dexed[instance_id].at_range, configuration.dexed[instance_id].at_assign); MicroDexed[instance_id]->setATController(configuration.dexed[instance_id].at_range, configuration.dexed[instance_id].at_assign);
MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled);
MicroDexed[instance_id]->doRefreshVoice(); MicroDexed[instance_id]->doRefreshVoice();
chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 200.0);
chorus_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].chorus_send / 200.0);
delay_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0);
delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0);
#if defined(USE_REVERB)
reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0);
reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0);
#endif
MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled);
MicroDexed[instance_id]->fx.Gain = configuration.dexed[instance_id].sound_intensity / 100.0;
MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0);
MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
} }
} }
Serial.println(F("OK, loaded!")); Serial.println(F("OK, loaded!"));
}
check_configuration(); set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0);
set_master_mixer_gain(DELAY, configuration.delay_level / 100.0);
#if defined(USE_REVERB)
set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0);
#endif
set_master_mixer_gain(DEXED, 1.0);
set_volume(configuration.vol, configuration.mono);
}
#ifdef DEBUG #ifdef DEBUG
show_configuration(); show_configuration();
#endif #endif
if (configuration.vol > 100)
configuration.vol = 100; // just to be sure ;-)
} }
void check_configuration(void) void check_configuration(void)
@ -1322,7 +1337,7 @@ void check_configuration(void)
configuration.chorus_waveform = constrain(configuration.chorus_waveform, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); configuration.chorus_waveform = constrain(configuration.chorus_waveform, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX);
configuration.chorus_depth = constrain(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); configuration.chorus_depth = constrain(configuration.chorus_depth, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX);
configuration.chorus_level = constrain(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); configuration.chorus_level = constrain(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX);
configuration.delay_time = constrain(configuration.delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX); configuration.delay_time = constrain(configuration.delay_time, DELAY_TIME_MIN / 10, DELAY_TIME_MAX / 10);
configuration.delay_feedback = constrain(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); configuration.delay_feedback = constrain(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX);
configuration.delay_level = constrain(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); configuration.delay_level = constrain(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX);
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
@ -1357,12 +1372,6 @@ void check_configuration(void)
configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX);
configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX);
} }
set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0);
set_master_mixer_gain(DELAY, configuration.delay_level / 100.0);
#if defined(USE_REVERB)
set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0);
#endif
} }
void init_configuration(void) void init_configuration(void)
@ -1384,7 +1393,7 @@ void init_configuration(void)
configuration.chorus_waveform = CHORUS_WAVEFORM_DEFAULT; configuration.chorus_waveform = CHORUS_WAVEFORM_DEFAULT;
configuration.chorus_depth = CHORUS_DEPTH_DEFAULT; configuration.chorus_depth = CHORUS_DEPTH_DEFAULT;
configuration.chorus_level = CHORUS_LEVEL_DEFAULT; configuration.chorus_level = CHORUS_LEVEL_DEFAULT;
configuration.delay_time = DELAY_TIME_DEFAULT; configuration.delay_time = DELAY_TIME_DEFAULT / 10;
configuration.delay_feedback = DELAY_FEEDBACK_DEFAULT; configuration.delay_feedback = DELAY_FEEDBACK_DEFAULT;
configuration.delay_level = DELAY_LEVEL_DEFAULT; configuration.delay_level = DELAY_LEVEL_DEFAULT;
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
@ -1493,7 +1502,11 @@ void set_master_mixer_gain(uint8_t type, float level)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Volumes for master_mixer: DEXED=")); Serial.print(F("Volumes for master_mixer(type="));
Serial.print(type, DEC);
Serial.print(F(",level="));
Serial.print(level, 2);
Serial.print(F("): DEXED="));
Serial.print(new_level[DEXED], 2); Serial.print(new_level[DEXED], 2);
Serial.print(F(" CHORUS=")); Serial.print(F(" CHORUS="));
Serial.print(new_level[CHORUS], 2); Serial.print(new_level[CHORUS], 2);
@ -1551,7 +1564,14 @@ void show_cpu_and_mem_usage(void)
Serial.print(F("|BLOCKSIZE:")); Serial.print(F("|BLOCKSIZE:"));
Serial.print(AUDIO_BLOCK_SAMPLES, DEC); Serial.print(AUDIO_BLOCK_SAMPLES, DEC);
Serial.print(F("|ACTVOICES:")); Serial.print(F("|ACTVOICES:"));
Serial.print(active_voices, DEC); for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
Serial.print(instance_id, DEC);
Serial.print(F("="));
Serial.print(active_voices[instance_id], DEC);
if (instance_id != NUM_DEXED - 1)
Serial.print(F(","));
}
Serial.println(); Serial.println();
Serial.flush(); Serial.flush();
AudioProcessorUsageMaxReset(); AudioProcessorUsageMaxReset();

@ -205,8 +205,8 @@ LCDML_add(6, LCDML_0_1_1, 5, "Reverb Send 1", UI_func_reverb_send);
LCDML_add(7, LCDML_0_1_1, 6, "Chorus Send 1", UI_func_chorus_send); LCDML_add(7, LCDML_0_1_1, 6, "Chorus Send 1", UI_func_chorus_send);
LCDML_add(8, LCDML_0_1_1, 7, "Delay Send 1", UI_func_delay_send); LCDML_add(8, LCDML_0_1_1, 7, "Delay Send 1", UI_func_delay_send);
LCDML_add(9, LCDML_0_1_1, 8, "Filter 1", NULL); LCDML_add(9, LCDML_0_1_1, 8, "Filter 1", NULL);
LCDML_add(10, LCDML_0_1_1_6, 1, "Cutoff 1", UI_func_filter_cutoff); LCDML_add(10, LCDML_0_1_1_8, 1, "Cutoff 1", UI_func_filter_cutoff);
LCDML_add(11, LCDML_0_1_1_6, 2, "Resonance 1", UI_func_filter_resonance); LCDML_add(11, LCDML_0_1_1_8, 2, "Resonance 1", UI_func_filter_resonance);
LCDML_add(12, LCDML_0_1_1, 9, "Panorama 1", UI_func_panorama); LCDML_add(12, LCDML_0_1_1, 9, "Panorama 1", UI_func_panorama);
LCDML_add(13, LCDML_0_1_1, 10, "Polyphony 1", UI_func_polyphony); LCDML_add(13, LCDML_0_1_1, 10, "Polyphony 1", UI_func_polyphony);
LCDML_add(14, LCDML_0_1_1, 11, "Engine 1", UI_func_engine); LCDML_add(14, LCDML_0_1_1, 11, "Engine 1", UI_func_engine);
@ -246,8 +246,8 @@ LCDML_add(47, LCDML_0_1_2, 5, "Reverb Send 2", UI_func_reverb_send);
LCDML_add(48, LCDML_0_1_2, 6, "Chorus Send 2", UI_func_chorus_send); LCDML_add(48, LCDML_0_1_2, 6, "Chorus Send 2", UI_func_chorus_send);
LCDML_add(49, LCDML_0_1_2, 7, "Delay Send 2", UI_func_delay_send); LCDML_add(49, LCDML_0_1_2, 7, "Delay Send 2", UI_func_delay_send);
LCDML_add(50, LCDML_0_1_2, 8, "Filter 1", NULL); LCDML_add(50, LCDML_0_1_2, 8, "Filter 1", NULL);
LCDML_add(51, LCDML_0_1_2_6, 1, "Cutoff 1", UI_func_filter_cutoff); LCDML_add(51, LCDML_0_1_2_8, 1, "Cutoff 1", UI_func_filter_cutoff);
LCDML_add(52, LCDML_0_1_2_6, 2, "Resonance 1", UI_func_filter_resonance); LCDML_add(52, LCDML_0_1_2_8, 2, "Resonance 1", UI_func_filter_resonance);
LCDML_add(53, LCDML_0_1_2, 9, "Panorama 2", UI_func_panorama); LCDML_add(53, LCDML_0_1_2, 9, "Panorama 2", UI_func_panorama);
LCDML_add(54, LCDML_0_1_2, 10, "Polyphony 2", UI_func_polyphony); LCDML_add(54, LCDML_0_1_2, 10, "Polyphony 2", UI_func_polyphony);
LCDML_add(55, LCDML_0_1_2, 11, "Engine 2", UI_func_engine); LCDML_add(55, LCDML_0_1_2, 11, "Engine 2", UI_func_engine);
@ -308,8 +308,8 @@ LCDML_add(5, LCDML_0_1, 5, "Reverb Send", UI_func_reverb_send);
LCDML_add(6, LCDML_0_1, 6, "Chorus Send", UI_func_chorus_send); LCDML_add(6, LCDML_0_1, 6, "Chorus Send", UI_func_chorus_send);
LCDML_add(7, LCDML_0_1, 7, "Delay Send", UI_func_delay_send); LCDML_add(7, LCDML_0_1, 7, "Delay Send", UI_func_delay_send);
LCDML_add(8, LCDML_0_1, 8, "Filter", NULL); LCDML_add(8, LCDML_0_1, 8, "Filter", NULL);
LCDML_add(9, LCDML_0_1_6, 1, "Cutoff", UI_func_filter_cutoff); LCDML_add(9, LCDML_0_1_8, 1, "Cutoff", UI_func_filter_cutoff);
LCDML_add(10, LCDML_0_1_6, 2, "Resonance", UI_func_filter_resonance); LCDML_add(10, LCDML_0_1_8, 2, "Resonance", UI_func_filter_resonance);
LCDML_add(11, LCDML_0_1, 9, "Panorama", UI_func_panorama); LCDML_add(11, LCDML_0_1, 9, "Panorama", UI_func_panorama);
LCDML_add(12, LCDML_0_1, 10, "Polyphony", UI_func_polyphony); LCDML_add(12, LCDML_0_1, 10, "Polyphony", UI_func_polyphony);
LCDML_add(13, LCDML_0_1, 11, "Engine", UI_func_engine); LCDML_add(13, LCDML_0_1, 11, "Engine", UI_func_engine);
@ -2009,7 +2009,7 @@ void UI_func_panorama(uint8_t param)
if (configuration.mono == 0) if (configuration.mono == 0)
{ {
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.dexed[instance_id].pan, 1, false, true, true); lcd_display_int(configuration.dexed[instance_id].pan - 20, 2, false, true, true);
pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); pan[instance_id]->amplitude(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
} }
} }

@ -95,20 +95,18 @@
#else #else
#define AUDIO_MEM 384 #define AUDIO_MEM 384
#endif #endif
#define REDUCE_LOUDNESS 3 #define REDUCE_LOUDNESS 0
#else // IF TEENSY_AUDIO_BOARD #else // IF TEENSY_AUDIO_BOARD
#define SGTL5000_LINEOUT_LEVEL 29 #define SGTL5000_LINEOUT_LEVEL 29
#if AUDIO_BLOCK_SAMPLES == 64 #if AUDIO_BLOCK_SAMPLES == 64
#define AUDIO_MEM 256 #define AUDIO_MEM 512
#else #else
#define AUDIO_MEM 384 #define AUDIO_MEM 384
#endif #endif
#define DELAY_MAX_TIME 600 #define REDUCE_LOUDNESS 0
#define REDUCE_LOUDNESS 3
#endif #endif
#define DELAY_MAX_TIME 600 #define DELAY_MAX_TIME 500
#define SAMPLE_RATE 44100 #define SAMPLE_RATE 44100
#define SOFTEN_VALUE_CHANGE_STEPS 5
//************************************************************************************************* //*************************************************************************************************
//* UI //* UI
@ -231,7 +229,7 @@ enum { DEXED, REVERB, DELAY, CHORUS };
// Teensy-3.6 settings // Teensy-3.6 settings
#define MIDI_DEVICE_USB_HOST 1 #define MIDI_DEVICE_USB_HOST 1
#if defined(USE_REVERB) #if defined(USE_REVERB)
#define MAX_NOTES 12 #define MAX_NOTES 11
#else #else
#define MAX_NOTES 14 #define MAX_NOTES 14
#endif #endif
@ -240,7 +238,7 @@ enum { DEXED, REVERB, DELAY, CHORUS };
#if defined (__MK64FX512__) #if defined (__MK64FX512__)
// Teensy-3.5 settings // Teensy-3.5 settings
#undef MIDI_DEVICE_USB_HOST #undef MIDI_DEVICE_USB_HOST
#define MAX_NOTES 11 #define MAX_NOTES 10
#undef USE_REVERB #undef USE_REVERB
#endif #endif
@ -248,7 +246,7 @@ enum { DEXED, REVERB, DELAY, CHORUS };
// Audio // Audio
#ifdef TGA_AUDIO_BOARD #ifdef TGA_AUDIO_BOARD
#define REDUCE_LOUDNESS 3 #define REDUCE_LOUDNESS 0
#endif #endif
// Some optimizations // Some optimizations

Loading…
Cancel
Save