Crackle at start and end of audio received from HTTP Get Request with I2SStream PAM8304 #1639
-
BriefI am currently trying to
Problems
HTTP and Speaker ConfigWiFiClient client;
HttpRequest http(client);
AnalogAudioStream audioOutput;
EncodedAudioStream decoder(&audioOutput, new MP3DecoderHelix());
StreamCopy copier(decoder, client); auto cfg = audioOutput.defaultConfig(TX_MODE);
audioOutput.begin(cfg);
decoder.begin(); Code Snippet (runs in loop())void loop()
{
boot_button.loop();
main_button.loop();
webSocket.loop();
switch (CURR_STATE)
{
case IDLE:
{
if(main_button.wasPressed())
{
switch(main_button.read())
{
case single_click:
{
CURR_STATE = USER_TALK;
}
break;
}
}
break;
}
case USER_TALK:
{
Serial.println("USER_TALK");
size_t bytesRead = conv.readBytes(audioData, BUFFER_SIZE);
if (bytesRead > 0) {
volumeScaler.convert(audioData, bytesRead);
webSocket.sendBIN(audioData, bytesRead);
}
disconnect_handler();
break;
}
case POLL_SERVER:
{
Serial.println("POLL_SERVER");
while(!http.processBegin(GET, url, nullptr, -1))
{
delay(20);
disconnect_handler();
}
while(!copier.available());
CURR_STATE = SERVER_TALK;
break;
}
case SERVER_TALK:
{
Serial.println("SERVER_TALK");
if(!copier.copy())
{
CURR_STATE = USER_TALK;
}
disconnect_handler();
break;
}
}
} Note: The switch between the cases is also handled externally. A websocket message from the server once received causes the switch. I get crackle at the start of audio and also whenever the copier ends in SERVER_TALK (due to copier.copy()! returning false or even the switch case changing). crackle_audio.mp4Note the single crackle at the start, and the multiple at the end. Originial audio file is here |
Beta Was this translation helpful? Give feedback.
Answered by
pschatzmann
Jul 29, 2024
Replies: 1 comment
-
Just read the Interactive Audio Wiki! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pschatzmann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just read the Interactive Audio Wiki!