Hello. I just joined and this is my first post. I bought a Teensy 4.0 and the Audio Shield (Rev D) for an effects pedal box that I am building. Rather than have effects, itself, it is going to be a box that has multiple outputs and corresponding inputs (for effects loops - multiple pedals or chains of pedals) that can be switched independently. It consists of a splitter board and a mixer board. For my output, I have a step-down audio transformer, and I would like to add a USB audio output. I want to keep things super simple, so I don't need to add any digital effects, or do any extra processing. I can pull a line level signal, or a board level signal for the Teensy. I have been looking at the audio examples in the Arduino IDE, and I am wondering if it would be as simple as the documentation shows for the input: the sample circuitry using A2 as the input, and then using something like the following code:
I may (or may not) have a volume pot at the mixer board output, so perhaps I don't need the 50ms level adjustment code? Please let me know if this will work, and what might make it more optimal for my use case. I appreciate any advice that anyone is kind enough to offer. Thank you in advance!
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=617,793
AudioOutputUSB usb1; //xy=925,756
AudioOutputI2S i2s1; //xy=925,836
AudioConnection patchCord1(adc1, 0, usb1, 0);
AudioConnection patchCord2(adc1, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=302,184
// GUItool: end automatically generated code
void setup() {
AudioMemory(12);
// Enable the audio shield and enable output
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
}
elapsedMillis volmsec=0;
void loop() {
// every 50 ms, adjust the volume
if (volmsec > 50) {
float vol = analogRead(15);
vol = vol / 1023.0;
volmsec = 0;
}
}
I may (or may not) have a volume pot at the mixer board output, so perhaps I don't need the 50ms level adjustment code? Please let me know if this will work, and what might make it more optimal for my use case. I appreciate any advice that anyone is kind enough to offer. Thank you in advance!