snapshot
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// FDK AAC decoding test: psram must be active
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/Communication/AudioHttp.h"
|
||||
|
||||
SET_LOOP_TASK_STACK_SIZE(50 * 1024);
|
||||
|
||||
URLStream url("ssid","password"); // or replace with ICYStream to get metadata
|
||||
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
|
||||
EncodedAudioStream dec(&i2s, new AACDecoderFDK()); // Decoding stream
|
||||
StreamCopy copier(dec, url); // copy url to decoder
|
||||
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup i2s
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
config.buffer_size = 1024;
|
||||
config.buffer_count = 20;
|
||||
i2s.begin(config);
|
||||
|
||||
// setup I2S based on sampling rate provided by decoder
|
||||
dec.begin();
|
||||
|
||||
// aac radio
|
||||
url.begin("http://peacefulpiano.stream.publicradio.org/peacefulpiano.aac","audio/aac");
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
|
||||
|
||||
// test case for sine -> aac encoder -> hex output
|
||||
AudioInfo info(44100,2,16);
|
||||
AACEncoderFDK fdk;
|
||||
SineWaveGenerator<int16_t> sineWave;
|
||||
GeneratedSoundStream<int16_t> in(sineWave);
|
||||
HexDumpOutput out(Serial);
|
||||
EncodedAudioStream encoder(&out, &fdk);
|
||||
StreamCopy copier(encoder, in);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioLogger::instance().begin(Serial,AudioLogger::Warning);
|
||||
|
||||
auto cfg = encoder.defaultConfig();
|
||||
cfg.copyFrom(info);
|
||||
encoder.begin(cfg);
|
||||
|
||||
// start generation of sound
|
||||
sineWave.begin(info, N_B4);
|
||||
}
|
||||
|
||||
|
||||
// copy the data
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file test-codec-adpcm.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCMXQ.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.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
|
||||
//AudioBoardStream out(AudioKitEs8388V1);
|
||||
//I2SStream out;
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new ADPCMDecoderXQ()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new ADPCMEncoderXQ()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file test-codec-adpcm.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* Please install the https://github.com/pschatzmann/adpcm library
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h" // https://github.com/pschatzmann/adpcm
|
||||
//#include "AudioTools/AudioLibs/AudioBoardStream.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
|
||||
//I2SStream out;
|
||||
//AudioBoardStream out(AudioKitEs8388V1);
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
AVCodecID id = AV_CODEC_ID_ADPCM_IMA_WAV;
|
||||
EncodedAudioStream decoder(&out, new ADPCMDecoder(id)); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new ADPCMEncoder(id)); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file test-codec-alac.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @note Activate PSRAM or dicrease the frame size e.g. by adding 1024 to the constructor of the enc_alac and dec_alac
|
||||
* @version 0.1
|
||||
*
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecALAC.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
// SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB - not needed
|
||||
|
||||
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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
//I2SStream out;
|
||||
//CsvOutput<int16_t> out(Serial);
|
||||
EncoderALAC enc_alac;
|
||||
DecoderALAC dec_alac;
|
||||
CodecNOP dec_nop;
|
||||
EncodedAudioStream decoder(&out, &dec_alac); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc_alac); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Debug);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// optionally copy config from encoder to decoder
|
||||
// since decoder already has audio info and frames
|
||||
// dec_alac.setCodecConfig(enc_alac.config());
|
||||
// dec_alac.setCodecConfig(enc_alac.binaryConfig());
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecAPTX.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
//AudioBoardStream out(AudioKitEs8388V1);
|
||||
//I2SStream out;
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new APTXDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new APTXEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new DecoderBase64()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new EncoderBase64()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin();
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> csv (Serial)
|
||||
* Unfortunately codec2 needs more stack then we have available in Arduino. So we do the processing
|
||||
* in a separate task with a stack of 20k
|
||||
*
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecCodec2.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
//CsvOutput<int16_t> out(Serial, channels);
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new Codec2Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new Codec2Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
|
||||
void loop1(void*) {
|
||||
// setup decoder
|
||||
decoder.begin(info);
|
||||
// setup encoder
|
||||
encoder.begin(info);
|
||||
// processing loop
|
||||
while(true){
|
||||
copier.copy();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
auto cfg = out.defaultConfig();
|
||||
cfg.copyFrom(info);
|
||||
out.begin(cfg);
|
||||
|
||||
int stack = 20000;
|
||||
xTaskCreate(loop1,"loopTask", stack, nullptr,1, nullptr);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecFLAC.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.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
|
||||
HexDumpOutput out(Serial);
|
||||
EncodedAudioStream encoder(&out, new FLACEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG7xx.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G711_ALAWDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G711_ALAWEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG7xx.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G711_ULAWDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G711_ULAWEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG7xx.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G721Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G721Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG722.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G722Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G722Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG7xx.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G723_24Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G723_24Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecG7xx.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new G723_40Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new G723_40Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecGSM.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new GSMDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new GSMEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file test-codec-iLBC.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecILBC.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new ILBCDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new ILBCEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void loop1(void*) {
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
while(true){
|
||||
copier.copy();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
int stack = 20000;
|
||||
xTaskCreate(loop1,"loopTask", stack, nullptr,1, nullptr);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecL8.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
//I2SStream out;
|
||||
//CsvOutput<int16_t> out(Serial,channels);
|
||||
EncodedAudioStream decoder(&out, new DecoderL8()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new EncoderL8()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);// LC3 does not provide audio info from source
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecLC3.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
//I2SStream out;
|
||||
//CsvOutput<int16_t> out(Serial,channels);
|
||||
EncodedAudioStream decoder(&out, new LC3Decoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new LC3Encoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);// LC3 does not provide audio info from source
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file test-codec-opus.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpus.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
OpusAudioDecoder dec;
|
||||
OpusAudioEncoder enc;
|
||||
EncodedAudioStream decoder(&out, &dec); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// Opus encoder and decoder need to know the audio info
|
||||
decoder.begin(info);
|
||||
encoder.begin(info);
|
||||
|
||||
// configure additinal parameters
|
||||
// auto &enc_cfg = enc.config()
|
||||
// enc_cfg.application = OPUS_APPLICATION_RESTRICTED_LOWDELAY;
|
||||
// enc_cfg.frame_sizes_ms_x2 = OPUS_FRAMESIZE_20_MS;
|
||||
// enc_cfg.complexity = 5;
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file test-codec-opusogg.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpusOgg.h"
|
||||
|
||||
AudioInfo info(24000, 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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
//CsvOutput<int16_t> out(Serial);
|
||||
OpusOggEncoder enc;
|
||||
OpusOggDecoder dec;
|
||||
EncodedAudioStream decoder(&out, &dec); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// Setup output
|
||||
auto cfgo = out.defaultConfig();
|
||||
cfgo.copyFrom(info);
|
||||
out.begin(cfgo);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(cfgs, N_B4);
|
||||
|
||||
// Opus encoder needs to know the audio info
|
||||
encoder.begin(info);
|
||||
decoder.begin(info);
|
||||
|
||||
// configure additinal parameters
|
||||
//enc.config().application = OPUS_APPLICATION_RESTRICTED_LOWDELAY;
|
||||
//enc.config().frame_sizes_ms_x2 = OPUS_FRAMESIZE_20_MS;
|
||||
//enc.config().complexity = 5;
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecSBC.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new SBCDecoder()); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, new SBCEncoder()); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecWAV.h"
|
||||
#include "AudioTools/AudioCodecs/CodecADPCM.h"
|
||||
|
||||
AudioInfo info(16000, 2, 16);
|
||||
SineWaveGenerator<int16_t> sineWave( 32000);
|
||||
GeneratedSoundStream<int16_t> sound( sineWave);
|
||||
CsvOutput<int16_t> out(Serial);
|
||||
AVCodecID id = AV_CODEC_ID_ADPCM_IMA_WAV;
|
||||
ADPCMDecoder adpcm_decoder(id);
|
||||
ADPCMEncoder adpcm_encoder(id);
|
||||
WAVDecoder wav_decoder(adpcm_decoder, AudioFormat::ADPCM);
|
||||
WAVEncoder wav_encoder(adpcm_encoder, AudioFormat::ADPCM);
|
||||
EncodedAudioStream decoder(&out, &wav_decoder);
|
||||
EncodedAudioStream encoder(&decoder, &wav_encoder);
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start Output
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
auto cfgs = sineWave.defaultConfig();
|
||||
cfgs.copyFrom(info);
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/All.h"
|
||||
|
||||
void setup() {
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file communication-container-binary-meta.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* We demonstrate how to pass any type of metadata from the encoder to the
|
||||
* decoder
|
||||
* @version 0.1
|
||||
* @date 2023-05-18
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpus.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerBinary.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
struct MetaData {
|
||||
MetaData(const char* typeArg, float vol) {
|
||||
volume = vol;
|
||||
strncpy(type, typeArg, 5);
|
||||
}
|
||||
MetaData(MetaData* data) {
|
||||
volume = data->volume;
|
||||
strncpy(type, data->type, 5);
|
||||
}
|
||||
|
||||
void log() {
|
||||
Serial.print("====> ");
|
||||
Serial.print(type);
|
||||
Serial.print(": volume ");
|
||||
Serial.println(volume);
|
||||
}
|
||||
|
||||
protected:
|
||||
float volume;
|
||||
char type[5];
|
||||
};
|
||||
|
||||
void metaCallback(uint8_t* data, int len, void*ref) {
|
||||
assert(sizeof(MetaData)==len);
|
||||
MetaData meta((MetaData*)data);
|
||||
meta.log();
|
||||
}
|
||||
|
||||
AudioInfo info(8000, 1, 16);
|
||||
SineWaveGenerator<int16_t> sineWave(32000);
|
||||
GeneratedSoundStream<int16_t> sound(sineWave);
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
BinaryContainerDecoder cont_dec(new OpusAudioDecoder());
|
||||
BinaryContainerEncoder cont_enc(new OpusAudioEncoder());
|
||||
EncodedAudioStream decoder(&out, &cont_dec);
|
||||
EncodedAudioStream encoder(&decoder, &cont_enc);StreamCopy copier(encoder, sound);
|
||||
MetaData meta{"opus", 0.5};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
// receive meta data
|
||||
cont_dec.setMetaCallback(metaCallback);
|
||||
|
||||
// write meta data
|
||||
cont_enc.writeMeta((const uint8_t*)&meta, sizeof(MetaData));
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
void loop() { copier.copy(); }
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file communication-container-binary.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerBinary.h"
|
||||
#include "AudioTools/AudioCodecs/CodecOpus.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
|
||||
AudioInfo info(8000,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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new BinaryContainerDecoder(new OpusAudioDecoder()));
|
||||
EncodedAudioStream encoder(&decoder, new BinaryContainerEncoder(new OpusAudioEncoder()));
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file communication-codec-test.ino
|
||||
* @author Phil Schatzmann
|
||||
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
|
||||
* @version 0.1
|
||||
* @date 2022-04-30
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/ContainerOgg.h"
|
||||
#include "AudioTools/AudioCodecs/CodecSBC.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.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
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
OggContainerEncoder enc(new SBCEncoder());
|
||||
OggContainerDecoder dec(new SBCDecoder());
|
||||
//OggContainerEncoder enc;
|
||||
//OggContainerDecoder dec;
|
||||
EncodedAudioStream decoder(&out, &dec); // encode and write
|
||||
EncodedAudioStream encoder(&decoder, &enc); // encode and write
|
||||
StreamCopy copier(encoder, sound);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
|
||||
|
||||
// start I2S
|
||||
Serial.println("starting I2S...");
|
||||
auto cfgi = out.defaultConfig(TX_MODE);
|
||||
cfgi.copyFrom(info);
|
||||
out.begin(cfgi);
|
||||
|
||||
// Setup sine wave
|
||||
sineWave.begin(info, N_B4);
|
||||
|
||||
// start decoder
|
||||
decoder.begin(info);
|
||||
|
||||
// start encoder
|
||||
encoder.begin(info);
|
||||
|
||||
Serial.println("Test started...");
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "AudioTools/Communication/AudioHttp.h"
|
||||
|
||||
/**
|
||||
* @brief Sketch to test the memory usage with libhelix with an ESP32
|
||||
* => Available heap 140980-151484
|
||||
*/
|
||||
|
||||
|
||||
|
||||
URLStream url("SSID","password");
|
||||
I2SStream i2s; // final output of decoded stream
|
||||
VolumeStream volume(i2s);
|
||||
LogarithmicVolumeControl lvc(0.1);
|
||||
EncodedAudioStream dec(&volume,new MP3DecoderHelix()); // Decoding stream
|
||||
StreamCopy copier(dec, url); // copy url to decoder
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup i2s
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
i2s.begin(config);
|
||||
|
||||
// setup I2S based on sampling rate provided by decoder
|
||||
dec.begin();
|
||||
|
||||
// set initial volume
|
||||
volume.setVolumeControl(lvc);
|
||||
volume.setVolume(0.5);
|
||||
|
||||
// mp3 radio
|
||||
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128","audio/mp3");
|
||||
}
|
||||
|
||||
uint32_t i=0;
|
||||
uint32_t minFree=0xFFFFFFFF;
|
||||
uint32_t maxFree=0;
|
||||
uint32_t actFree;
|
||||
|
||||
void minMax(){
|
||||
if (i%1000==0){
|
||||
actFree = ESP.getFreeHeap();
|
||||
if (actFree < minFree){
|
||||
minFree = actFree;
|
||||
}
|
||||
if (actFree > maxFree){
|
||||
maxFree = actFree;
|
||||
}
|
||||
Serial.println();
|
||||
Serial.print(actFree);
|
||||
Serial.print(":");
|
||||
Serial.print(minFree);
|
||||
Serial.print("-");
|
||||
Serial.println(maxFree);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
minMax();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @brief Tesing the MP3DecoderHelix: Decoding
|
||||
* on the input side.
|
||||
*/
|
||||
// install https://github.com/pschatzmann/arduino-libhelix.git
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
//CsvOutput<int16_t> out(Serial,2);
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream pcm_source(&mp3, new MP3DecoderHelix()); // output to decoder
|
||||
StreamCopy copier(out, pcm_source);
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup I2s
|
||||
out.begin(out.defaultConfig());
|
||||
|
||||
// make sure that i2s is updated
|
||||
pcm_source.addNotifyAudioChange(out);
|
||||
// setup pcm_source
|
||||
pcm_source.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @brief Tesing the MP3DecoderHelix
|
||||
*
|
||||
*/
|
||||
// install https://github.com/pschatzmann/arduino-libhelix.git
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
//CsvOutput<int16_t> out(Serial,2);
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new MP3DecoderHelix()); // output to decoder
|
||||
StreamCopy copier(decoder, mp3);
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
|
||||
// setup I2s
|
||||
out.begin(out.defaultConfig());
|
||||
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
decoder.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @brief Testing MP3DecoderMAD
|
||||
*
|
||||
*/
|
||||
// install https://github.com/pschatzmann/arduino-libhelix.git
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3MAD.h"
|
||||
#include "BabyElephantWalk60_mp3.h"
|
||||
|
||||
MemoryStream mp3(BabyElephantWalk60_mp3, BabyElephantWalk60_mp3_len);
|
||||
//CsvOutput<int16_t> out(Serial,2);
|
||||
AudioBoardStream out(AudioKitEs8388V1);
|
||||
EncodedAudioStream decoder(&out, new MP3DecoderMAD()); // output to decoder
|
||||
StreamCopy copier(decoder, mp3);
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup I2s
|
||||
out.begin(out.defaultConfig());
|
||||
|
||||
decoder.begin();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
copier.copy();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/Disk/AudioSourceSD.h" // or AudioSourceIdxSD.h
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h" // for SD pins
|
||||
|
||||
AudioSourceSD source("/", "", PIN_AUDIO_KIT_SD_CARD_CS);
|
||||
HeaderParserMP3 mp3;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
|
||||
while (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
|
||||
Serial.println("SD.begin failed");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
source.begin();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
File* p_file = (File*) source.nextStream();
|
||||
if (p_file==nullptr) stop();
|
||||
File& file = *p_file;
|
||||
|
||||
uint8_t tmp[1024];
|
||||
int len = file.readBytes((char*)tmp, 1024);
|
||||
|
||||
// check if mp3 file
|
||||
bool is_mp3 = mp3.isValid(tmp, len);
|
||||
|
||||
// print result
|
||||
Serial.print(" ==> ");
|
||||
Serial.print(file.name());
|
||||
Serial.println(is_mp3 ? " +":" -");
|
||||
file.close();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "AudioTools.h"
|
||||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
|
||||
#include "AudioTools/AudioLibs/AudioBoardStream.h"
|
||||
#include "AudioTools/Communication/AudioHttp.h"
|
||||
|
||||
URLStream url("ssid","password"); // or replace with ICYStream to get metadata
|
||||
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
|
||||
MP3DecoderHelix helix;
|
||||
StreamingDecoderAdapter decoder(helix, "audaudio/mpeg");
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
||||
|
||||
// setup i2s
|
||||
auto config = i2s.defaultConfig(TX_MODE);
|
||||
i2s.begin(config);
|
||||
|
||||
// setup I2S based on sampling rate provided by decoder
|
||||
decoder.setInput(url);
|
||||
decoder.setOutput(i2s);
|
||||
decoder.begin();
|
||||
|
||||
// mp3 radio
|
||||
url.begin("http://stream.srg-ssr.ch/m/rsj/mp3_128","audio/mp3");
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
decoder.copy();
|
||||
}
|
||||
Reference in New Issue
Block a user