Patrick1992
Member
Hi, first post so hopefully i'm in the right forum category. Very new to Teensy and having a lot of fun messing around with the Audio System Design tool. I have minimal coding experience so apologies in advance for what might be basic questions. I'm just slowly nudging stuff in a direction i like, and learning new things all the way but i've hit a bit of a wall with this.
I have a basic delay set up, going into a bitcrusher and a biquad bandpass filter. Sounds pretty cool when i adjust the frequency of the BP filter with a pot, so i'm trying to figure out how to have an LFO adjust this frequency instead. Or possibly even have it controlled with an envelope detector triggered by the guitar. But maybe lets start with the LFO, i can't seem to implement one successfully or even really figure out how to hook it up in the GUI.
I also for the life of me can't get the delay time assigned to pot. It works fine when i set the delay time in the setup but it really bugs out when i try to have this value updated by a pot read. Is it trying to read the pot too quickly or something? Sorry this sketch is a bit of a rats nest
Any help would be greatly appreciated!
Thanks
Patrick
I have a basic delay set up, going into a bitcrusher and a biquad bandpass filter. Sounds pretty cool when i adjust the frequency of the BP filter with a pot, so i'm trying to figure out how to have an LFO adjust this frequency instead. Or possibly even have it controlled with an envelope detector triggered by the guitar. But maybe lets start with the LFO, i can't seem to implement one successfully or even really figure out how to hook it up in the GUI.
I also for the life of me can't get the delay time assigned to pot. It works fine when i set the delay time in the setup but it really bugs out when i try to have this value updated by a pot read. Is it trying to read the pot too quickly or something? Sorry this sketch is a bit of a rats nest
Any help would be greatly appreciated!
Thanks
Patrick
Code:
#define LED 3
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=82,344
AudioMixer4 mixer1; //xy=162,96
AudioEffectDelay delay1; //xy=262,221
AudioAmplifier amp1; //xy=277,29
AudioEffectBitcrusher bitcrusher1; //xy=407,28
AudioMixer4 mixer2; //xy=421,313
AudioFilterBiquad biquad1; //xy=554,32
AudioOutputI2S i2s2; //xy=597,95
AudioConnection patchCord1(i2s1, 0, mixer1, 0);
AudioConnection patchCord2(i2s1, 0, mixer2, 1);
AudioConnection patchCord3(i2s1, 0, amp1, 0);
AudioConnection patchCord4(mixer1, delay1);
AudioConnection patchCord5(delay1, 0, mixer1, 2);
AudioConnection patchCord6(delay1, 0, mixer2, 0);
AudioConnection patchCord7(amp1, bitcrusher1);
AudioConnection patchCord8(bitcrusher1, biquad1);
AudioConnection patchCord9(mixer2, 0, i2s2, 0);
AudioConnection patchCord10(biquad1, 0, mixer1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=767,328
// GUItool: end automatically generated code
/*
Bounce footswitch = Bounce(0, 50); // debounce the footswitch
Bounce D1 = Bounce(1, 50); // debounce the toggle switch
Bounce D2 = Bounce(2, 50); // " " " " " " " " "
// this section includes the function to check the toggle position
bool right;
bool middle;
bool left;
void checkToggle () { // this is our function to check toggle position...
D1.update(); D2.update(); // check digital inputs connected to toggle (can delete I think)
if (digitalRead(1) && !digitalRead(2)) {
right = 1; // toggle is right
middle = 0;
left = 0;
}
if (digitalRead(1) && digitalRead(2)) {
right = 0; // toggle is in the middle
middle = 1;
left = 0;
}
if (!digitalRead(1) && digitalRead(2)) {
right = 0; // toggle is left
middle = 0;
left = 1;
}
}
*/
byte bitdepth = 16; // used to set bit depth
int samplerate = 44100; // used to set sample rate
float mix; // clean/delay mix
float mix1; // clean/delay mix
float feedback; // delay feedback
int bandpass; //bandpass cutoff frequency
void setup() {
AudioMemory(400); // the "40" represents how much internal memory (in the Teensy, not the external RAM chip) is allotted for audio recording. It is measured in sample blocks, each providing 2.9ms of audio.
sgtl5000_1.enable(); // this turns on the SGTL5000, which is the audio codec on the audio board
sgtl5000_1.volume(1); // this sets the output volume (it can be between 0 and 1)
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN); // selects the audio input, we always use Line In
analogReadResolution(12); // configure the pots to give 12 bit readings
pinMode(0, INPUT_PULLUP); // internal pull-up resistor for footswitch
pinMode(1, INPUT_PULLUP); // internal pull-up resistor for toggle
pinMode(2, INPUT_PULLUP); // internal pull-up resistor for toggle
pinMode(3, OUTPUT); // pin 3 (the LED) is an output;
Serial.begin(9600); // initiate the serial monitor. USB is always 12 Mbit/sec
sgtl5000_1.audioPostProcessorEnable();
analogReadAveraging(32);
}
void loop() {
//set up delay
delay1.delay (0, 450);
delay1.disable (1);
delay1.disable (2);
delay1.disable (3);
delay1.disable (4);
delay1.disable (5);
delay1.disable (6);
delay1.disable (7);
feedback = (float) analogRead (A2) / 4095; // delay feedback
mix = (float) analogRead (A0) / 2000; // wet/dry mix
Serial.println (mix);
mix1 = 1.0 - mix;
amp1.gain(1);
//Set mixer levels
mixer1.gain (0, mix1); // clean delay in level
mixer1.gain (1, mix); // bitcrush delay in
mixer1.gain (2, feedback);
mixer2.gain (0, 0.5); // set delay out level
mixer2.gain (1, 0.5); // clean out level
// do bitcrushing
bitdepth = (16);
bitcrusher1.bits(bitdepth); // set bit depth
samplerate = (analogRead(A1) << 1) + 1000; // samplerate pot ranges from 1000 to 9190
bitcrusher1.sampleRate(samplerate); // set sample rate
bandpass = (analogRead(A3) << 1) + 1000; // lpf pot ranges from 500 to 8240hz
biquad1.setBandpass (0, bandpass, 2);
biquad1.setBandpass (1, bandpass, 2);
biquad1.setBandpass (2, bandpass, 2);
biquad1.setBandpass (3, bandpass, 2);
}