Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SimultaneousPlay.ino 2.9KB

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