Hey all, it's my first time posting on a forum like this so if I make any mistakes please let me know.
I have been working on a project which utilizes a XIAO ESP32S3, an Adafruit MAX9814 mic, and a PCM5102A DAC breakout board from HiLetGo. I am currently reading in the audio from the microphone with the ESP32 and then transmitting it through I2S to a pair of headphones using the DAC board. When I perform this with the current code I'm posting, the audio can be interpreted but sounds robotic and is of a higher pitch than my voice. When I change the I2S mode to I2S_LEFT_JUSTIFIED_MODE, the robotic element disappears but the pitch is still higher than normal. Please let me know if you have any thoughts or experience with an issue like this. Thank you!
Code below:
#include <Arduino.h>
#include <I2S.h>
const int micPin = A2;
int audio = 0;
int dualChannelAudio = 0;
void setup() {
Serial.begin(9600);
delay(10);
Serial.println("Hi!");
I2S.setAllPins(6,7,8,8,-1);
if(!I2S.begin(I2S_PHILIPS_MODE, 16000, 16)){
Serial.println("Didnt start");
}
}
void loop() {
audio = analogRead(micPin);
//dualChannelAudio = audio;
//dualChannelAudio = dualChannelAudio << 16;
//dualChannelAudio += audio;
audio *= 11;
//Serial.println(audio);
//I2S.write(dualChannelAudio);
I2S.write(audio);
}