Testing with two modulators (triangle and sine) added together.

master
Holger Wirtz 5 years ago
parent 8833124c4f
commit 7efc9854c1
  1. 60
      MicroMDAEPiano.ino
  2. 13
      UI.hpp
  3. 3
      config.h
  4. 20
      effect_modulated_delay.cpp

@ -56,8 +56,9 @@ AudioAmplifier volume_l;
AudioAmplifier inverter;
AudioEffectModulatedDelay modchorus_r;
AudioEffectModulatedDelay modchorus_l;
AudioSynthWaveform modulator;
//AudioFilterStateVariable modulator_filter;
AudioSynthWaveform modulator1;
AudioSynthWaveform modulator2;
AudioMixer4 modulator_mixer;
AudioFilterStateVariable chorus_filter_r;
AudioFilterStateVariable chorus_filter_l;
AudioConnection patchCord0(queue_r, peak_r);
@ -66,30 +67,29 @@ AudioConnection patchCord2(queue_r, freeverb_r);
AudioConnection patchCord3(queue_l, freeverb_l);
AudioConnection patchCord4(queue_r, 0, modchorus_r, 0);
AudioConnection patchCord5(queue_l, 0, modchorus_l, 0);
//AudioConnection patchCord6(modulator, 0, modulator_filter, 1);
//AudioConnection patchCord7(modulator_filter, 0, modchorus_r, 1);
//AudioConnection patchCord8(modulator_filter, 0, inverter, 0);
AudioConnection patchCord6(modulator, 0, modchorus_r, 1);
AudioConnection patchCord7(modulator, 0, inverter, 0);
AudioConnection patchCord9(inverter, 0, modchorus_l, 1);
AudioConnection patchCord10(queue_r, 0, mixer_r, 0);
AudioConnection patchCord11(queue_l, 0, mixer_l, 0);
AudioConnection patchCord12(modchorus_r, chorus_filter_r);
AudioConnection patchCord13(modchorus_l, chorus_filter_l);
AudioConnection patchCord14(chorus_filter_r, 0, mixer_r, 2);
AudioConnection patchCord15(chorus_filter_l, 0, mixer_l, 2);
AudioConnection patchCord16(freeverb_r, 0, mixer_r, 1);
AudioConnection patchCord17(freeverb_l, 0, mixer_l, 1);
AudioConnection patchCord18(mixer_r, volume_r);
AudioConnection patchCord19(mixer_l, volume_l);
AudioConnection patchCord6(modulator1, 0, modulator_mixer, 0);
AudioConnection patchCord7(modulator2, 0, modulator_mixer, 1);
AudioConnection patchCord8(modulator_mixer, 0, modchorus_r, 1);
AudioConnection patchCord9(modulator_mixer, inverter);
AudioConnection patchCord10(inverter, 0, modchorus_l, 1);
AudioConnection patchCord11(queue_r, 0, mixer_r, 0);
AudioConnection patchCord12(queue_l, 0, mixer_l, 0);
AudioConnection patchCord13(modchorus_r, chorus_filter_r);
AudioConnection patchCord14(modchorus_l, chorus_filter_l);
AudioConnection patchCord15(chorus_filter_r, 0, mixer_r, 2);
AudioConnection patchCord16(chorus_filter_l, 0, mixer_l, 2);
AudioConnection patchCord17(freeverb_r, 0, mixer_r, 1);
AudioConnection patchCord18(freeverb_l, 0, mixer_l, 1);
AudioConnection patchCord19(mixer_r, volume_r);
AudioConnection patchCord20(mixer_l, volume_l);
#ifdef USB_AUDIO
AudioOutputUSB usb1;
AudioConnection patchCord22(volume_r, 0, usb1, 0);
AudioConnection patchCord23(volume_l, 0, usb1, 1);
AudioConnection patchCord21(volume_r, 0, usb1, 0);
AudioConnection patchCord22(volume_l, 0, usb1, 1);
#endif
AudioOutputI2S i2s1;
AudioConnection patchCord24(volume_r, 0, i2s1, 0);
AudioConnection patchCord25(volume_l, 0, i2s1, 1);
AudioConnection patchCord23(volume_r, 0, i2s1, 0);
AudioConnection patchCord24(volume_l, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1;
// Objects
@ -237,11 +237,17 @@ void setup()
}
// chorus modulation fixed
modulator.begin(CHORUS_WAVEFORM);
modulator.phase(0);
modulator.amplitude(1.0);
modulator.offset(0.0);
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
modulator1.begin(CHORUS_WAVEFORM_MOD1);
modulator1.phase(0);
modulator1.amplitude(1.0);
modulator1.offset(0.0);
modulator2.begin(CHORUS_WAVEFORM_MOD2);
modulator2.phase(0);
modulator2.amplitude(1.0);
modulator2.offset(0.0);
modulator_mixer.gain(0, 0.5);
modulator_mixer.gain(1, 0.5);
inverter.gain(1.0); // change phase for second modulated delay (faked stereo mode)
//modulator_filter.frequency(15000);
//modulator_filter.resonance(0.7);
//modulator_filter.octaveControl(1);

