1
+ /* *
2
+ * @file player-sdfat-a2dp.ino
3
+ * @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md
4
+ *
5
+ * @author Phil Schatzmann
6
+ * @copyright GPLv3
7
+ */
8
+
9
+
10
+ #include " AudioTools.h"
11
+ #include " AudioLibs/AudioA2DP.h"
12
+ #include " AudioLibs/AudioSourceSDFAT.h"
13
+ #include " AudioLibs/AudioKit.h"
14
+ #include " AudioCodecs/CodecMP3Helix.h"
15
+
16
+ const char *startFilePath=" /" ;
17
+ const char * ext=" mp3" ;
18
+ SdSpiConfig sdcfg (PIN_AUDIO_KIT_SD_CARD_CS, DEDICATED_SPI, SD_SCK_MHZ(10 ) , &AUDIOKIT_SD_SPI);
19
+ AudioSourceSDFAT source (startFilePath, ext, sdcfg);
20
+ A2DPStream out = A2DPStream::instance(); // A2DP input - A2DPStream is a singleton!
21
+ MP3DecoderHelix decoder;
22
+ AudioPlayer player (source, out, decoder);
23
+
24
+
25
+ void setup () {
26
+ Serial.begin (115200 );
27
+ AudioLogger::instance ().begin (Serial, AudioLogger::Warning);
28
+
29
+ // Define SPI FOR SD card
30
+ SPI.begin (PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
31
+
32
+ // setup output - We send the test signal via A2DP - so we conect to the "LEXON MINO L" Bluetooth Speaker
33
+ auto cfg = out.defaultConfig (TX_MODE);
34
+ cfg.name = " LEXON MINO L" ;
35
+ // cfg.auto_reconnect = true; // if this is use we just quickly connect to the last device ignoring cfg.name
36
+ out.begin (cfg);
37
+
38
+ // setup player
39
+ player.setVolume (0.1 );
40
+ player.begin ();
41
+
42
+ }
43
+
44
+ void loop () {
45
+ player.copy ();
46
+ }
0 commit comments