How to use the AudioDriverES8311 to the fullest. #2252
-
|
For my combadge i just switched to the new M5stack Atom EchoS3R. #include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#define SDAPIN 45 // I2C Data, Adafruit ESP32 S3 3, Sparkfun Thing Plus C 23
#define SCLPIN 0 // I2C Clock, Adafruit ESP32 S3 4, Sparkfun Thing Plus C 22
#define I2CSPEED 100000 // Clock Rate
#define CODECADDR 0x18 // Address of ES8388 I2C port
// I2S, your configuration for the ES8388 board
#define MCLKPIN 11 // Master Clock
#define BCLKPIN 17 // Bit Clock
#define WSPIN 3 // Word select
#define DOPIN 48 // This is connected to DI on ES8388 (MISO)
#define DIPIN 4 // This is connected to DO on ES8388 (MOSI)
#define NS4150_CTR 18
AudioInfo info(16000, 1, 16);
SineWaveGenerator<int16_t> sineWave(32000); // subclass of SoundGenerator with max amplitude of 32000
DriverPins my_pins; // board pins
AudioBoard audio_board(AudioDriverES8311, my_pins); // audio board
I2SCodecStream out(audio_board); // i2s coded
TwoWire myWire = TwoWire(0); // universal I2C interface
RTTTLOutput<int16_t> rtttl(sineWave, out);
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
delay(5000);
my_pins.addI2C(PinFunction::CODEC, SCLPIN, SDAPIN, CODECADDR, I2CSPEED, myWire);
my_pins.addI2S(PinFunction::CODEC, MCLKPIN, BCLKPIN, WSPIN, DOPIN, DIPIN);
my_pins.addPin(PinFunction::PA, NS4150_CTR, PinLogic::Output);
my_pins.begin();
audio_board.begin();
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig();
config.copyFrom(info);
out.begin(config);
// Setup sine wave (optional)
sineWave.begin(info);
Serial.println("started...");
audio_board.setPAPower(true);
audio_board.setVolume(50);
}
// Arduino loop - copy sound to out
void loop() {
delay(1000);
rtttl.begin(info);
rtttl.print("ComplexDemo: d=8, o=5, b=95: c4 e g c6 ");
}
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Not sure: I suggest that you set the audio-driver library to debug mode. It might also be a good idea to define this device in the audio driver library. |
Beta Was this translation helpful? Give feedback.
-
|
Now that this part works, could you give me some hinds on creating a bidirectional setup using the above and the espnow configuration, I think i have slightly an idea on how define the pipelines, but how to no clue what to do to setup it so that we need to click the button to start sending audio and a second time stopping it again. I also saw somewhere on you repo's that you where working on a echo_canceling solution but now i cant figure out where i saw it. I like to test that as well in the near future. |
Beta Was this translation helpful? Give feedback.
Not sure: I suggest that you set the audio-driver library to debug mode.
It might also be a good idea to define this device in the audio driver library.