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,45 @@
/**
* @file example-udp-receive.ino
* @author Phil Schatzmann
* @brief Receiving audio via udp.
* Because the clocks of the 2 processors are not synchronized, we might get some
* buffer overruns or underruns.
* @version 0.1
* @date 2022-03-09
*
* @copyright Copyright (c) 2022
* */
#include "AudioTools.h"
#include "AudioTools/Communication/UDPStream.h"
// #include "AudioTools/AudioLibs/AudioBoardStream.h"
const char* ssid="SSID";
const char* password="password";
AudioInfo info(22000, 1, 16);
UDPStream udp(ssid, password);
const int udpPort = 7000;
I2SStream out; // or ony other e.g. AudioBoardStream
StreamCopy copier(out, udp);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start UDP receive
udp.begin(udpPort);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
config.buffer_size = 1024;
config.buffer_count = 20;
out.begin(config);
Serial.println("started...");
}
void loop() {
copier.copy();
}

View File

@@ -0,0 +1,48 @@
/**
* @file example-udp-send.ino
* @author Phil Schatzmann
* @brief Sending audio over udp. Because the SineWaveGenerator is providing the data as fast
* as possible we need to throttle the speed.
* @version 0.1
* @date 2022-03-09
*
* @copyright Copyright (c) 2022
*/
#include "AudioTools.h"
#include "AudioTools/Communication/UDPStream.h"
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(22000, 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
UDPStream udp(ssid, password);
Throttle throttle(udp);
IPAddress udpAddress(192, 168, 1, 255);
const int udpPort = 7000;
StreamCopy copier(throttle, sound); // copies sound into i2s
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// Setup sine wave
sineWave.begin(info, N_B4);
// Define udp address and port
udp.begin(udpAddress, udpPort);
// Define Throttle
auto cfg = throttle.defaultConfig();
cfg.copyFrom(info);
//cfg.correction_ms = 0;
throttle.begin(cfg);
Serial.println("started...");
}
void loop() {
copier.copy();
}