@ -121,7 +121,8 @@ extern void eeprom_config_write(uint8_t value);
extern AudioControlSGTL5000 sgtl5000_1;
extern AudioEffectFreeverb freeverb_r;
extern AudioEffectFreeverb freeverb_l;
extern AudioSynthWaveform modulator;
extern AudioSynthWaveform modulator1;
extern AudioSynthWaveform modulator2;
extern AudioEffectModulatedDelay modchorus_r;
extern AudioEffectModulatedDelay modchorus_l;
extern AudioMixer4 mixer_r;
@ -2037,7 +2038,8 @@ void set_chorus_frequency(uint8_t value)
Serial.print(F("Set CHORUS_FREQUENCY "));
Serial.println(value);
#endif
modulator.frequency(float(value) / 10);
modulator1.frequency(float(value) / 10);
modulator2.frequency(float(value) / 10);
configuration.chorus_frequency = value;
}
@ -2057,7 +2059,8 @@ void set_chorus_intensity(uint8_t value)
Serial.print(F("Set CHORUS_INTENSITY "));
Serial.println(value);
#endif
modulator.amplitude(mapfloat(float(value), ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX, 0.0, 1.0));
modulator1.amplitude(mapfloat(float(value), ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX, 0.0, 1.0));
modulator2.amplitude(mapfloat(float(value), ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX, 0.0, 1.0));
configuration.chorus_intensity = value;
}
@ -2068,8 +2071,8 @@ void set_chorus_level(uint8_t value)
Serial.println(value);
#endif
float tmp = mapfloat(float(value), ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX, 0.0, 0.5);
mixer_r.gain(0, 1.0-tmp);
mixer_l.gain(0, 1.0-tmp);
mixer_r.gain(0, 1.0 - tmp);
mixer_l.gain(0, 1.0 - tmp);
mixer_r.gain(2, tmp);
mixer_l.gain(2, tmp);
configuration.chorus_level = value;

@ -56,7 +56,8 @@
#define USE_XFADE_DATA 1
// CHORUS parameters
#define CHORUS_DELAY_LENGTH_SAMPLES (15*AUDIO_BLOCK_SAMPLES) // one AUDIO_BLOCK_SAMPLES = 2.902ms
#define CHORUS_WAVEFORM WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define CHORUS_WAVEFORM_MOD1 WAVEFORM_SINE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
#define CHORUS_WAVEFORM_MOD2 WAVEFORM_TRIANGLE // WAVEFORM_SINE WAVEFORM_TRIANGLE WAVEFORM_SAWTOOTH WAVEFORM_SAWTOOTH_REVERSE
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS
//*************************************************************************************************

@ -72,7 +72,7 @@ void AudioEffectModulatedDelay::set_modulator_filter_coeffs(float gain, float fc
// coefficients calculated with "IOWA Hills IIR Filter Designer 6.5", http://www.iowahills.com/8DownloadPage.html
// Example: https://web.fhnw.ch/technik/projekte/eit/Fruehling2016/MuelZum/html/parametric_equalizer_example_8c-example.html
float32_t A = sqrt(powf(10, gain / 20.0f));
/* float32_t A = sqrt(powf(10, gain / 20.0f));
float32_t w0 = 2.0f * PI * fc / ((float32_t)AUDIO_SAMPLE_RATE_EXACT);
float32_t cosw0 = cosf(w0);
float32_t sinw0 = sinf(w0);
@ -83,14 +83,14 @@ void AudioEffectModulatedDelay::set_modulator_filter_coeffs(float gain, float fc
modulator_filter_coeffs[1] = (-2.0f * cosw0) / a0; // b1
modulator_filter_coeffs[2] = (1.0f - alpha * A) / a0; // b2
modulator_filter_coeffs[3] = -(2.0f * cosw0) / -a0; // -a1
modulator_filter_coeffs[4] = (1.0f - alpha / A) / -a0; // -a2
// OmegaC = 0.5, SR = 44117.64706, Fc = 11 kHz, N=2
/* modulator_filter_coeffs[0] = 0.291938819295525787; // b0
modulator_filter_coeffs[1] = 0.582700575839973478; // b1
modulator_filter_coeffs[2] = 0.291938819295525787; // b2
modulator_filter_coeffs[3] = 0.005242268129729576; // -a1
modulator_filter_coeffs[4] = -0.171820482560754689; // -a2 */
modulator_filter_coeffs[4] = (1.0f - alpha / A) / -a0; // -a2 */
// OmegaC = 0.1, SR = 44117.64706, Fc = 2.21 kHz, N=2
modulator_filter_coeffs[0] = 0.020727217357494492; // b0
modulator_filter_coeffs[1] = 0.020727217357494492; // b1
modulator_filter_coeffs[2] = 0.020727217357494492; // b2
modulator_filter_coeffs[3] = 1.563046149664217620; // -a1
modulator_filter_coeffs[4] = -0.642749223719756180; // -a2
}
void AudioEffectModulatedDelay::update(void)
@ -115,7 +115,7 @@ void AudioEffectModulatedDelay::update(void)
bp = block->data;
arm_q15_to_float(modulation->data, modulation_f32, AUDIO_BLOCK_SAMPLES);
arm_biquad_cascade_df1_f32(&modulator_filter_data, modulation_f32, modulation_f32, AUDIO_BLOCK_SAMPLES);
//arm_biquad_cascade_df1_f32(&modulator_filter_data, modulation_f32, modulation_f32, AUDIO_BLOCK_SAMPLES);
mp = modulation_f32;
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++)

Loading…
Cancel
Save