ESP32 Webradio

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: ESP32 Webradio

Postby BuddyCasino » Tue Jul 18, 2017 8:13 am

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?
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
Posts: 1
Joined: Mon Jul 17, 2017 10:32 pm

Re: ESP32 Webradio

Postby randy_house » Tue Jul 18, 2017 4:44 pm

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!

BuddyCasino wrote:
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?
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...

VijayThakkar
Posts: 1
Joined: Fri Aug 11, 2017 9:19 am

Re: ESP32 Webradio

Postby VijayThakkar » Fri Aug 11, 2017 9:25 am

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

Palak Joshi
Posts: 1
Joined: Fri Aug 11, 2017 9:15 am

Re: ESP32 Webradio

Postby Palak Joshi » Fri Aug 11, 2017 11:05 am

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.

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

Re: ESP32 Webradio

Postby pataga » Sat Aug 12, 2017 6:23 am

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.
buffer_underflow.jpg
buffer_underflow.jpg (315.75 KiB) Viewed 20809 times

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: ESP32 Webradio

Postby BuddyCasino » Sun Aug 13, 2017 8:23 pm

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.

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

Re: ESP32 Webradio

Postby pataga » Mon Aug 14, 2017 7:30 am

OK thanks BuddyCasino, will try this out.

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

Re: ESP32 Webradio

Postby pataga » Tue Aug 15, 2017 9:08 am

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];

BuddyCasino
Posts: 263
Joined: Sun Jun 19, 2016 12:00 am

Re: ESP32 Webradio

Postby BuddyCasino » Tue Aug 15, 2017 11:44 am

Thanks for the feedback, those look like useful modifications.

Saskia
Posts: 40
Joined: Mon Jun 26, 2017 11:45 am

Re: ESP32 Webradio

Postby Saskia » Fri Sep 22, 2017 8:31 am

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 14 guests