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,39 @@
# 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 to Warning so that there is no disturbing output!
Make sure that you do not use any noisy power supply!
### Output Device: Earphones
You can also use some simple earphones
![DAC](https://pschatzmann.github.io/Resources/img/earphones.jpg)
On the ESP32 the stereo output is on the Pins GPIO25 and GPIO26
| Earphone| ESP32 | UNO R4 |
| --------| -----------------|---------|
| Left | GPIO25 | A0 |
| Righ | GPIO25 | GND |
| GND | GND | GND |
### 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)
On the ESP32 the stereo output is on the Pins GPIO25 and GPIO26
| PIEZO | ESP32 | UNO R4 |
| --------| -----------------|---------|
| + | GPIO25 | A0 |
| - | GND | GND |

View File

@@ -0,0 +1,36 @@
/**
* @file streams-generator-analog.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-stream/streams-generator-analog/README.md
* @author Phil Schatzmann
* @copyright GPLv3
**/
#include "AudioTools.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
AnalogAudioStream out;
StreamCopy copier(out, sound); // copies sound into i2s
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start the analog output
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
out.begin(config);
// Setup sine wave
sineWave.begin(info, N_B4);
Serial.println("started...");
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}