Skip to content

Commit f081a4d

Browse files
committed
sdfat a2dp example
1 parent aaa48f5 commit f081a4d

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

examples/examples-audiokit/basic-audiokit-a2dp/basic-audiokit-a2dp.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* @file base-audiokit-a2dp.ino
33
* @author Phil Schatzmann
4-
* @brief We use the built in microphone as input and send the data to A2DP
4+
* @brief We play mp4 files to an A2DP speaker
5+
* make sure that you compile with partition scheme: huge app
56
* @copyright GPLv3
67
*/
78

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

Comments
 (0)