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,25 @@
# I2S Analog Output Test
This is a simple basic test for the ESP32 __analog output__ using I2S.
We just send a generated sine wave and expect to hear a clean signal.
Please note the log level should be set so that there is no disturbing output!
### Output Device: Piezo Electric Element
To test the output I am using a piezo electric element
![DAC](https://pschatzmann.github.io/Resources/img/piezo.jpeg)
It should also be possible to connect a headphone to the output pins...
On the ESP32 the output is on the Pins GPIO26 and GPIO27
| PIEZO | ESP32
| --------| ---------------
| + | GPIO25 / GPIO26
| - | GND

View File

@@ -0,0 +1,41 @@
/**
* @file streams-generator_fromarray-analog.ino
* @author Phil Schatzmann
* @brief Example for GeneratorFromArray
* @version 0.1
* @date 2022-03-22
*
* @copyright Copyright (c) 2022
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
AudioInfo info(44100, 1, 16);
int16_t sine_array[] = {0, 4560, 9031, 13327, 17363, 21062, 24350, 27165, 29450, 31163, 32269, 32747, 32587, 31793, 30381, 28377, 25820, 22761, 19259, 15383, 11206, 6812, 2285, -2285, -6812, -11206, -15383, -19259, -22761, -25820, -28377, -30381, -31793, -32587, -32747, -32269, -31163, -29450, -27165, -24350, -21062, -17363, -13327, -9031, -4560 };
GeneratorFromArray<int16_t> sineWave(sine_array,0,false);
GeneratedSoundStream<int16_t> sound(sineWave); // Stream generated from sine wave
AnalogAudioStream out;
StreamCopy copier(out, sound); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave.begin(info);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}