#include #include #include #include #include #include /* SdWav1 : sample voix | * SdWav2 : sample attente |-> mix1 -> Lout & RMS1 * * SdWav3 : sample ambiance -> mix2 -> Rout & RMS2 */ // GUItool: begin automatically generated code AudioPlaySdWav playSdWav3; //xy=152,429 AudioPlaySdWav playSdWav1; //xy=153,217 AudioPlaySdWav playSdWav2; //xy=155,307 AudioMixer4 mixer1; //xy=572,215 AudioMixer4 mixer2; //xy=579,344 AudioAnalyzeRMS rms1; //xy=875,315 AudioOutputI2S i2s1; //xy=876,225 AudioAnalyzeRMS rms2; //xy=876,365 AudioConnection patchCord1(playSdWav3, 0, mixer2, 0); AudioConnection patchCord2(playSdWav1, 0, mixer1, 0); AudioConnection patchCord3(playSdWav2, 0, mixer1, 1); AudioConnection patchCord4(mixer1, 0, i2s1, 0); AudioConnection patchCord5(mixer1, rms1); AudioConnection patchCord6(mixer2, 0, i2s1, 1); AudioConnection patchCord7(mixer2, rms2); AudioControlSGTL5000 sgtl5000_1; //xy=573,537 // 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 // 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 void setup() { Serial.begin(9600); // DmxSimple.maxChannel(4); // DmxSimple.write(4, 250); pinMode(16, INPUT); pinMode(20,INPUT); // Audio connections require memory to work. For more // detailed information, see the MemoryAndCpuUsage example AudioMemory(16); // Comment these out if not using the audio adaptor board. // This may wait forever if the SDA & SCL pins lack // pullup resistors sgtl5000_1.enable(); sgtl5000_1.lineOutLevel(13); // set output to 3.16 Vpp sgtl5000_1.volume(1); //set volume to maximum SPI.setMOSI(SDCARD_MOSI_PIN); SPI.setSCK(SDCARD_SCK_PIN); if (!(SD.begin(SDCARD_CS_PIN))) { // stop here, but print a message repetitively while (1) { Serial.println("Unable to access the SD card"); delay(500); } } delay(2000); } // void playFile(const char *filename) { Serial.print("Playing file: "); Serial.println(filename); // Start playing the file. This sketch continues to // run while the file plays. playSdWav1.play(filename); // A brief delay for the library read WAV info delay(5); // Simply wait for the file to finish playing. while (playSdWav1.isPlaying()) { printLDR(); // uncomment these lines if you audio shield // has the optional volume pot soldered //float vol = analogRead(15); //vol = vol / 1024; // sgtl5000_1.volume(vol); } } void printLDR(){ Serial.print(analogRead(A3)); Serial.print(" "); Serial.print(digitalRead(16)); Serial.print(" "); Serial.print(analogRead(A7)); Serial.print(" "); Serial.print(digitalRead(20)); Serial.println(); } void loop() { delay(100); playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format delay(500); playFile("SDTEST2.WAV"); delay(500); playFile("SDTEST3.WAV"); delay(500); playFile("SDTEST4.WAV"); delay(1500); }