Added an AudioAmplifier after Dexed engine which allows to amplify from

0.0 to 2.0.
pull/32/head
Holger Wirtz 5 years ago
parent 303bb1c5c1
commit 953f4ac3eb
  1. 34
      MicroDexed.ino
  2. 4
      UI.hpp
  3. 2
      config.h
  4. 4
      dexed.cpp

@ -42,6 +42,7 @@
// Audio engines // Audio engines
AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; AudioSourceMicroDexed* MicroDexed[NUM_DEXED];
AudioAmplifier* dexed_level[NUM_DEXED];
AudioEffectMonoStereo* mono2stereo[NUM_DEXED]; AudioEffectMonoStereo* mono2stereo[NUM_DEXED];
AudioAnalyzePeak microdexed_peak; AudioAnalyzePeak microdexed_peak;
AudioMixer4 microdexed_peak_mixer; AudioMixer4 microdexed_peak_mixer;
@ -169,14 +170,15 @@ AudioConnection patchCord34(stereo2mono, 1, dacOut, 1);
// //
uint8_t nDynamic = 0; uint8_t nDynamic = 0;
#if defined(USE_FX) #if defined(USE_FX)
AudioConnection * dynamicConnections[NUM_DEXED * 10]; AudioConnection * dynamicConnections[NUM_DEXED * 11];
#else #else
AudioConnection * dynamicConnections[NUM_DEXED * 4]; AudioConnection * dynamicConnections[NUM_DEXED * 5];
#endif #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, 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, 0, dexed_mixer_r, instance_id);
dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, dexed_mixer_l, instance_id); dynamicConnections[nDynamic++] = new AudioConnection(mono2stereo, 1, dexed_mixer_l, instance_id);
#if defined(USE_FX) #if defined(USE_FX)
@ -284,8 +286,9 @@ void setup()
Serial.print(F("Creating MicroDexed instance ")); Serial.print(F("Creating MicroDexed instance "));
Serial.println(instance_id, DEC); Serial.println(instance_id, DEC);
MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE); MicroDexed[instance_id] = new AudioSourceMicroDexed(SAMPLE_RATE);
dexed_level[instance_id] = new AudioAmplifier();
mono2stereo[instance_id] = new AudioEffectMonoStereo(); 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 else
{ {
@ -464,13 +467,17 @@ void setup()
// 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, 1.0)); 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)); 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 // 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.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]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0);
MicroDexed[instance_id]->doRefreshVoice(); MicroDexed[instance_id]->doRefreshVoice();
#endif
// Dexed output level
dexed_level[instance_id]->gain(1.0);
// PANORAMA // PANORAMA
mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); 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")); Serial.println(F("VOLUME CC"));
#endif #endif
configuration.dexed[instance_id].sound_intensity = map(inValue, 0, 0x7f, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); 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); 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(); eeprom_write();
break; break;
case 10: // Pan 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 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_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); reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0);
#endif // MicroDexed[instance_id]->fx.Gain = configuration.dexed[instance_id].sound_intensity / 100.0;
MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); MicroDexed[instance_id]->fx.Gain = 1.0;
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.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]->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!")); Serial.println(F("OK, loaded!"));

@ -84,6 +84,7 @@ extern AudioAmplifier volume_r;
extern AudioAmplifier volume_l; extern AudioAmplifier volume_l;
extern AudioEffectStereoMono stereo2mono; extern AudioEffectStereoMono stereo2mono;
extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED]; extern AudioSourceMicroDexed* MicroDexed[NUM_DEXED];
extern AudioAmplifier* dexed_level[NUM_DEXED];
extern AudioEffectMonoStereo* mono2stereo[NUM_DEXED]; extern AudioEffectMonoStereo* mono2stereo[NUM_DEXED];
extern AudioSynthWaveformDc* pan[NUM_DEXED]; extern AudioSynthWaveformDc* pan[NUM_DEXED];
extern uint8_t selected_dexed_instance; 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); lcd_display_bar_int("Sound Intens.", configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, false);

@ -387,7 +387,7 @@ enum { DEXED, CHORUS, DELAY, REVERB};
#define TUNE_DEFAULT 100 #define TUNE_DEFAULT 100
#define SOUND_INTENSITY_MIN 0 #define SOUND_INTENSITY_MIN 0
#define SOUND_INTENSITY_MAX 100 #define SOUND_INTENSITY_MAX 200
#define SOUND_INTENSITY_DEFAULT 100 #define SOUND_INTENSITY_DEFAULT 100
#define POLYPHONY_MIN 1 #define POLYPHONY_MIN 1

@ -178,8 +178,8 @@ void Dexed::getSamples(uint16_t n_samples, int16_t* buffer)
#ifdef USE_FX #ifdef USE_FX
fx.process(sumbuf, n_samples); fx.process(sumbuf, n_samples);
#else // #else
arm_scale_f32(sumbuf, fx.getGain(), sumbuf, n_samples); // arm_scale_f32(sumbuf, fx.getGain(), sumbuf, n_samples);
#endif #endif
//#ifdef USE_TEENSY_DSP //#ifdef USE_TEENSY_DSP

Loading…
Cancel
Save