From 4994062f113934b88dcb630c3d5280d04b8372b2 Mon Sep 17 00:00:00 2001 From: Phil Schatzmann Date: Wed, 3 Nov 2021 08:51:59 +0100 Subject: [PATCH] streams-i2s-a2dp.ino --- .../streams-i2s-a2dp/streams-i2s-a2dp.ino | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/examples/streams-i2s-a2dp/streams-i2s-a2dp.ino b/examples/streams-i2s-a2dp/streams-i2s-a2dp.ino index b1f08f0aec..2fcb7400a4 100644 --- a/examples/streams-i2s-a2dp/streams-i2s-a2dp.ino +++ b/examples/streams-i2s-a2dp/streams-i2s-a2dp.ino @@ -16,36 +16,30 @@ using namespace audio_tools; -I2SStream i2sStream; // Access I2S as stream +I2SStream i2sStream; // Access I2S as stream A2DPStream a2dpStream = A2DPStream::instance(); // access A2DP as stream StreamCopy copier(a2dpStream, i2sStream); // copy i2sStream to a2dpStream ConverterFillLeftAndRight filler(RightIsEmpty); // fill both channels - // Arduino Setup void setup(void) { - Serial.begin(115200); - AudioLogger::instance().begin(Serial, AudioLogger::Info); - - // start the bluetooth - Serial.println("starting A2DP..."); - a2dpStream.begin(TX_MODE, "MyMusic"); - Serial.println("A2DP is connected now"); - - // start i2s input with default configuration - Serial.println("starting I2S..."); - auto config = i2sStream.defaultConfig(RX_MODE); - config.sample_rate = 44100; - config.channels = 2; - config.bits_per_sample = 16; - i2sStream.begin(config); - Serial.println("I2S started"); + Serial.begin(115200); + AudioLogger::instance().begin(Serial, AudioLogger::Info); + + // start bluetooth + Serial.println("starting A2DP..."); + auto cfgA2DP = a2dpStream.defaultConfig(TX_MODE); + cfgA2DP.name = "LEXON MINO L"; + a2dpStream.begin(cfgA2DP); + + // start i2s input with default configuration + Serial.println("starting I2S..."); + a2dpStream.setNotifyAudioChange(i2sStream); // i2s is using the info from a2dp + i2sStream.begin(i2sStream.defaultConfig(RX_MODE)); } -// Arduino loop - copy data +// Arduino loop - copy data void loop() { - if (a2dpStream){ - copier.copy(filler); - } -} \ No newline at end of file + copier.copy(filler); +}