-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
streams-generator_inputmixer-audiokit.ino
46 lines (38 loc) · 1.33 KB
/
streams-generator_inputmixer-audiokit.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @file streams-generator_inputmixer-audiokit.ino
* @brief Tesing input mixer
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(32000, 2, 16);
SineWaveGenerator<int16_t> sineWave1(32000); // subclass of SoundGenerator with max amplitude of 32000
SineWaveGenerator<int16_t> sineWave2(32000); // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound1(sineWave1); // Stream generated from sine wave
GeneratedSoundStream<int16_t> sound2(sineWave2); // Stream generated from sine wave
InputMixer<int16_t> mixer;
AudioBoardStream out(AudioKitEs8388V1);
StreamCopy copier(out, mixer); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave1.begin(info, N_B4);
sineWave2.begin(info, N_E4);
mixer.add(sound1);
mixer.add(sound2);
mixer.begin(info);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}