Skip to content

Commit dbabdf2

Browse files
committed
Draft BinaryContainer
1 parent ec2f86b commit dbabdf2

File tree

5 files changed

+632
-231
lines changed

5 files changed

+632
-231
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @file communication-container-binary.ino
3+
* @author Phil Schatzmann
4+
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
5+
* @version 0.1
6+
* @date 2022-04-30
7+
*
8+
* @copyright Copyright (c) 2022
9+
*
10+
*/
11+
#include "AudioTools.h"
12+
#include "AudioCodecs/ContainerBinary.h"
13+
#include "AudioLibs/AudioKit.h"
14+
15+
AudioInfo info(8000,1,16);
16+
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
17+
GeneratedSoundStream<int16_t> sound( sineWave); // Stream generated from sine wave
18+
AudioKitStream out;
19+
EncodedAudioStream decoder(&out, new BinaryContainerDecoder()); // encode and write
20+
EncodedAudioStream encoder(&decoder, new BinaryContainerEncoder()); // encode and write
21+
StreamCopy copier(encoder, sound);
22+
23+
void setup() {
24+
Serial.begin(115200);
25+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
26+
27+
// start I2S
28+
Serial.println("starting I2S...");
29+
auto cfgi = out.defaultConfig(TX_MODE);
30+
cfgi.copyFrom(info);
31+
out.begin(cfgi);
32+
33+
// Setup sine wave
34+
sineWave.begin(info, N_B4);
35+
36+
// start decoder
37+
decoder.begin(info);
38+
39+
// start encoder
40+
encoder.begin(info);
41+
42+
Serial.println("Test started...");
43+
}
44+
45+
46+
void loop() {
47+
copier.copy();
48+
}

0 commit comments

Comments
 (0)