snapshot
This commit is contained in:
@@ -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
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
|
||||
On the ESP32 the stereo output is on the Pins GPIO25 and GPIO26
|
||||
|
||||
| PIEZO | ESP32 | UNO R4 |
|
||||
| --------| -----------------|---------|
|
||||
| + | GPIO25 | A0 |
|
||||
| - | GND | GND |
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user