Yeah thats tricky. I'll try to upload it to Github this week. My decision to implement some required Alexa webservices in Rust delayed things a little...randy_house wrote: I actually have a question regarding how you use `nghttp2` to do multipart HTTP/2 POST request. Do you simply use `nghttp2_submit_request` to send your request? How do you combine the Json and Audio into one request?
ESP32 Webradio
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
-
- Posts: 1
- Joined: Mon Jul 17, 2017 10:32 pm
Re: ESP32 Webradio
Dear Buddy Casino
It is great to hear back from you. I am looking forward to your post on Github. Currently, I have figured out the connections and the down channel, I am stuck on making the actual request (to be more specific, I am stuck on the part where you put Json + Audio onto a multi-part Http2 message, using `nghttp2`). Thanks for replying to my message!
It is great to hear back from you. I am looking forward to your post on Github. Currently, I have figured out the connections and the down channel, I am stuck on making the actual request (to be more specific, I am stuck on the part where you put Json + Audio onto a multi-part Http2 message, using `nghttp2`). Thanks for replying to my message!
BuddyCasino wrote:Yeah thats tricky. I'll try to upload it to Github this week. My decision to implement some required Alexa webservices in Rust delayed things a little...randy_house wrote: I actually have a question regarding how you use `nghttp2` to do multipart HTTP/2 POST request. Do you simply use `nghttp2_submit_request` to send your request? How do you combine the Json and Audio into one request?
-
- Posts: 1
- Joined: Fri Aug 11, 2017 9:19 am
Re: ESP32 Webradio
Hi Buddy Casino,
I am also facing connection issue with Alexa using nghttp2 + mbedTLS.
It would be grateful if you share working code on GitHub.
Thanks in Advance.
Regards,
Vijay
I am also facing connection issue with Alexa using nghttp2 + mbedTLS.
It would be grateful if you share working code on GitHub.
Thanks in Advance.
Regards,
Vijay
-
- Posts: 1
- Joined: Fri Aug 11, 2017 9:15 am
Re: ESP32 Webradio
Hi,
I am also using the nghttp2 library to format the multipart frames to communicate with Alexa. I am currently able to get the response of audio with a multipart message. But, currently it is only possible to send data up to 16KB, I want to do streaming of my recorded data which can be greater than 16KB as a whole.
Can you please help me in sending the audio data in the chunk to the AVS using nghttp2?
Looking forward to your response, please help.
Thanks.
I am also using the nghttp2 library to format the multipart frames to communicate with Alexa. I am currently able to get the response of audio with a multipart message. But, currently it is only possible to send data up to 16KB, I want to do streaming of my recorded data which can be greater than 16KB as a whole.
Can you please help me in sending the audio data in the chunk to the AVS using nghttp2?
Looking forward to your response, please help.
Thanks.
Re: ESP32 Webradio
BuddyCasino, apologies if this is a digression from the current discussions, but you had mentioned potential optimizations for the case where there is a high latency connection. I am using a 4G hotspot at home for my internet connection and normally have no buffering issues with standard def youtube videos.
But I have consistent buffer underflow problems running the webradio. If I switch to the next radio channel, it starts up again, but within a few seconds, the buffer underflow issue starts again. See attached monitor screenshot which captures this scenario.
Am a noob when it comes to this area, but any chance you can let me know where to look and what tweaks might help with this ?
Hardware set up is an Easykit ESP32-B1 (Chip Rev 0 ) connected to a "DIY More" PCM5102A module. The only modification i made to your code was to configure the I2S signals on different pins for a shortest-path connection to the PCM5102 board. Stereo audio quality is quite good on headphones.
But I have consistent buffer underflow problems running the webradio. If I switch to the next radio channel, it starts up again, but within a few seconds, the buffer underflow issue starts again. See attached monitor screenshot which captures this scenario.
Am a noob when it comes to this area, but any chance you can let me know where to look and what tweaks might help with this ?
Hardware set up is an Easykit ESP32-B1 (Chip Rev 0 ) connected to a "DIY More" PCM5102A module. The only modification i made to your code was to configure the I2S signals on different pins for a shortest-path connection to the PCM5102 board. Stereo audio quality is quite good on headphones.
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
Yeah I've got a feeling this used to work better. Try:
- check freertos task priorities
- check wifi connection quality (RSSI)
You can increase the network buffer if you don't care about AAC.
- check freertos task priorities
- check wifi connection quality (RSSI)
You can increase the network buffer if you don't care about AAC.
Re: ESP32 Webradio
OK thanks BuddyCasino, will try this out.
Re: ESP32 Webradio
Hi BuddyCasino, I tried tweaking task priorities, increasing dummy spiram fifo size, increasing the number of Wifi RX buffers etc. None of them worked, but the following trial and error hack seems to have mitigated the buffer under flow problem for me :
\audio_player\audio_player.c
uint8_t fill_level = (bytes_in_buf * 100) / spiRamFifoLen();
// seems 4k is enough to prevent initial buffer underflow
// me : 20% of 32k = 6k, comment needs fixing ?
uint8_t min_fill_lvl = player->buffer_pref == BUF_PREF_FAST ? 20 : 90;
bool enough_buffer = fill_level > min_fill_lvl;
//bool early_start = (bytes_in_buf > 1028 && player->media_stream->eof);
bool early_start = ((bytes_in_buf > (3*1028)) && player->media_stream->eof);
if (player->decoder_status != RUNNING && (enough_buffer || early_start)) {
Doubling the value of early_start seemed to have worked, but after a few minutes, could detect some stuttering. Tripling it was even better. Can now run several minutes without any choppiness, and any stuttering goes away within a few seconds. Before, it would never recover once the buffer underflow started.
I did find something that I thought may be inconsistent in \fifo\spiram_fifo.c. The fifo lowmark (112*1024) is defined as a value larger than the fifo size (32000). I modified it to be half of the fifo size (not sure what is appropriate). Though just this change alone without the change to audio_player.c did not fix the buffer underflow issue.
//#define FIFO_LOWMARK (112*1024)
#define FIFO_LOWMARK (16*1024)
#ifdef FAKE_SPI_BUFF
//Re-define a bunch of things so we use the internal buffer
#undef SPIRAMSIZE
//allocate enough for about one mp3 frame
//#define SPIRAMSIZE 1850
#define SPIRAMSIZE 32000
static char fakespiram[SPIRAMSIZE];
\audio_player\audio_player.c
uint8_t fill_level = (bytes_in_buf * 100) / spiRamFifoLen();
// seems 4k is enough to prevent initial buffer underflow
// me : 20% of 32k = 6k, comment needs fixing ?
uint8_t min_fill_lvl = player->buffer_pref == BUF_PREF_FAST ? 20 : 90;
bool enough_buffer = fill_level > min_fill_lvl;
//bool early_start = (bytes_in_buf > 1028 && player->media_stream->eof);
bool early_start = ((bytes_in_buf > (3*1028)) && player->media_stream->eof);
if (player->decoder_status != RUNNING && (enough_buffer || early_start)) {
Doubling the value of early_start seemed to have worked, but after a few minutes, could detect some stuttering. Tripling it was even better. Can now run several minutes without any choppiness, and any stuttering goes away within a few seconds. Before, it would never recover once the buffer underflow started.
I did find something that I thought may be inconsistent in \fifo\spiram_fifo.c. The fifo lowmark (112*1024) is defined as a value larger than the fifo size (32000). I modified it to be half of the fifo size (not sure what is appropriate). Though just this change alone without the change to audio_player.c did not fix the buffer underflow issue.
//#define FIFO_LOWMARK (112*1024)
#define FIFO_LOWMARK (16*1024)
#ifdef FAKE_SPI_BUFF
//Re-define a bunch of things so we use the internal buffer
#undef SPIRAMSIZE
//allocate enough for about one mp3 frame
//#define SPIRAMSIZE 1850
#define SPIRAMSIZE 32000
static char fakespiram[SPIRAMSIZE];
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
Thanks for the feedback, those look like useful modifications.
Re: ESP32 Webradio
Youj implemented a Bluetooth Speaker Mode. Is this for sending audio data to the esp32, so the esp32 is used as a bluetooth speaker or is it also possible to send the audio data from the esp32 to a bluetooth speaker? Last one would be great.
Who is online
Users browsing this forum: No registered users and 16 guests