File tree Expand file tree Collapse file tree 3 files changed +52
-12
lines changed
examples-basic-api/basic-a2dp-i2s Expand file tree Collapse file tree 3 files changed +52
-12
lines changed Original file line number Diff line number Diff line change 6
6
* @copyright GPLv3
7
7
*/
8
8
9
- /* *
10
- * @file basic-a2dp-audioi2s.ino
11
- * @brief A2DP Sink with output to SPDIFStream
12
- *
13
- * @author Phil Schatzmann
14
- * @copyright GPLv3
15
- */
16
-
17
9
#define USE_A2DP
18
10
#include " AudioConfigLocal.h"
19
11
#include " AudioTools.h"
20
- #include " AudioExperiments/Resample.h"
21
12
22
13
BluetoothA2DPSink a2dp_sink;
23
14
I2SStream i2s;
24
- Resample<int16_t > out (i2s, 2 , 2 );
25
15
26
16
// Write data to SPDIF in callback
27
17
void read_data_stream (const uint8_t *data, uint32_t length) {
28
- out .write (data, length);
18
+ i2s .write (data, length);
29
19
}
30
20
31
21
void setup () {
@@ -42,7 +32,7 @@ void setup() {
42
32
// setup output
43
33
auto cfg = i2s.defaultConfig ();
44
34
cfg.pin_data = 23 ;
45
- cfg.sample_rate = a2dp_sink.sample_rate ()* 2 ;
35
+ cfg.sample_rate = a2dp_sink.sample_rate ();
46
36
cfg.channels = 2 ;
47
37
cfg.bits_per_sample = 16 ;
48
38
i2s.begin (cfg);
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #define I2S_BUFFER_COUNT 8
4
+ #define I2S_BUFFER_SIZE 256
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * @file basic-a2dp-audioi2s.ino
3
+ * @brief A2DP Sink with output to respampled I2S
4
+ *
5
+ * @author Phil Schatzmann
6
+ * @copyright GPLv3
7
+ */
8
+
9
+ #define USE_A2DP
10
+ #include " AudioConfigLocal.h"
11
+ #include " AudioTools.h"
12
+ #include " AudioExperiments/Resample.h"
13
+
14
+ BluetoothA2DPSink a2dp_sink;
15
+ I2SStream i2s;
16
+ Resample<int16_t > out (i2s, 2 , 2 );
17
+
18
+ // Write data to SPDIF in callback
19
+ void read_data_stream (const uint8_t *data, uint32_t length) {
20
+ out.write (data, length);
21
+ }
22
+
23
+ void setup () {
24
+ Serial.begin (115200 );
25
+ AudioLogger::instance ().begin (Serial, AudioLogger::Warning);
26
+
27
+ // register callback
28
+ a2dp_sink.set_stream_reader (read_data_stream, false );
29
+
30
+ // Start Bluetooth Audio Receiver
31
+ a2dp_sink.set_auto_reconnect (false );
32
+ a2dp_sink.start (" a2dp-i2s" );
33
+
34
+ // setup output
35
+ auto cfg = i2s.defaultConfig ();
36
+ cfg.pin_data = 23 ;
37
+ cfg.sample_rate = a2dp_sink.sample_rate ()*2 ;
38
+ cfg.channels = 2 ;
39
+ cfg.bits_per_sample = 16 ;
40
+ i2s.begin (cfg);
41
+
42
+ }
43
+
44
+ void loop () {
45
+ delay (100 );
46
+ }
You can’t perform that action at this time.
0 commit comments