Hello, Trying to get an effect to work (flanger) based on sample code. I generate a tone out on Pin 33. It is turned on/off through a button. The square wave then gets fed back in to the i2s input. I had it simply route to the i2s output, and it worked just fine. Now I added a flange effect
into the signal chain ( code below ), and no output. Any thoughts on what I am doing wrong?
Thanks!
Leor
into the signal chain ( code below ), and no output. Any thoughts on what I am doing wrong?
Thanks!
Leor
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioInputI2S i2s1; //xy=200,69
AudioOutputI2S i2s2; //xy=365,94
AudioControlSGTL5000 sgtl5000_1; //xy=302,184
AudioEffectFlange l_myEffect;
AudioEffectFlange r_myEffect;
AudioConnection c1(i2s1, 0, l_myEffect, 0);
AudioConnection c2(i2s1, 1, r_myEffect, 0);
AudioConnection c3(l_myEffect, 0, i2s2, 0);
AudioConnection c4(r_myEffect, 0, i2s2, 1);
#define FLANGE_DELAY_LENGTH (6*AUDIO_BLOCK_SAMPLES)
// Allocate the delay lines for left and right channels
short l_delayline[FLANGE_DELAY_LENGTH];
short r_delayline[FLANGE_DELAY_LENGTH];
const int myInput = AUDIO_INPUT_LINEIN;
int s_idx = FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = .5;
void setup() {
AudioMemory(12);
sgtl5000_1.enable();
sgtl5000_1.inputSelect(myInput);
sgtl5000_1.volume(0.3);
pinMode(34, INPUT_PULLDOWN);
l_myEffect.begin(l_delayline,FLANGE_DELAY_LENGTH,s_idx,s_depth,s_freq);
r_myEffect.begin(r_delayline,FLANGE_DELAY_LENGTH,s_idx,s_depth,s_freq);
}
void loop() {
int pressed = digitalRead(34);
if (pressed == HIGH ) {
tone(33,300,10);
}
l_myEffect.voices(s_idx,s_depth,s_freq);
r_myEffect.voices(s_idx,s_depth,s_freq);
}