Hello everybody,
this is my first post in this forum.
I've been reading a lot of posts here and always found a solution in the past.
But now I can't find an answer so this is my start here
I just bought a teensy and an audio shield because I heard about the audio library and I thought I might use it for my projects.
I'm building a delay right now with pots to control the delay time, feedback and lowpass filtering.
It works but I have a problem and I don't know if there's a good solution for that.
Everytime I change the delay time, the delayed signal gets distorted. The dry signal stays clean and as soon as I stop altering the delay time, there's no distortion anymore.
Is there any way to avoid this distortion? I plan to control the delay time via control voltages from my synths later so it would be pretty annoying then.
Here's my code so far:
I'd appreciate any help!
Cheers
Malte
this is my first post in this forum.
I've been reading a lot of posts here and always found a solution in the past.
But now I can't find an answer so this is my start here
I just bought a teensy and an audio shield because I heard about the audio library and I thought I might use it for my projects.
I'm building a delay right now with pots to control the delay time, feedback and lowpass filtering.
It works but I have a problem and I don't know if there's a good solution for that.
Everytime I change the delay time, the delayed signal gets distorted. The dry signal stays clean and as soon as I stop altering the delay time, there's no distortion anymore.
Is there any way to avoid this distortion? I plan to control the delay time via control voltages from my synths later so it would be pretty annoying then.
Here's my code so far:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s2; //xy=72.85720825195312,227.14288330078125
AudioMixer4 mixer2; //xy=220,437.1428527832031
AudioEffectDelay delay1; //xy=377.142822265625,470.0000915527344
AudioMixer4 mixer1; //xy=545.7142944335938,438.571533203125
AudioFilterStateVariable filter1; //xy=665.7142944335938,299.9999694824219
AudioMixer4 mixer3; //xy=805.7142333984375,157.1428680419922
AudioOutputI2S i2s1; //xy=992.857177734375,180
AudioConnection patchCord1(i2s2, 0, mixer2, 0);
AudioConnection patchCord2(i2s2, 0, mixer3, 0);
AudioConnection patchCord3(mixer2, delay1);
AudioConnection patchCord4(delay1, 0, mixer1, 0);
AudioConnection patchCord5(mixer1, 0, filter1, 0);
AudioConnection patchCord6(filter1, 0, mixer3, 1);
AudioConnection patchCord7(filter1, 0, mixer2, 1);
AudioConnection patchCord8(mixer3, 0, i2s1, 0);
AudioConnection patchCord9(mixer3, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=457.1428571428571,628.5714285714286
// GUItool: end automatically generated code
float deltime = 200;
const int numReadings = 100;
int readings[numReadings];
int readIndex = 0;
float total = 0;
void setup() {
Serial.begin(9600);
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.8);
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
mixer1.gain(0, 0.8);
mixer2.gain(0, 1);
mixer2.gain(1, 0.2);
mixer3.gain(0, 1);
mixer3.gain(1, 0.8);
delay1.delay(0, deltime);
filter1.frequency(1000);
filter1.resonance(0.7);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
int knob1 = analogRead(A2);
int knob2 = analogRead(A3) / 3 + 5;
int knob3 = analogRead(A6);
//Feedback
float feedback = (float)knob1 / 800;
mixer2.gain(1, feedback);
//Serial.println(feedback);
//Delay Time
total = total - readings[readIndex];
readings[readIndex] = knob2;
total = total + readings[readIndex];
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
deltime = total / numReadings;
delay1.delay(0, deltime);
Serial.println(deltime);
delay(1);
//Filter
float cutoff = pow((float)knob3/10.24, 2);
filter1.frequency(cutoff);
//Serial.println(cutoff);
//float cutlog = pow(cutoff/10.24, 2);
//Serial.println(cutlog);
// delay(100);
}
I'd appreciate any help!
Cheers
Malte