No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

68 líneas
1.6KB

  1. // Simple MP3 file player example
  2. //
  3. // Requires the prop-shield and Teensy 3.2 or 3.1
  4. // This example code is in the public domain.
  5. #include <Audio.h>
  6. #include <Wire.h>
  7. #include <SPI.h>
  8. #include <SerialFlash.h>
  9. #include <play_sd_mp3.h> // https://github.com/FrankBoesing/Arduino-Teensy-Codec-lib
  10. //#include <play_sd_aac.h>
  11. // GUItool: begin automatically generated code
  12. //AudioPlaySdWav playSdWav1; //xy=154,422
  13. AudioPlaySdMp3 playMp31; //xy=154,422
  14. AudioMixer4 mixer1; //xy=327,432
  15. AudioOutputAnalog dac1; //xy=502,412
  16. AudioConnection patchCord1(playMp31, 0, mixer1, 0);
  17. AudioConnection patchCord2(playMp31, 1, mixer1, 1);
  18. AudioConnection patchCord3(mixer1, dac1);
  19. // GUItool: end automatically generated code
  20. #define PROP_AMP_ENABLE 5
  21. #define FLASH_CHIP_SELECT 6
  22. void setup() {
  23. AudioMemory(8); //4
  24. delay(2000);
  25. // Start SerialFlash
  26. if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
  27. while (1) {
  28. Serial.println ("Cannot access SPI Flash chip");
  29. delay (1000);
  30. }
  31. }
  32. //Start Amplifier
  33. pinMode(PROP_AMP_ENABLE, OUTPUT);
  34. digitalWrite(PROP_AMP_ENABLE, HIGH); // Enable Amplifier
  35. }
  36. void playFile(const char *filename)
  37. {
  38. SerialFlashFile ff = SerialFlash.open(filename);
  39. Serial.print("Playing file: ");
  40. Serial.println(filename);
  41. uint32_t sz = ff.size();
  42. uint32_t pos = ff.getFlashAddress();
  43. // Start playing the file. This sketch continues to
  44. // run while the file plays.
  45. playMp31.play(pos,sz);
  46. // Simply wait for the file to finish playing.
  47. while (playMp31.isPlaying()) {}
  48. }
  49. void loop() {
  50. playFile("rain.mp3");
  51. delay(1000);
  52. }