snapshot
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file communications-ble-client-receive.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Receiving audio via BLE: The client acts as audio sink and is writing to I2S.
|
||||
* This scenario works amazingly well!
|
||||
* @version 0.1
|
||||
* @date 2022-11-04
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*/
|
||||
|
||||
|
||||
#include "AudioTools.h"
|
||||
//#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm
|
||||
#include "AudioTools/Sandbox/BLE/AudioBLE.h"
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
AudioBLEClient ble;
|
||||
I2SStream i2s;
|
||||
ADPCMDecoder adpcm(AV_CODEC_ID_ADPCM_IMA_WAV);
|
||||
EncodedAudioStream decoder(&i2s, &adpcm);
|
||||
StreamCopy copier(decoder, ble);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start BLE client - wait at most 10 minutes
|
||||
ble.begin("ble-receive", 60*10);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start I2S
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
config.copyFrom(info);
|
||||
i2s.begin(config);
|
||||
|
||||
Serial.println("started...");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (ble)
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file communications-ble-server-send.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief Sending audio via BLE: The server acts as audio source.
|
||||
* This scenario works amazingly well!
|
||||
* @version 0.1
|
||||
* @date 2022-11-04
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*/
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm
|
||||
#include "AudioTools/Sandbox/BLE/AudioBLE.h"
|
||||
|
||||
AudioInfo info(44100, 2, 16);
|
||||
SineWaveGenerator<int16_t>
|
||||
sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
|
||||
GeneratedSoundStream<int16_t>
|
||||
sound(sineWave); // Stream generated from sine wave
|
||||
AudioBLEServer ble;
|
||||
ADPCMEncoder adpcm(AV_CODEC_ID_ADPCM_IMA_WAV);
|
||||
EncodedAudioStream encoder(&ble, &adpcm);
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
encoder.begin(info);
|
||||
|
||||
// ble.setAudioInfoActive(true);
|
||||
ble.begin("ble-send");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (ble.availableForWrite() > 0)
|
||||
copier.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user