Skip to content

Commit

Permalink
streams-i2s-a2dp.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 3, 2021
1 parent 158b074 commit 4994062
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions examples/streams-i2s-a2dp/streams-i2s-a2dp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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<int16_t> 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);
}
}
copier.copy(filler);
}

0 comments on commit 4994062

Please sign in to comment.