diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index 8ef0465..04d9ef8 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -34,7 +34,7 @@ #else #include "mdaEPianoData.h" #endif -#if defined(MIDI_DEVICE_USB) +#ifdef MIDI_DEVICE_USB #include #endif #ifdef MIDI_DEVICE_USB_HOST @@ -45,6 +45,9 @@ #include "LiquidCrystalPlus_I2C.h" #include "UI.h" #include // had rename libraries/BALibrary/src/peripherals/BAPhysicalControls.cpp +#include + +using namespace BAEffects; //************************************************************************************************* //* GLOBAL VARIABLES @@ -59,37 +62,33 @@ AudioEffectFreeverb freeverb_r; AudioEffectFreeverb freeverb_l; AudioMixer4 reverb_mixer_r; AudioMixer4 reverb_mixer_l; -AudioEffectDelay delay_r; -AudioEffectDelay delay_l; -AudioMixer4 delay_mixer_r; -AudioMixer4 delay_mixer_l; +AudioEffectSimpleChorus chorus_r(20.0); +AudioEffectSimpleChorus chorus_l(20.0); +//BAEffects::AudioEffectAnalogDelay chorus_r(200.0); +//BAEffects::AudioEffectAnalogDelay chorus_l(200.0); AudioConnection patchCord0(queue_r, peak_r); AudioConnection patchCord1(queue_l, peak_l); -AudioConnection patchCord2(queue_r, delay_r); -AudioConnection patchCord3(queue_l, delay_l); -AudioConnection patchCord4(queue_r, 0, delay_mixer_r, 0); -AudioConnection patchCord5(delay_r, 0, delay_mixer_r, 1); -AudioConnection patchCord6(queue_l, 0, delay_mixer_l, 0); -AudioConnection patchCord7(delay_l, 0, delay_mixer_l, 1); -AudioConnection patchCord8(delay_mixer_r, freeverb_r); -AudioConnection patchCord9(delay_mixer_l, freeverb_l); -AudioConnection patchCord10(delay_mixer_r, 0, reverb_mixer_r, 0); -AudioConnection patchCord11(delay_mixer_l, 0, reverb_mixer_l, 0); -AudioConnection patchCord12(freeverb_r, 0, reverb_mixer_r, 1); -AudioConnection patchCord13(freeverb_l, 0, reverb_mixer_l, 1); +AudioConnection patchCord2(queue_r, chorus_r); +AudioConnection patchCord3(queue_l, chorus_l); +AudioConnection patchCord4(chorus_r, freeverb_r); +AudioConnection patchCord5(chorus_l, freeverb_l); +AudioConnection patchCord6(chorus_r, 0, reverb_mixer_r, 0); +AudioConnection patchCord7(chorus_l, 0, reverb_mixer_l, 0); +AudioConnection patchCord8(freeverb_r, 0, reverb_mixer_r, 1); +AudioConnection patchCord9(freeverb_l, 0, reverb_mixer_l, 1); #ifdef TEENSY_AUDIO_BOARD AudioOutputI2S i2s1; -AudioConnection patchCord14(reverb_mixer_r, 0, i2s1, 0); -AudioConnection patchCord15(reverb_mixer_l, 0, i2s1, 1); +AudioConnection patchCord10(reverb_mixer_r, 0, i2s1, 0); +AudioConnection patchCord11(reverb_mixer_l, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else AudioOutputPT8211 pt8211_1; AudioAmplifier volume_r; AudioAmplifier volume_l; -AudioConnection patchCord14(reverb_mixer_r, volume_r); -AudioConnection patchCord15(reverb_mixer_l, volume_l); -AudioConnection patchCord16(volume_r, 0, pt8211_1, 1); -AudioConnection patchCord17(volume_l, 0, pt8211_1, 0); +AudioConnection patchCord10(reverb_mixer_r, volume_r); +AudioConnection patchCord11(reverb_mixer_l, volume_l); +AudioConnection patchCord12(volume_r, 0, pt8211_1, 1); +AudioConnection patchCord13(volume_l, 0, pt8211_1, 0); #endif // Objects @@ -116,7 +115,7 @@ uint32_t xrun = 0; uint32_t overload = 0; uint32_t peak = 0; uint16_t render_time_max = 0; -float vol = VOLUME; +float vol = _VOLUME; float vol_right = 1.0; float vol_left = 1.0; elapsedMicros fill_audio_buffer; @@ -235,19 +234,22 @@ void setup() freeverb_l.roomsize(0.2); freeverb_r.damping(0.5); freeverb_l.damping(0.5); - reverb_mixer_r.gain(0, 0.7); - reverb_mixer_l.gain(0, 0.7); - reverb_mixer_r.gain(1, 0.3); - reverb_mixer_l.gain(1, 0.3); + reverb_mixer_r.gain(0, 1.0); + reverb_mixer_l.gain(0, 1.0); + reverb_mixer_r.gain(1, 0.0); + reverb_mixer_l.gain(1, 0.0); // Chorus - delay_mixer_r.gain(0, 1.0 - DELAY_VOLUME); - delay_mixer_r.gain(1, DELAY_VOLUME); - delay_mixer_l.gain(0, 1.0 - DELAY_VOLUME); - delay_mixer_l.gain(1, DELAY_VOLUME); - delay_r.delay(0, DELAY_R_MS); - delay_l.delay(0, DELAY_L_MS); - chorus_lfo.setRateAudio(DELAY_FRQ); + chorus_r.enable(); + chorus_r.bypass(false); + chorus_r.frequency(1.0f); + chorus_r.mix(0.5f); + chorus_r.intensity(0.5f); + chorus_l.enable(); + chorus_r.bypass(false); + chorus_l.frequency(1.0f); + chorus_l.mix(0.5f); + chorus_l.intensity(0.5f); Serial.println(F("")); @@ -318,11 +320,6 @@ void loop() } #endif - float c = *chorus_lfo.getNextVector(); - - delay_r.delay(0, DELAY_R_MS / 2 * c * DELAY_R_INTENSITY + DELAY_R_MS / 2); - delay_l.delay(0, DELAY_L_MS / 2 * c * DELAY_R_INTENSITY + DELAY_L_MS / 2); - queue_r.playBuffer(); queue_l.playBuffer(); } diff --git a/config.h b/config.h index db32c8a..8d25770 100644 --- a/config.h +++ b/config.h @@ -59,7 +59,7 @@ //* AUDIO SETTINGS //************************************************************************************************* -#define VOLUME 0.8 +#define _VOLUME 0.8 #define AUDIO_MEM 128 #define SAMPLE_RATE 44100 #define REDUCE_LOUDNESS 1