-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7346c18
commit ecd8ddf
Showing
5 changed files
with
127 additions
and
15 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...dbox/ble/client-as-source/communication-ble-client-send/communication-ble-client-send.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @file communications-ble-client-send.ino | ||
* @author Phil Schatzmann | ||
* @brief Sending audio via BLE: the client acts as audio source | ||
* @version 0.1 | ||
* @date 2022-11-04 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
*/ | ||
|
||
|
||
#include "AudioTools.h" | ||
#include "AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm | ||
#include "Sandbox/BLE/AudioBLE.h" | ||
|
||
AudioInfo info(16000, 1, 16); | ||
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000 | ||
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave | ||
Throttle throttle(sound); | ||
AudioBLEClient ble; | ||
ADPCMEncoder adpcm(AV_CODEC_ID_ADPCM_IMA_WAV); | ||
EncodedAudioStream encoder(&ble, &adpcm); | ||
StreamCopy copier(encoder, throttle); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
AudioLogger::instance().begin(Serial, AudioLogger::Info); | ||
|
||
sineWave.begin(info, N_B4); | ||
throttle.begin(info); | ||
encoder.begin(info); | ||
ble.begin("ble-send", 60*10); | ||
|
||
Serial.println("started..."); | ||
} | ||
|
||
void loop() { | ||
copier.copy(); | ||
} |
38 changes: 38 additions & 0 deletions
38
...le/client-as-source/communication-ble-server-receive/communication-ble-server-receive.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @file communications-ble-server-receive.ino | ||
* @author Phil Schatzmann | ||
* @brief Receiving audio via BLE: the server acts as audio sink | ||
* @version 0.1 | ||
* @date 2022-11-04 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
*/ | ||
|
||
#include "AudioTools.h" | ||
#include "AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm | ||
#include "Sandbox/BLE/AudioBLE.h" | ||
//#include "AudioLibs/AudioKit.h" | ||
|
||
AudioInfo info(16000, 1, 16); | ||
ADPCMDecoder adpcm(AV_CODEC_ID_ADPCM_IMA_WAV); | ||
I2SStream i2s; // or AudioKitStream ... | ||
EncodedAudioStream decoder(&i2s, &adpcm); | ||
AudioBLEServer ble; | ||
StreamCopy copier(decoder, ble); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
AudioLogger::instance().begin(Serial, AudioLogger::Warning); | ||
|
||
decoder.begin(info); | ||
|
||
auto cfg = i2s.defaultConfig(); | ||
cfg.copyFrom(info); | ||
i2s.begin(cfg); | ||
|
||
ble.begin("ble-receive"); | ||
} | ||
|
||
void loop() { | ||
copier.copy(); | ||
} |
8 changes: 4 additions & 4 deletions
8
...n-ble-client/communication-ble-client.ino → ...eive/communication-ble-client-receive.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...n-ble-server/communication-ble-server.ino → ...er-send/communication-ble-server-send.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters