16
16
17
17
using namespace audio_tools ;
18
18
19
- I2SStream i2sStream; // Access I2S as stream
19
+ I2SStream i2sStream; // Access I2S as stream
20
20
A2DPStream a2dpStream = A2DPStream::instance(); // access A2DP as stream
21
21
StreamCopy copier (a2dpStream, i2sStream); // copy i2sStream to a2dpStream
22
22
ConverterFillLeftAndRight<int16_t > filler (RightIsEmpty); // fill both channels
23
23
24
-
25
24
// Arduino Setup
26
25
void setup (void ) {
27
- Serial.begin (115200 );
28
- AudioLogger::instance ().begin (Serial, AudioLogger::Info);
29
-
30
- // start the bluetooth
31
- Serial.println (" starting A2DP..." );
32
- a2dpStream.begin (TX_MODE, " MyMusic" );
33
- Serial.println (" A2DP is connected now" );
34
-
35
- // start i2s input with default configuration
36
- Serial.println (" starting I2S..." );
37
- auto config = i2sStream.defaultConfig (RX_MODE);
38
- config.sample_rate = 44100 ;
39
- config.channels = 2 ;
40
- config.bits_per_sample = 16 ;
41
- i2sStream.begin (config);
42
- Serial.println (" I2S started" );
26
+ Serial.begin (115200 );
27
+ AudioLogger::instance ().begin (Serial, AudioLogger::Info);
28
+
29
+ // start bluetooth
30
+ Serial.println (" starting A2DP..." );
31
+ auto cfgA2DP = a2dpStream.defaultConfig (TX_MODE);
32
+ cfgA2DP.name = " LEXON MINO L" ;
33
+ a2dpStream.begin (cfgA2DP);
34
+
35
+ // start i2s input with default configuration
36
+ Serial.println (" starting I2S..." );
37
+ a2dpStream.setNotifyAudioChange (i2sStream); // i2s is using the info from a2dp
38
+ i2sStream.begin (i2sStream.defaultConfig (RX_MODE));
43
39
44
40
}
45
41
46
- // Arduino loop - copy data
42
+ // Arduino loop - copy data
47
43
void loop () {
48
- if (a2dpStream){
49
- copier.copy (filler);
50
- }
51
- }
44
+ copier.copy (filler);
45
+ }
0 commit comments