您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SimultaneousPlay.ino 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <Audio.h>
  2. #include <SD.h>
  3. // Reducing this delay will attempt to play the files simultaneously.
  4. // The clips are about 3.0 to 3.4 seconds, even though the voice is
  5. // heard only for the about the first half second.
  6. const int milliseconds = 3500;
  7. // GUItool: begin automatically generated code
  8. AudioPlaySdWav playSdWav4; //xy=259,267
  9. AudioPlaySdWav playSdWav3; //xy=260,218
  10. AudioPlaySdWav playSdWav5; //xy=260,317
  11. AudioPlaySdWav playSdWav6; //xy=261,369
  12. AudioPlaySdWav playSdWav2; //xy=262,169
  13. AudioPlaySdWav playSdWav1; //xy=263,118
  14. AudioMixer4 mixer1; //xy=460,176
  15. AudioMixer4 mixer2; //xy=571,271
  16. AudioOutputI2S i2s1; //xy=763,245
  17. AudioConnection patchCord1(playSdWav4, 0, mixer1, 3);
  18. AudioConnection patchCord2(playSdWav3, 0, mixer1, 2);
  19. AudioConnection patchCord3(playSdWav5, 0, mixer2, 1);
  20. AudioConnection patchCord4(playSdWav6, 0, mixer2, 2);
  21. AudioConnection patchCord5(playSdWav2, 0, mixer1, 1);
  22. AudioConnection patchCord6(playSdWav1, 0, mixer1, 0);
  23. AudioConnection patchCord7(mixer1, 0, mixer2, 0);
  24. AudioConnection patchCord8(mixer2, 0, i2s1, 0);
  25. AudioConnection patchCord9(mixer2, 0, i2s1, 1);
  26. AudioControlSGTL5000 sgtl5000_1; //xy=625,368
  27. // GUItool: end automatically generated code
  28. // Use these with the Teensy 3.x Audio Shield (Rev C)
  29. #define SDCARD_CS_PIN 10
  30. #define SDCARD_MOSI_PIN 7
  31. #define SDCARD_SCK_PIN 14
  32. // Use these with the Teensy 3.5 & 3.6 SD card
  33. //#define SDCARD_CS_PIN BUILTIN_SDCARD
  34. //#define SDCARD_MOSI_PIN 11 // not actually used
  35. //#define SDCARD_SCK_PIN 13 // not actually used
  36. void setup() {
  37. AudioMemory(40);
  38. sgtl5000_1.enable();
  39. sgtl5000_1.volume(0.6);
  40. mixer1.gain(0, 0.167);
  41. mixer1.gain(1, 0.167);
  42. mixer1.gain(2, 0.167);
  43. mixer1.gain(3, 0.167);
  44. mixer2.gain(0, 1.0);
  45. mixer2.gain(1, 0.167);
  46. mixer2.gain(2, 0.167);
  47. SPI.setMOSI(SDCARD_MOSI_PIN);
  48. SPI.setSCK(SDCARD_SCK_PIN);
  49. if (!(SD.begin(SDCARD_CS_PIN))) {
  50. // stop here if no SD card, but print a message repetitively
  51. while (1) {
  52. Serial.println("Unable to access the SD card");
  53. delay(500);
  54. }
  55. }
  56. }
  57. AudioPlaySdWav * const playerlist[6] = {
  58. &playSdWav1, &playSdWav2, &playSdWav3, &playSdWav4, &playSdWav5, &playSdWav6
  59. };
  60. void playNumber(int n)
  61. {
  62. String filename = String("NUM") + n + ".WAV";
  63. Serial.print("Playing File: ");
  64. Serial.println(filename);
  65. Serial.flush();
  66. playerlist[n]->play(filename.c_str());
  67. }
  68. void loop() {
  69. for (int i=1; i <= 6; i++) {
  70. playNumber(i);
  71. delay(milliseconds);
  72. }
  73. }