|
| 1 | +/** |
| 2 | + * @file player-sdfat-vs1053.ino |
| 3 | + * @brief Audio player which sends the output to a VS1053 module. Using a module with built in SD card |
| 4 | + * |
| 5 | + * @author Phil Schatzmann |
| 6 | + * @copyright GPLv3 |
| 7 | + */ |
| 8 | + |
| 9 | +// install https://github.com/pschatzmann/arduino-vs1053.git |
| 10 | +// install https://github.com/greiman/SdFat |
| 11 | + |
| 12 | +#include "AudioTools.h" |
| 13 | +#include "AudioLibs/VS1053Stream.h" |
| 14 | +#include "AudioLibs/AudioSourceSDFAT.h" |
| 15 | +#include "AudioCodecs/CodecCopy.h" |
| 16 | + |
| 17 | +const char *startFilePath="/"; |
| 18 | +const char* ext="mp3"; |
| 19 | +AudioSouSdSpiConfig sd_cfg(PIN_CS, SHARED_SPI, SPI_CLOCK); |
| 20 | +AudioSourceSDFAT source(startFilePath, ext, cfg); |
| 21 | +VS1053Stream vs1053; // final output |
| 22 | +AudioPlayer player(source, vs1053, *new CopyDecoder()); |
| 23 | + |
| 24 | + |
| 25 | +void setup() { |
| 26 | + Serial.begin(115200); |
| 27 | + AudioLogger::instance().begin(Serial, AudioLogger::Info); |
| 28 | + |
| 29 | + // setup output |
| 30 | + auto cfg = vs1053.defaultConfig(); |
| 31 | + cfg.is_encoded_data = true; // vs1053 is accepting encoded data |
| 32 | + // Use your custom pins or define in AudioCodnfig.h |
| 33 | + //cfg.cs_pin = VS1053_CS; |
| 34 | + //cfg.dcs_pin = VS1053_DCS; |
| 35 | + //cfg.dreq_pin = VS1053_DREQ; |
| 36 | + //cfg.reset_pin = VS1053_RESET; |
| 37 | + vs1053.begin(cfg); |
| 38 | + vs1053.setVolume(1.0); // full volume |
| 39 | + |
| 40 | + // setup player |
| 41 | + player.begin(); |
| 42 | + |
| 43 | + // select file with setPath() or setIndex() |
| 44 | + //player.setPath("/ZZ Top/Unknown Album/Lowrider.mp3"); |
| 45 | + //player.setIndex(1); // 2nd file |
| 46 | + |
| 47 | +} |
| 48 | + |
| 49 | +void loop() { |
| 50 | + player.copy(); |
| 51 | +} |
0 commit comments