Several small fixes for audio chain.

pull/32/head
Holger Wirtz 5 years ago
parent ff48558d29
commit 4ea0ced615
  1. 199
      MicroDexed.ino
  2. 10
      UI.hpp
  3. 11
      effect_mono_stereo.cpp

@ -53,56 +53,62 @@ AudioAmplifier modchorus_inverter;
// FX chain left // FX chain left
AudioMixer4 delay_send_mixer_l; AudioMixer4 delay_send_mixer_l;
AudioMixer4 delay_mixer_l;
AudioMixer4 delay_fb_mixer_l; AudioMixer4 delay_fb_mixer_l;
AudioEffectDelay delay_l; AudioEffectDelay delay_l;
AudioConnection patchCord1(delay_send_mixer_l, 0, delay_fb_mixer_l, 0); AudioConnection patchCord1(delay_send_mixer_l, 0, delay_fb_mixer_l, 0);
AudioConnection patchCord2(delay_fb_mixer_l, delay_l); AudioConnection patchCord2(delay_fb_mixer_l, delay_l);
AudioConnection patchCord3(delay_l, 0, delay_fb_mixer_l, 1); // feedback-loop AudioConnection patchCord3(delay_l, 0, delay_fb_mixer_l, 1); // feedback-loop
AudioConnection patchCord4(delay_fb_mixer_l, 0, master_mixer_l, DELAY); AudioConnection patchCord4(delay_l, 0, delay_mixer_l, 0);
AudioConnection patchCord5(delay_fb_mixer_l, 0, delay_mixer_l, 1);
AudioConnection patchCord6(delay_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_send_mixer_l, modchorus_l); AudioConnection patchCord7(chorus_send_mixer_l, 0, modchorus_l, 0);
AudioConnection patchCord6(chorus_modulator, 0, modchorus_l, 1); AudioConnection patchCord8(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 patchCord7(modchorus_l, modchorus_filter_l); AudioConnection patchCord9(modchorus_l, modchorus_filter_l);
AudioConnection patchCord8(modchorus_filter_l, modchorus_inverter); AudioConnection patchCord10(modchorus_filter_l, modchorus_inverter);
AudioConnection patchCord9(modchorus_inverter_l, 0, master_mixer_l, CHORUS ); AudioConnection patchCord11(modchorus_inverter_l, 0, master_mixer_l, CHORUS);
#else #else
AudioConnection patchCord7(modchorus_l, modchorus_inverter); AudioConnection patchCord9(modchorus_l, modchorus_inverter);
AudioConnection patchCord8(modchorus_inverter, 0, master_mixer_l, CHORUS); AudioConnection patchCord10(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 patchCord10(reverb_send_mixer_l, freeverb_l); AudioConnection patchCord12(reverb_send_mixer_l, freeverb_l);
AudioConnection patchCord11(freeverb_l, 0, master_mixer_r, REVERB); AudioConnection patchCord13(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_mixer_r;
AudioMixer4 delay_fb_mixer_r; AudioMixer4 delay_fb_mixer_r;
AudioEffectDelay delay_r; AudioEffectDelay delay_r;
AudioConnection patchCord12(delay_send_mixer_r, 0, delay_fb_mixer_r, 0); AudioConnection patchCord14(delay_send_mixer_r, 0, delay_fb_mixer_r, 0);
AudioConnection patchCord13(delay_fb_mixer_r, delay_r); AudioConnection patchCord15(delay_fb_mixer_r, delay_r);
AudioConnection patchCord14(delay_r, 0, delay_fb_mixer_r, 1); // feedback-loop AudioConnection patchCord16(delay_r, 0, delay_fb_mixer_r, 1); // feedback-loop
AudioConnection patchCord15(delay_fb_mixer_r, 0, master_mixer_r, DELAY); AudioConnection patchCord17(delay_r, 0, delay_mixer_r, 0);
AudioConnection patchCord18(delay_fb_mixer_r, 0, delay_mixer_r, 1);
AudioConnection patchCord19(delay_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); AudioConnection patchCord20(chorus_send_mixer_r, modchorus_r);
AudioEffectModulatedDelay modchorus_r; AudioEffectModulatedDelay modchorus_r;
AudioConnection patchCord17(chorus_modulator, 0, modchorus_r, 1); AudioConnection patchCord21(chorus_modulator, 0, modchorus_r, 1);
#if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT #if MOD_FILTER_OUTPUT != MOD_NO_FILTER_OUTPUT
AudioFilterBiquad modchorus_filter_r; AudioFilterBiquad modchorus_filter_r;
AudioConnection patchCord18(modchorus_r, modchorus_filter_r); AudioConnection patchCord22(modchorus_r, modchorus_filter_r);
AudioConnection patchCord19(modchorus_filter_r, 0, master_mixer_r, CHORUS ); AudioConnection patchCord23(modchorus_filter_r, 0, master_mixer_r, CHORUS);
#else #else
AudioConnection patchCord18(modchorus_r, 0, master_mixer_r, CHORUS); AudioConnection patchCord22(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 patchCord20(reverb_send_mixer_r, freeverb_r); AudioConnection patchCord24(reverb_send_mixer_r, freeverb_r);
AudioConnection patchCord21(freeverb_r, 0, master_mixer_r, REVERB); AudioConnection patchCord25(freeverb_r, 0, master_mixer_r, REVERB);
#endif #endif
// FX chain tail // FX chain tail
@ -115,50 +121,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 patchCord22(dexed_mixer_r, 0, master_mixer_r, DEXED); AudioConnection patchCord26(dexed_mixer_r, 0, master_mixer_r, DEXED);
AudioConnection patchCord23(dexed_mixer_l, 0, master_mixer_l, DEXED); AudioConnection patchCord27(dexed_mixer_l, 0, master_mixer_l, DEXED);
AudioConnection patchCord24(master_mixer_r, volume_r); AudioConnection patchCord28(master_mixer_r, volume_r);
AudioConnection patchCord25(master_mixer_l, volume_l); AudioConnection patchCord29(master_mixer_l, volume_l);
AudioConnection patchCord26(volume_r, 0, stereo2mono, 0); AudioConnection patchCord30(volume_r, 0, stereo2mono, 0);
AudioConnection patchCord27(volume_l, 0, stereo2mono, 1); AudioConnection patchCord31(volume_l, 0, stereo2mono, 1);
AudioConnection patchCord28(volume_r, master_peak_r); AudioConnection patchCord32(volume_r, master_peak_r);
AudioConnection patchCord29(volume_l, master_peak_l); AudioConnection patchCord33(volume_l, master_peak_l);
AudioConnection patchCord30(microdexed_peak_mixer, microdexed_peak); AudioConnection patchCord34(microdexed_peak_mixer, microdexed_peak);
// Outputs // Outputs
#ifdef AUDIO_DEVICE_USB #ifdef AUDIO_DEVICE_USB
AudioOutputUSB usb1; AudioOutputUSB usb1;
AudioConnection patchCord31(stereo2mono, 0, usb1, 0); AudioConnection patchCord35(stereo2mono, 0, usb1, 0);
AudioConnection patchCord32(stereo2mono, 1, usb1, 1); AudioConnection patchCord36(stereo2mono, 1, usb1, 1);
#endif #endif
#if defined(TEENSY_AUDIO_BOARD) #if defined(TEENSY_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord33(stereo2mono, 0, i2s1, 0); AudioConnection patchCord37(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord34(stereo2mono, 1, i2s1, 1); AudioConnection patchCord38(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 patchCord33(stereo2mono, 0, i2s1, 0); AudioConnection patchCord37(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord34(stereo2mono, 1, i2s1, 1); AudioConnection patchCord38(stereo2mono, 1, i2s1, 1);
#elif defined(TGA_AUDIO_BOARD) #elif defined(TGA_AUDIO_BOARD)
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord33(stereo2mono, 0, i2s1, 0); AudioConnection patchCord37(stereo2mono, 0, i2s1, 0);
AudioConnection patchCord34(stereo2mono, 1, i2s1, 1); AudioConnection patchCord38(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 patchCord33(stereo2mono, 0, pt8211_1, 0); AudioConnection patchCord37(stereo2mono, 0, pt8211_1, 0);
AudioConnection patchCord34(stereo2mono, 1, pt8211_1, 1); AudioConnection patchCord38(stereo2mono, 1, pt8211_1, 1);
#elif defined(TEENSY_DAC_SYMMETRIC) #elif defined(TEENSY_DAC_SYMMETRIC)
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioMixer4 invMixer; AudioMixer4 invMixer;
AudioConnection patchCord33(stereo2mono, 0, dacOut , 0); AudioConnection patchCord37(stereo2mono, 0, dacOut , 0);
AudioConnection patchCord34(stereo2mono, 1, invMixer, 0); AudioConnection patchCord38(stereo2mono, 1, invMixer, 0);
AudioConnection patchCord35(invMixer, 0, dacOut , 1); AudioConnection patchCord39(invMixer, 0, dacOut , 1);
#else #else
AudioOutputAnalogStereo dacOut; AudioOutputAnalogStereo dacOut;
AudioConnection patchCord33(stereo2mono, 0, dacOut, 0); AudioConnection patchCord37(stereo2mono, 0, dacOut, 0);
AudioConnection patchCord34(stereo2mono, 1, dacOut, 1); AudioConnection patchCord38(stereo2mono, 1, dacOut, 1);
#endif #endif
// //
@ -172,18 +178,26 @@ AudioConnection * dynamicConnections[NUM_DEXED * 9];
#endif #endif
void create_audio_connections(AudioSourceMicroDexed &dexed, AudioEffectMonoStereo &mono2stereo, AudioSynthWaveformDc &pan, uint8_t instance_id) void create_audio_connections(AudioSourceMicroDexed &dexed, AudioEffectMonoStereo &mono2stereo, AudioSynthWaveformDc &pan, uint8_t instance_id)
{ {
Serial.print(F("Connecting Dexed "));
Serial.print(instance_id, DEC);
Serial.println(F(" -> "));
dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, microdexed_peak_mixer, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, microdexed_peak_mixer, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, mono2stereo, 0); dynamicConnections[nDynamic++] = new AudioConnection(dexed, 0, mono2stereo, 0);
dynamicConnections[nDynamic++] = new AudioConnection(pan, 0, mono2stereo, 1); dynamicConnections[nDynamic++] = new AudioConnection(pan, 0, mono2stereo, 1);
Serial.println(F(" Peakmeter"));
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, dexed_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, dexed_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, dexed_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, dexed_mixer_l, instance_id);
Serial.println(F(" Dexed mixer"));
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, chorus_send_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, chorus_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, chorus_send_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, chorus_send_mixer_l, instance_id);
Serial.println(F(" Chorus send"));
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, delay_send_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, delay_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, delay_send_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, delay_send_mixer_l, instance_id);
Serial.println(F(" Delay send"));
#if defined(USE_REVERB) #if defined(USE_REVERB)
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, reverb_send_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, reverb_send_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, reverb_send_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, reverb_send_mixer_l, instance_id);
Serial.println(F(" Reverb send"));
#endif #endif
} }
@ -275,12 +289,11 @@ void setup()
if (instance_id < MAX_DEXED) if (instance_id < MAX_DEXED)
{ {
Serial.print(F("Creating MicroDexed instance ")); Serial.print(F("Creating MicroDexed instance "));
Serial.print(instance_id, DEC); Serial.println(instance_id, DEC);
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE);
mono2stereo[instance_id] = new AudioEffectMonoStereo(); mono2stereo[instance_id] = new AudioEffectMonoStereo();
pan[instance_id] = new AudioSynthWaveformDc(); pan[instance_id] = new AudioSynthWaveformDc();
create_audio_connections(*MicroDexed[instance_id], *mono2stereo[instance_id], *pan[instance_id], instance_id); create_audio_connections(*MicroDexed[instance_id], *mono2stereo[instance_id], *pan[instance_id], instance_id);
Serial.println(F("... created"));
} }
else else
{ {
@ -426,7 +439,16 @@ void setup()
Serial.println(F(" samples")); Serial.println(F(" samples"));
#endif #endif
set_master_mixer_gain(DEXED, 1.0); master_mixer_r.gain(DEXED, 1.0);
master_mixer_l.gain(DEXED, 1.0);
master_mixer_r.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
#if defined(USE_REVERB)
master_mixer_r.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
#endif
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
@ -462,15 +484,19 @@ void setup()
} }
// DELAY // DELAY
set_master_mixer_gain(DELAY, configuration.delay_level / 100.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
delay_fb_mixer_r.gain(0, 1.0); // original signal delay_fb_mixer_r.gain(0, 1.0); // original signal
delay_fb_mixer_r.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
delay_fb_mixer_l.gain(0, 1.0); // original signal
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
delay_mixer_r.gain(0, 1.0);
delay_mixer_l.gain(0, 1.0);
delay_mixer_r.gain(1, 1.0);
delay_mixer_l.gain(1, 1.0);
// CHORUS // CHORUS
set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0);
switch (configuration.chorus_waveform) switch (configuration.chorus_waveform)
{ {
case 0: case 0:
@ -504,7 +530,6 @@ void setup()
#if defined(USE_REVERB) #if defined(USE_REVERB)
// 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.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_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.roomsize(mapfloat(configuration.reverb_roomsize, REVERB_ROOMSIZE_MIN, REVERB_ROOMSIZE_MAX, 0.0, 1.0));
@ -555,39 +580,6 @@ void setup()
void loop() void loop()
{ {
#ifdef OLD
int16_t* audio_buffer; // pointer to AUDIO_BLOCK_SAMPLES * int16_t
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
#endif
//while (42 == 42)
//{
#ifdef OLD
// Main sound calculation
if (queue1.available() && fill_audio_buffer > audio_block_time_us - 10)
{
fill_audio_buffer = 0;
audio_buffer = queue1.getBuffer();
elapsedMicros t1;
for (uint8_t i = 0; i < NUM_DEXED; i++)
{
MicroDexed[i]->getSamples(AUDIO_BLOCK_SAMPLES, audio_buffer);
}
if (t1 > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++;
if (t1 > render_time_max)
render_time_max = t1;
if (peak1.available())
{
if (peak1.read() > 0.99)
peak++;
}
queue1.playBuffer();
}
#endif
// MIDI input handling // MIDI input handling
check_midi_devices(); check_midi_devices();
@ -779,15 +771,16 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue)
eeprom_write(); eeprom_write();
case 106: // CC 106: delay feedback case 106: // CC 106: delay feedback
configuration.delay_feedback = map(inValue, 0, 0x7f, DELAY_FEEDBACK_MIN , DELAY_FEEDBACK_MAX); configuration.delay_feedback = map(inValue, 0, 0x7f, DELAY_FEEDBACK_MIN , DELAY_FEEDBACK_MAX);
delay_fb_mixer_r.gain(1, configuration.delay_feedback / 200.0 ); // amount of feedback //delay_fb_mixer_r.gain(0, 1.0); // original signal
delay_fb_mixer_r.gain(0, 1.0 - configuration.delay_feedback / 200.0); // original signalbreak; delay_fb_mixer_r.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, configuration.delay_feedback / 200.0 ); // amount of feedback //delay_fb_mixer_l.gain(0, 1.0); // original signal
delay_fb_mixer_l.gain(0, 1.0 - configuration.delay_feedback / 200.0); // original signalbreak; delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
eeprom_write(); eeprom_write();
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);
set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
eeprom_write(); eeprom_write();
break; break;
case 120: case 120:
@ -1293,8 +1286,10 @@ void initial_values_from_eeprom(bool init)
chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 200.0); 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); 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_fb_mixer_r.gain(0, 1.0); // original signal
delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0); delay_fb_mixer_r.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
delay_fb_mixer_l.gain(0, 1.0); // original signal
delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback
#if defined(USE_REVERB) #if defined(USE_REVERB)
reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0); 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); reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0);
@ -1309,12 +1304,16 @@ void initial_values_from_eeprom(bool init)
} }
Serial.println(F("OK, loaded!")); Serial.println(F("OK, loaded!"));
set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0); master_mixer_r.gain(DEXED, 1.0);
set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); master_mixer_l.gain(DEXED, 1.0);
master_mixer_r.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
#if defined(USE_REVERB) #if defined(USE_REVERB)
set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0); master_mixer_r.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
#endif #endif
set_master_mixer_gain(DEXED, 1.0);
set_volume(configuration.vol, configuration.mono); set_volume(configuration.vol, configuration.mono);
} }
@ -1469,6 +1468,7 @@ uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https:/
return (crc); return (crc);
} }
/*
void set_master_mixer_gain(uint8_t type, float level) void set_master_mixer_gain(uint8_t type, float level)
{ {
master_mixer_level[type] = constrain(level, 0.0, 1.0); master_mixer_level[type] = constrain(level, 0.0, 1.0);
@ -1520,6 +1520,7 @@ void set_master_mixer_gain(uint8_t type, float level)
Serial.println(); Serial.println();
#endif #endif
} }
*/
/****************************************************************************** /******************************************************************************
DEBUG HELPER DEBUG HELPER

@ -57,7 +57,6 @@ extern void strip_extension(char* s, char *target);
extern void eeprom_write(void); extern void eeprom_write(void);
extern bool get_voice_names_from_bank(uint8_t b, uint8_t instance_id); extern bool get_voice_names_from_bank(uint8_t b, uint8_t instance_id);
extern bool load_sysex(uint8_t b, uint8_t v); extern bool load_sysex(uint8_t b, uint8_t v);
extern void set_master_mixer_gain(uint8_t type, float level);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
extern void change_disp_sd(bool d); extern void change_disp_sd(bool d);
#endif #endif
@ -1161,7 +1160,8 @@ void UI_func_reverb_level(uint8_t param)
} }
} }
set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0); master_mixer_r.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0));
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1429,7 +1429,8 @@ void UI_func_chorus_level(uint8_t param)
} }
} }
set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0); master_mixer_r.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0));
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -1636,7 +1637,8 @@ void UI_func_delay_level(uint8_t param)
} }
} }
set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0));
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);

@ -60,12 +60,11 @@ void AudioEffectMonoStereo::update(void)
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)
{ {
*op[0] = int16_t(f_l * (*ip));
*op[0]++ = int16_t(f_l * (*ip)); *op[1] = int16_t(f_r * (*ip));
*op[1]++ = int16_t(f_r * (*ip++)); op[0]++;
//op[0]++; op[1]++;
//op[1]++; ip++;
//mod++;
} }
if (in) if (in)

Loading…
Cancel
Save