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

|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user