You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Simple WAV file player example
  2. //
  3. // Three types of output may be used, by configuring the code below.
  4. //
  5. // 1: Digital I2S - Normally used with the audio shield:
  6. // http://www.pjrc.com/store/teensy3_audio.html
  7. //
  8. // 2: Digital S/PDIF - Connect pin 22 to a S/PDIF transmitter
  9. // https://www.oshpark.com/shared_projects/KcDBKHta
  10. //
  11. // 3: Analog DAC - Connect the DAC pin to an amplified speaker
  12. // http://www.pjrc.com/teensy/gui/?info=AudioOutputAnalog
  13. //
  14. // To configure the output type, first uncomment one of the three
  15. // output objects. If not using the audio shield, comment out
  16. // the sgtl5000_1 lines in setup(), so it does not wait forever
  17. // trying to configure the SGTL5000 codec chip.
  18. //
  19. // The SD card may connect to different pins, depending on the
  20. // hardware you are using. Uncomment or configure the SD card
  21. // pins to match your hardware.
  22. //
  23. // Data files to put on your SD card can be downloaded here:
  24. // http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
  25. //
  26. // This example code is in the public domain.
  27. #include <Audio.h>
  28. #include <Wire.h>
  29. #include <SPI.h>
  30. #include <SD.h>
  31. #include <SerialFlash.h>
  32. AudioPlaySdWav playWav1;
  33. // Use one of these 3 output types: Digital I2S, Digital S/PDIF, or Analog DAC
  34. AudioOutputI2S audioOutput;
  35. //AudioOutputSPDIF audioOutput;
  36. //AudioOutputAnalog audioOutput;
  37. AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
  38. AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
  39. AudioControlSGTL5000 sgtl5000_1;
  40. // Use these with the audio adaptor board
  41. #define SDCARD_CS_PIN 10
  42. #define SDCARD_MOSI_PIN 7
  43. #define SDCARD_SCK_PIN 14
  44. // Use these for the SD+Wiz820 or other adaptors
  45. //#define SDCARD_CS_PIN 4
  46. //#define SDCARD_MOSI_PIN 11
  47. //#define SDCARD_SCK_PIN 13
  48. void setup() {
  49. Serial.begin(9600);
  50. // Audio connections require memory to work. For more
  51. // detailed information, see the MemoryAndCpuUsage example
  52. AudioMemory(8);
  53. // Comment these out if not using the audio adaptor board.
  54. // This may wait forever if the SDA & SCL pins lack
  55. // pullup resistors
  56. sgtl5000_1.enable();
  57. sgtl5000_1.volume(0.5);
  58. SPI.setMOSI(SDCARD_MOSI_PIN);
  59. SPI.setSCK(SDCARD_SCK_PIN);
  60. if (!(SD.begin(SDCARD_CS_PIN))) {
  61. // stop here, but print a message repetitively
  62. while (1) {
  63. Serial.println("Unable to access the SD card");
  64. delay(500);
  65. }
  66. }
  67. }
  68. void playFile(const char *filename)
  69. {
  70. Serial.print("Playing file: ");
  71. Serial.println(filename);
  72. // Start playing the file. This sketch continues to
  73. // run while the file plays.
  74. playWav1.play(filename);
  75. // A brief delay for the library read WAV info
  76. delay(5);
  77. // Simply wait for the file to finish playing.
  78. while (playWav1.isPlaying()) {
  79. // uncomment these lines if you audio shield
  80. // has the optional volume pot soldered
  81. //float vol = analogRead(15);
  82. //vol = vol / 1024;
  83. // sgtl5000_1.volume(vol);
  84. }
  85. }
  86. void loop() {
  87. playFile("SDTEST1.WAV");
  88. delay(500);
  89. playFile("SDTEST2.WAV");
  90. delay(500);
  91. playFile("SDTEST3.WAV");
  92. delay(500);
  93. playFile("SDTEST4.WAV");
  94. delay(1500);
  95. }