derplecbob
Active member
Hi
I have a teensy 3.2 soldered onto the prop shield with an 8omh 1.5 watt speaker soldered off the speaker end of the prop shield.
I'm trying to find the minimum amount of code I need to play a few wav files. That way I can add it into other code.
I'm not very good at coding and I'm new to playing audio so I apologize for the messy code
I got this first Code to play a tone so I know its working but the second code I tried to use to play a WAV file but its not working and I don't know why
Second code
I have a teensy 3.2 soldered onto the prop shield with an 8omh 1.5 watt speaker soldered off the speaker end of the prop shield.
I'm trying to find the minimum amount of code I need to play a few wav files. That way I can add it into other code.
I'm not very good at coding and I'm new to playing audio so I apologize for the messy code
I got this first Code to play a tone so I know its working but the second code I tried to use to play a WAV file but its not working and I don't know why
Code:
#include <Audio.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=180,469
//AudioSynthWaveformSineHires sine1;
AudioOutputAnalog dac1; //xy=380,468
AudioConnection patchCord1(sine1, dac1);
// GUItool: end automatically generated code
int freq = 1100;
void setup() {
Serial.begin(9600);
//dac1.analogReference(EXTERNAL); // louder, default is 1.2v INTERNAL
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);//Enable Amplifier
AudioMemory(12);
sine1.amplitude(1.0);
sine1.frequency(1000);
}
void loop()
{
if (Serial.available()) {
Serial.read();
sine1.frequency(freq);
Serial.println(freq);
freq += 100;
}
}
Second code
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playSdWav1;
AudioOutputAnalog dac1;
AudioConnection patchCord1(playSdWav1, 0, dac1, 0);
AudioConnection patchCord2(playSdWav1, 0, dac1, 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(5, OUTPUT); // sound
digitalWrite(5, HIGH); // turn on the amplifier
delay(10); // allow time to wake up
Serial.begin(115200);
AudioMemory(10);
delay(1000);
}
void loop() {
playSdWav1.play("SDTEST2.WAV");
delay(1000); // wait for library to parse WAV info
}