Works but with a clicking sound in the background.

chorus2
Holger Wirtz 6 years ago
parent dd2faa4797
commit 4a1ed44e75
  1. 43
      MicroMDAEPiano.ino
  2. 35
      mod-delay.cpp
  3. 12
      mod-delay.h

@ -28,7 +28,7 @@
#include <MIDI.h> #include <MIDI.h>
#include <EEPROM.h> #include <EEPROM.h>
#include <limits.h> #include <limits.h>
#include "mod-delay-gain.h" #include "mod-delay.h"
#include "mdaEPiano.h" #include "mdaEPiano.h"
#ifdef USE_XFADE_DATA #ifdef USE_XFADE_DATA
#include "mdaEPianoDataXfade.h" #include "mdaEPianoDataXfade.h"
@ -46,7 +46,6 @@
#include "LiquidCrystalPlus_I2C.h" #include "LiquidCrystalPlus_I2C.h"
#include "UI.h" #include "UI.h"
//************************************************************************************************* //*************************************************************************************************
//* GLOBAL VARIABLES //* GLOBAL VARIABLES
//************************************************************************************************* //*************************************************************************************************
@ -61,11 +60,9 @@ AudioEffectFreeverb freeverb_l;
AudioMixer4 mixer_r; AudioMixer4 mixer_r;
AudioMixer4 mixer_l; AudioMixer4 mixer_l;
AudioSynthWaveform delaySweep_r; AudioSynthWaveform delaySweep_r;
AudioSynthWaveform envelope_r;
AudioSynthWaveform delaySweep_l; AudioSynthWaveform delaySweep_l;
AudioSynthWaveform envelope_l; AudioEffectModDelay modulatedDelay_r;
AudioEffectModDelayGain modulatedDelay_r; AudioEffectModDelay modulatedDelay_l;
AudioEffectModDelayGain modulatedDelay_l;
AudioConnection patchCord0(queue_r, peak_r); AudioConnection patchCord0(queue_r, peak_r);
AudioConnection patchCord1(queue_l, peak_l); AudioConnection patchCord1(queue_l, peak_l);
AudioConnection patchCord4(queue_r, freeverb_r); AudioConnection patchCord4(queue_r, freeverb_r);
@ -80,8 +77,6 @@ AudioConnection patchCord12(modulatedDelay_r, 0, mixer_r, 2);
AudioConnection patchCord13(modulatedDelay_l, 0, mixer_l, 2); AudioConnection patchCord13(modulatedDelay_l, 0, mixer_l, 2);
AudioConnection patchCord14(delaySweep_r, 0, modulatedDelay_r, 1); AudioConnection patchCord14(delaySweep_r, 0, modulatedDelay_r, 1);
AudioConnection patchCord15(delaySweep_l, 0, modulatedDelay_l, 1); AudioConnection patchCord15(delaySweep_l, 0, modulatedDelay_l, 1);
AudioConnection patchCord16(envelope_r, 0, modulatedDelay_r, 2);
AudioConnection patchCord17(envelope_l, 0, modulatedDelay_l, 2);
#ifdef TEENSY_AUDIO_BOARD #ifdef TEENSY_AUDIO_BOARD
AudioOutputI2S i2s1; AudioOutputI2S i2s1;
AudioConnection patchCord18(mixer_r, 0, i2s1, 0); AudioConnection patchCord18(mixer_r, 0, i2s1, 0);
@ -97,10 +92,6 @@ AudioConnection patchCord20(volume_r, 0, pt8211_1, 1);
AudioConnection patchCord21(volume_l, 0, pt8211_1, 0); AudioConnection patchCord21(volume_l, 0, pt8211_1, 0);
#endif #endif
const int32_t delayBufferLength = 4500;
int16_t delayBuf1[delayBufferLength];
int16_t delayBuf2[delayBufferLength];
// Objects // Objects
mdaEPiano* ep; mdaEPiano* ep;
@ -132,10 +123,13 @@ const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLE
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
elapsedMillis cpu_mem_millis; elapsedMillis cpu_mem_millis;
#endif #endif
float modFreq = 2.0;
enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE }; const int32_t delayBufferLength = 1000;
int16_t delayBuf_r[delayBufferLength];
int16_t delayBuf_l[delayBufferLength];
float modFreq = 0.7;
enum MDA_EP_PARAM { DECAY, RELEASE, HARDNESS, TREBLE, PAN_TREM, LFO_RATE, VELOCITY_SENSE, STEREO, MAX_POLY, TUNE, DETUNE, OVERDRIVE };
//************************************************************************************************* //*************************************************************************************************
//* SETUP FUNCTION //* SETUP FUNCTION
@ -246,17 +240,16 @@ void setup()
freeverb_r.damping(0.5); freeverb_r.damping(0.5);
freeverb_l.damping(0.5); freeverb_l.damping(0.5);
delaySweep_r.begin(1, modFreq, WAVEFORM_SINE); modulatedDelay_r.setbuf(delayBufferLength, delayBuf_r);
delaySweep_l.begin(1, modFreq, WAVEFORM_SINE); modulatedDelay_l.setbuf(delayBufferLength, delayBuf_l);
delaySweep_l.phase(180.0); delaySweep_r.begin(0.1, modFreq, WAVEFORM_SINE);
envelope_r.begin(1, modFreq, WAVEFORM_SINE); delaySweep_l.begin(0.1, modFreq, WAVEFORM_SINE);
envelope_l.begin(1, modFreq, WAVEFORM_SINE); //delaySweep_l.phase(180.0);
envelope_l.phase(180.0);
mixer_r.gain(0, 0.5);
mixer_r.gain(0, 0.7); mixer_l.gain(0, 0.5);
mixer_l.gain(0, 0.7); mixer_r.gain(1, 0.2);
mixer_r.gain(1, 0.3); mixer_l.gain(1, 0.2);
mixer_l.gain(1, 0.3);
mixer_r.gain(2, 0.5); mixer_r.gain(2, 0.5);
mixer_l.gain(2, 0.5); mixer_l.gain(2, 0.5);

