snowskijunky
Active member
Hello! I'm working on a model train sound board and need to get it playing multiple wav files at once. Right now, I'm just trying to play the test files and not having much luck despite looking through much of the tutorial material. First off, here is the code I am using as of right now:
Here are a few pictures of my physical setup. The DAC on the prop shield is connected to DA0 on the teensy 3.6... as far as I can tell from the reading I've done, this should be the correct connection for audio output. I've tried two different speakers that I have... one a VECO 8 ohm 2 watt speaker, another a really tiny VECO 4 ohm 3 watt speaker. Both seem to make a faint popping noise when the program runs.
https://www.dropbox.com/s/iapezwmkwwdh55v/20170803_124337.jpg?dl=0
https://www.dropbox.com/s/se8xbfe5euvoxa7/20170803_124419.jpg?dl=0
https://www.dropbox.com/s/12avz99luzrkmgy/20170803_124438.jpg?dl=0
I've also tested the read/write and cardinfo for the sd card, with success:
https://www.dropbox.com/s/h7673rxy3u7su8s/sdtest.JPG?dl=0
Any assistance with this would be much appreciated... I might just need a second set of eyes, I've been working with this thing for two days now, its possible I'm hoping I've just overlooked something silly.
Code:
// Advanced Microcontroller-based Audio Workshop
//
// http://www.pjrc.com/store/audio_tutorial_kit.html
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
//
// Part 1-3: First "Hello World" program, play a music file
//
// WAV files for this and other Tutorials are here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playSdWav1;
//AudioMixer4 mixer1;
AudioOutputAnalog dac1;
AudioConnection myConnection(playSdWav1, 0, dac1, 0);
//AudioConnection patchCord2(playSdWav1, 1, dac1, 1);
//AudioConnection patchCord2(mixer1, dac1);
//AudioControlSGTL5000 sgtl5000_1;
// Use these with the Teensy Audio Shield
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
// Use these with the Teensy 3.5 & 3.6 SD card
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN 4
//#define SDCARD_MOSI_PIN 11
//#define SDCARD_SCK_PIN 13
void setup() {
pinMode(13, OUTPUT);
AudioMemory(20);
dac1.analogReference(EXTERNAL); // much louder!
delay(50); // time for DAC voltage stable
pinMode(5, OUTPUT);
digitalWrite(5, HIGH); // turn on the amplifier
delay(10); // allow time to wake up
Serial.begin(9600);
//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);
}
}
delay(1000);
digitalWrite(13, HIGH);
delay(2000);
}
void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("SDTEST1.WAV");
delay(10); // wait for library to parse WAV info
digitalWrite(13, LOW);
}
// do nothing while playing...
}
Here are a few pictures of my physical setup. The DAC on the prop shield is connected to DA0 on the teensy 3.6... as far as I can tell from the reading I've done, this should be the correct connection for audio output. I've tried two different speakers that I have... one a VECO 8 ohm 2 watt speaker, another a really tiny VECO 4 ohm 3 watt speaker. Both seem to make a faint popping noise when the program runs.
https://www.dropbox.com/s/iapezwmkwwdh55v/20170803_124337.jpg?dl=0
https://www.dropbox.com/s/se8xbfe5euvoxa7/20170803_124419.jpg?dl=0
https://www.dropbox.com/s/12avz99luzrkmgy/20170803_124438.jpg?dl=0
I've also tested the read/write and cardinfo for the sd card, with success:
https://www.dropbox.com/s/h7673rxy3u7su8s/sdtest.JPG?dl=0
Any assistance with this would be much appreciated... I might just need a second set of eyes, I've been working with this thing for two days now, its possible I'm hoping I've just overlooked something silly.