diff --git a/MicroDexed.ino b/MicroDexed.ino index 3525630..b38df95 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -42,6 +42,7 @@ // Audio engines AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; +AudioAmplifier* dexed_level[NUM_DEXED]; AudioEffectMonoStereo* mono2stereo[NUM_DEXED]; AudioAnalyzePeak microdexed_peak; AudioMixer4 microdexed_peak_mixer; @@ -169,14 +170,15 @@ AudioConnection patchCord34(stereo2mono, 1, dacOut, 1); // uint8_t nDynamic = 0; #if defined(USE_FX) -AudioConnection * dynamicConnections[NUM_DEXED * 10]; +AudioConnection * dynamicConnections[NUM_DEXED * 11]; #else -AudioConnection * dynamicConnections[NUM_DEXED * 4]; +AudioConnection * dynamicConnections[NUM_DEXED * 5]; #endif -void create_audio_connections(AudioSourceMicroDexed &dexed, AudioEffectMonoStereo &mono2stereo, uint8_t instance_id) +void create_audio_connections(AudioSourceMicroDexed &dexed, AudioEffectMonoStereo &mono2stereo, AudioAmplifier &dexed_level, uint8_t 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, dexed_level, 0); + dynamicConnections[nDynamic++] = new AudioConnection(dexed_level, 0, mono2stereo, 0); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 0, dexed_mixer_r, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, dexed_mixer_l, instance_id); #if defined(USE_FX) @@ -284,8 +286,9 @@ void setup() Serial.print(F("Creating MicroDexed instance ")); Serial.println(instance_id, DEC); MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); + dexed_level[instance_id] = new AudioAmplifier(); mono2stereo[instance_id] = new AudioEffectMonoStereo(); - create_audio_connections(*MicroDexed[instance_id], *mono2stereo[instance_id], instance_id); + create_audio_connections(*MicroDexed[instance_id], *mono2stereo[instance_id], *dexed_level[instance_id], instance_id); } else { @@ -464,13 +467,17 @@ void setup() // INIT CHORUS 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, 1.0)); -#endif // 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); + MicroDexed[instance_id]->fx.Gain = 1.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); MicroDexed[instance_id]->doRefreshVoice(); +#endif + + // Dexed output level + dexed_level[instance_id]->gain(1.0); // PANORAMA mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); @@ -727,7 +734,11 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) Serial.println(F("VOLUME CC")); #endif configuration.dexed[instance_id].sound_intensity = map(inValue, 0, 0x7f, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); +#ifdef USE_FX MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 1.0); +#else + dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 2.0)); +#endif eeprom_write(); break; case 10: // Pan @@ -1304,12 +1315,13 @@ void initial_values_from_eeprom(bool init) delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.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.Gain = configuration.dexed[instance_id].sound_intensity / 100.0; + MicroDexed[instance_id]->fx.Gain = 1.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); +#endif + MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); + dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 2.0)); } } Serial.println(F("OK, loaded!")); diff --git a/UI.hpp b/UI.hpp index d01ba7c..d1cb696 100644 --- a/UI.hpp +++ b/UI.hpp @@ -84,6 +84,7 @@ extern AudioAmplifier volume_r; extern AudioAmplifier volume_l; extern AudioEffectStereoMono stereo2mono; extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; +extern AudioAmplifier* dexed_level[NUM_DEXED]; extern AudioEffectMonoStereo* mono2stereo[NUM_DEXED]; extern AudioSynthWaveformDc* pan[NUM_DEXED]; extern uint8_t selected_dexed_instance; @@ -1711,7 +1712,8 @@ void UI_func_sound_intensity(uint8_t param) } } - MicroDexed[instance_id]->fx.Gain = configuration.dexed[instance_id].sound_intensity / 100.0; + //MicroDexed[instance_id]->fx.Gain = configuration.dexed[instance_id].sound_intensity / 100.0; + dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, 2.0)); } lcd_display_bar_int("Sound Intens.", configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, false); diff --git a/config.h b/config.h index 8138304..6f85b4b 100644 --- a/config.h +++ b/config.h @@ -387,7 +387,7 @@ enum { DEXED, CHORUS, DELAY, REVERB}; #define TUNE_DEFAULT 100 #define SOUND_INTENSITY_MIN 0 -#define SOUND_INTENSITY_MAX 100 +#define SOUND_INTENSITY_MAX 200 #define SOUND_INTENSITY_DEFAULT 100 #define POLYPHONY_MIN 1 diff --git a/dexed.cpp b/dexed.cpp index 4c50a0b..ef560e2 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -178,8 +178,8 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer) #ifdef USE_FX fx.process(sumbuf, n_samples); -#else - arm_scale_f32(sumbuf, fx.getGain(), sumbuf, n_samples); +// #else +// arm_scale_f32(sumbuf, fx.getGain(), sumbuf, n_samples); #endif //#ifdef USE_TEENSY_DSP