Hi guys
I am working on an audio project that needs to pan between two audios. I used Teesy4.0 with RevD2 shield and I adopted code from the teensy audio library tutorial Part_2_02 mixer, but it does not work. There is no sound coming out. I tested the hardware, and that's not the problem. The code is literally the same code they used in the tutorial.
The Serial Monitor only prints:
so I guess playSdWav1.play has some problem and blocked the execution of the following code. so "Start playing 2" was never printed.
I tested with the SD_Card lib and it succeeded in reading the files in the SD. so the problem is not the SD Card.
I also tried the WavFilePlayer. Succeeded in playing the TEST song. so it's not the shield or hardware problem.
Please advise.
I am working on an audio project that needs to pan between two audios. I used Teesy4.0 with RevD2 shield and I adopted code from the teensy audio library tutorial Part_2_02 mixer, but it does not work. There is no sound coming out. I tested the hardware, and that's not the problem. The code is literally the same code they used in the tutorial.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=140,266
AudioPlaySdWav playSdWav2; //xy=140,322
AudioMixer4 mixer2; //xy=331,336
AudioMixer4 mixer1; //xy=333,269
AudioOutputI2S i2s1; //xy=550,316
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav1, 1, mixer2, 0);
AudioConnection patchCord3(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord4(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord5(mixer2, 0, i2s1, 1);
AudioConnection patchCord6(mixer1, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=337,407
// GUItool: end automatically generated code
// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
pinMode(13, OUTPUT); // LED on pin 13
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);
mixer2.gain(0, 0.5);
mixer2.gain(1, 0.5);
delay(1000);
}
void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing 1");
playSdWav1.play("SDTEST1.WAV");
delay(10); // wait for library to parse WAV info
}
if (playSdWav2.isPlaying() == false) {
Serial.println("Start playing 2");
playSdWav2.play("SDTEST4.WAV");
delay(10); // wait for library to parse WAV info
}
// uncomment this code to allow Knob A3 to pan between songs
int knob = analogRead(A3); // knob = 0 to 1023
float gain1 = (float)knob / 1023.0;
float gain2 = 1.0 - gain1;
mixer1.gain(0, gain1);
mixer1.gain(1, gain2);
mixer2.gain(0, gain1);
mixer2.gain(1, gain2);
}
The Serial Monitor only prints:
Code:
"Start playing 1"
so I guess playSdWav1.play has some problem and blocked the execution of the following code. so "Start playing 2" was never printed.
I tested with the SD_Card lib and it succeeded in reading the files in the SD. so the problem is not the SD Card.
I also tried the WavFilePlayer. Succeeded in playing the TEST song. so it's not the shield or hardware problem.
Please advise.