41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
/**
|
|
* @file AudioMini.ino
|
|
* See https://github.com/sonocotta/esp32-audio-development-kit
|
|
* @author Phil Schatzmann
|
|
* @copyright GPLv3
|
|
*/
|
|
|
|
#include "AudioTools.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;
|
|
StreamCopy copier(out, sound); // copies sound into i2s
|
|
|
|
// Arduino Setup
|
|
void setup(void) {
|
|
// Open Serial
|
|
Serial.begin(115200);
|
|
while(!Serial);
|
|
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
|
|
|
|
// start I2S
|
|
Serial.println("starting I2S...");
|
|
auto config = out.defaultConfig(TX_MODE);
|
|
config.copyFrom(info);
|
|
// Custom I2S output pins
|
|
config.pin_bck = 26;
|
|
config.pin_ws = 25;
|
|
config.pin_data = 22;
|
|
out.begin(config);
|
|
|
|
// Setup sine wave
|
|
sineWave.begin(info, N_B4);
|
|
Serial.println("started...");
|
|
}
|
|
|
|
// Arduino loop - copy sound to out
|
|
void loop() {
|
|
copier.copy();
|
|
} |