1
+ /*
2
+ Streaming Music from Bluetooth
3
+
4
+ Copyright (C) 2020 Phil Schatzmann
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+ */
16
+
17
+ // ==> Example A2DP Receiver which uses the A2DP I2S output with 32 bits
18
+
19
+ #include " AudioTools.h"
20
+ #include " AudioLibs/AudioBoardStream.h" // install https://github.com/pschatzmann/arduino-audio-driver
21
+ #include " BluetoothA2DPSink.h"
22
+
23
+ AudioInfo info (44100 , 2 , 32 );
24
+ I2SStream out;
25
+ NumberFormatConverterStream convert (out);
26
+ BluetoothA2DPSink a2dp_sink (convert);
27
+
28
+ void setup () {
29
+ Serial.begin (115200 );
30
+ // AudioLogger::instance().begin(Serial, AudioLogger::Info);
31
+
32
+ // Configure i2s to use 32 bits
33
+ auto cfg = out.defaultConfig ();
34
+ cfg.copyFrom (info);
35
+ out.begin (cfg);
36
+
37
+ // Convert from 16 to 32 bits
38
+ convert.begin (16 , 32 );
39
+
40
+ // start a2dp
41
+ a2dp_sink.start (" AudioKit" );
42
+ }
43
+
44
+
45
+ void loop () {
46
+ delay (1000 ); // do nothing
47
+ }
0 commit comments