@ -36,18 +36,16 @@
*/ */
#include "mod-delay.h"
#include "mod-delay-gain.h"
#define INTERPOLATE (1) #define INTERPOLATE (1)
void AudioEffectModDelayGain::update(void) void AudioEffectModDelay::update(void)
{ {
audio_block_t *audioblock, *controlblockDelay, *controlblockGain; audio_block_t *audioblock, *controlblockDelay;
int16_t *data, *end, *ctrlDelay, *ctrlGain; int16_t *data, *end, *ctrlDelay;
int32_t extract_index; int32_t extract_index;
int32_t temp;
#ifdef INTERPOLATE #ifdef INTERPOLATE
int32_t interp_delta; int32_t interp_delta;
@ -67,20 +65,11 @@ void AudioEffectModDelayGain::update(void)
return; return;
} }
controlblockGain = receiveReadOnly(2);
if (!controlblockGain) {
release(audioblock);
release(controlblockDelay);
return;
}
data = audioblock->data; data = audioblock->data;
end = audioblock->data + AUDIO_BLOCK_SAMPLES; end = audioblock->data + AUDIO_BLOCK_SAMPLES;
ctrlDelay = controlblockDelay->data; ctrlDelay = controlblockDelay->data;
ctrlGain = controlblockGain->data;
do do
{ {
delayline_p[insert_index] = *data; delayline_p[insert_index] = *data;
@ -91,9 +80,8 @@ void AudioEffectModDelayGain::update(void)
} }
#ifdef INTERPOLATE #ifdef INTERPOLATE
//
interp_delta = (buffer_length * (*ctrlDelay)); interp_delta = (buffer_length * (*ctrlDelay));
delay_delta = interp_delta >> 15; // MSB's for delay len delay_delta = (interp_delta >> 15); // MSB's for delay len
interp_delta &= 0x7fff; //LSBs for interp distance interp_delta &= 0x7fff; //LSBs for interp distance
#else #else
delay_delta = (buffer_length * (*ctrlDelay)) >> 15; delay_delta = (buffer_length * (*ctrlDelay)) >> 15;
@ -115,27 +103,18 @@ void AudioEffectModDelayGain::update(void)
} }
calc = delayline_p[next] - delayline_p[extract_index]; calc = delayline_p[next] - delayline_p[extract_index];
calc = (calc * interp_delta ) >> 15; calc = (calc * interp_delta ) >> 15;
calc += delayline_p[extract_index]; calc += delayline_p[extract_index];
//*data = calc; *data = calc;
temp = (int32_t)calc * (*ctrlGain);
*data = temp >> 15;
#else #else
//data = delayline_p[extract_index]; *data = delayline_p[extract_index];
temp = (int32_t)delayline_p[extract_index] * (*ctrlGain);
*data = temp >> 15;
#endif #endif
data++; data++;
ctrlDelay++; ctrlDelay++;
ctrlGain++;
} while (data < end); } while (data < end);
transmit(audioblock); transmit(audioblock);
release(audioblock); release(audioblock);
release(controlblockDelay); release(controlblockDelay);
release(controlblockGain);
} }

@ -43,14 +43,13 @@
#ifndef _mod_delay_h_ #ifndef _mod_delay_h_
#define _mod_delay_h_ #define _mod_delay_h_
#include "AudioStream.h" #include "AudioStream.h"
#include <Arduino.h> #include <Arduino.h>
class AudioEffectModDelayGain: public AudioStream class AudioEffectModDelay: public AudioStream
{ {
public: public:
AudioEffectModDelayGain (void) : AudioStream(3, inputQueueArray) AudioEffectModDelay (void) : AudioStream(2, inputQueueArray)
{ {
buffer_length = 0; buffer_length = 0;
} }
@ -64,10 +63,7 @@ class AudioEffectModDelayGain: public AudioStream
insert_index = 0; insert_index = 0;
buffer_length = delay_len; buffer_length = delay_len;
for (int32_t i = 0; i < buffer_length; i++) memset(delayline_p, 0, buffer_length);
{
delayline_p[i] = 0;
}
}; };
void inspect(void) void inspect(void)
@ -81,7 +77,7 @@ class AudioEffectModDelayGain: public AudioStream
}; };
private: private:
audio_block_t *inputQueueArray[3]; audio_block_t *inputQueueArray[2];
int16_t *delayline_p; int16_t *delayline_p;
Loading…
Cancel
Save