Hello everyone, I am trying to develop a flanger effect pedal for electric guitar using the Teensy 3.6 board with audio shield. The idea is that the guitar input goes into the Line in of the audio shield and comes out through the mini jack output of the audio shield. Between the guitar and the audio shield I have added a simple preamp with an operational amplifier, in non inverting configuration and with a gain of 10. But when I connect the guitar or a tone with the function generator nothing comes out of the output. I have checked with the oscilloscope that indeed the preamplified signal reaches the input of the audio shield, so I think the fault may be in the teensyduino code, I share here the code in case someone could help me to see something I'm not seeing.
Thanks in advance.
I´m using three potentiometers and one button, potentiometers control volumen, depth and frecuency and the button activates flange effect.
The code is a modification of Gadget Reboot's code which shares on his youtube channel and github page a code to apply flanger effect to wav songs put in the teensy from a SD card.
Thanks in advance.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>
// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=428,291
AudioEffectFlange flange; //xy=625,292
AudioMixer4 mixer1; //xy=752,174
AudioOutputI2S audioOutput; //xy=929,262
AudioConnection patchCord1(adc1, 0, mixer1, 0);
AudioConnection patchCord2(adc1, flange);
AudioConnection patchCord3(flange, 0, mixer1, 1);
AudioConnection patchCord4(mixer1, 0, audioOutput, 0);
AudioControlSGTL5000 audioShield;
// GUItool: end automatically generated code
// buttons and potentiometers
#define pot0 A13
#define pot1 A12
#define pot2 A20
#define button0 29
// attach button debouncers to input buttons
Bounce db_button0 = Bounce(button0, 30);
// choose mic or line input for audio shield input path
const int inputChSelect = 0;
// audio shield volume
int masterVolume = 0.7;
// Flange Effect parameters
#define FLANGE_DELAY_LENGTH (6*AUDIO_BLOCK_SAMPLES) // number of samples in each delay line
short l_delayline[FLANGE_DELAY_LENGTH]; // allocate delay lines for left and right channels
short r_delayline[FLANGE_DELAY_LENGTH];
int s_idx = FLANGE_DELAY_LENGTH / 4;
int s_depth = FLANGE_DELAY_LENGTH / 4;
double s_freq = 3;
bool flangeActive = false; // track if flange effect is on or off
void setup() {
Serial.begin(9600);
// buttons are inputs with pullups
pinMode(button0, INPUT_PULLUP);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(8);
// Comment these out if not using the audio adaptor board.
Serial.print("init audio shield...");
audioShield.enable();
audioShield.inputSelect(inputChSelect); // select mic or line-in for audio shield input source
audioShield.volume(0.8);
Serial.println("done.");
audioShield.lineOutLevel(20);
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);
mixer1.gain(2, 0);
mixer1.gain(3, 0);
Serial.println("done.");
Serial.print("init Flange effect...");
// Set up the flange effect:
// address of delayline
// total number of samples in the delay line
// Index (in samples) into the delay line for the added voice
// Depth of the flange effect
// frequency of the flange effect
flange.begin(l_delayline, FLANGE_DELAY_LENGTH, s_idx, s_depth, s_freq);
// Initially the effect is off.
flange.voices(FLANGE_DELAY_PASSTHRU, 0, 0);
Serial.println("done.");
Serial.println("Waiting for control input...");
// reset audio resource usage stats.
// useful if tracking max usage in main program
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
}
void loop() {
// update the button debounce status so falling edges
// can be detected and processed
db_button0.update();
// button 0 pressed - toggle Flange effect
//if (db_button0.fallingEdge()) {
// if (flangeActive) {
// flange.voices(FLANGE_DELAY_PASSTHRU, 0, 0);
// Serial.println("Flange OFF\n");
// }
//else {
// flange.voices(s_idx, s_depth, s_freq);
// Serial.println("Flange ON");
//}
//flangeActive = !flangeActive;
// }
if (db_button0.fallingEdge()) {
flangeActive = !flangeActive;
if (flangeActive) {
flange.voices(s_idx, s_depth, s_freq);
Serial.println("Flanger ON");
} else {
flange.voices(FLANGE_DELAY_PASSTHRU, 0, 0);
Serial.println("Flanger OFF");
}
}
// read volume control pot and set audio shield volume if required
int vol = analogRead(pot0);
if (vol != masterVolume) {
masterVolume = vol;
audioShield.volume((float)vol / 1023); // audio shield headphone out volume (optional)
mixer1.gain(0, (float)vol / 1023); // software mixer input channel volume
mixer1.gain(1, (float)vol / 1023);
Serial.print("Volume: ");
Serial.println(vol);
}
// read Flange control pot and change parameter if required
if (flangeActive) {
int reading1 = map(analogRead(pot1), 0, 1023, 1, 10);
if ((reading1 / 10.0) != s_freq) {
s_freq = reading1 / 10.0;
Serial.print("New flange freq: ");
Serial.println(s_freq);
flange.voices(s_idx, s_depth, s_freq);
}
int reading2 = map(analogRead(pot2), 0, 1023, 1, 10);
if ((reading2 / 1) != s_depth) {
s_depth = reading2 / 1;
Serial.print("New flange depth: ");
Serial.println(s_depth);
flange.voices(s_idx, s_depth, s_freq);
}
}
}
I´m using three potentiometers and one button, potentiometers control volumen, depth and frecuency and the button activates flange effect.
The code is a modification of Gadget Reboot's code which shares on his youtube channel and github page a code to apply flanger effect to wav songs put in the teensy from a SD card.