This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
# Test Signal to Bluetooth Speaker
Sometimes it is quite useful to be able to generate a test tone.
We can use the GeneratedSoundStream class together with a SoundGenerator class. In my example I use a SineWaveGenerator.
To test the output I'm using this generated signal and write it to A2DP (e.g. a Bluetooth Speaker).
### Dependencies
- https://github.com/pschatzmann/ESP32-A2DP.git

View File

@@ -0,0 +1,48 @@
/**
* @file streams-generator-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-generator-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/A2DPStream.h"
const char* name = "LEXON MINO L"; // Replace with your device name
AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
A2DPStream out; // A2DP output
StreamCopy copier(out, in); // copy in to out
// Arduino Setup
void setup(void) {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// set the frequency
sineWave.setFrequency(N_B4);
// Setup sine wave
auto cfg = in.defaultConfig();
cfg.copyFrom(info);
in.addNotifyAudioChange(out);
in.begin(cfg);
// We send the test signal via A2DP - so we conect to the MyMusic Bluetooth Speaker
auto cfgA2DP = out.defaultConfig(TX_MODE);
cfgA2DP.name = name;
//cfgA2DP.auto_reconnect = false;
out.begin(cfgA2DP);
out.setVolume(0.3);
Serial.println("A2DP is connected now...");
}
// Arduino loop
void loop() {
copier.copy();
}