Skip to content

Commit 4994062

Browse files
committed
streams-i2s-a2dp.ino
1 parent 158b074 commit 4994062

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

examples/streams-i2s-a2dp/streams-i2s-a2dp.ino

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,30 @@
1616

1717
using namespace audio_tools;
1818

19-
I2SStream i2sStream; // Access I2S as stream
19+
I2SStream i2sStream; // Access I2S as stream
2020
A2DPStream a2dpStream = A2DPStream::instance(); // access A2DP as stream
2121
StreamCopy copier(a2dpStream, i2sStream); // copy i2sStream to a2dpStream
2222
ConverterFillLeftAndRight<int16_t> filler(RightIsEmpty); // fill both channels
2323

24-
2524
// Arduino Setup
2625
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));
4339

4440
}
4541

46-
// Arduino loop - copy data
42+
// Arduino loop - copy data
4743
void loop() {
48-
if (a2dpStream){
49-
copier.copy(filler);
50-
}
51-
}
44+
copier.copy(filler);
45+
}

0 commit comments

Comments
 (0)