ESP32 Webradio
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
ESP32 Webradio
I was a big fan of Sprite_TMs https://github.com/espressif/ESP8266_MP3_DECODER project, and so I ported it to the ESP32.
Go and get it here:
https://github.com/MrBuddyCasino/ESP32_MP3_Decoder
I made a picture, but Github currently refuses to serve blobs it seems: https://github.com/MrBuddyCasino/ESP32_ ... wiring.jpg
Running it without the I2S codec doesn't currently work, patches welcome: https://github.com/MrBuddyCasino/ESP32_ ... r/issues/1
Go and get it here:
https://github.com/MrBuddyCasino/ESP32_MP3_Decoder
I made a picture, but Github currently refuses to serve blobs it seems: https://github.com/MrBuddyCasino/ESP32_ ... wiring.jpg
Running it without the I2S codec doesn't currently work, patches welcome: https://github.com/MrBuddyCasino/ESP32_ ... r/issues/1
Re: ESP32 Webradio
Interested in the i2s dac output resolution
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
The built-in one? It has only 8 Bit resolution, but still better than the ~5 Bit of hacked PWM of the ESP8266 predecessor project.
The hardware codec I used has... I don't know, 16 Bit?
The hardware codec I used has... I don't know, 16 Bit?
Re: ESP32 Webradio
Cool work done BuddyCasino
I cloned you code and had to disable last line in app_main.c
uxTaskGetStackHigh.... issued a core dump ...
I did a capture of the I2S output and the format looks like sweep music to me. Have a look:
I will try to get the i2s driver to do 32 bits - so it can play on my merus-audio amplifier.
I cloned you code and had to disable last line in app_main.c
Code: Select all
// init player
player = calloc(1, sizeof(Player));
player->state = PLAYER_STARTING;
ESP_LOGI(TAG, "RAM left %d", esp_get_free_heap_size());
// ESP_LOGI(TAG, "app_main stack: %d\n", uxTaskGetStackHighWaterMark(NULL));
I did a capture of the I2S output and the format looks like sweep music to me. Have a look:
I will try to get the i2s driver to do 32 bits - so it can play on my merus-audio amplifier.
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
Re: ESP32 Webradio
Still no good new for the i2s driver in 32 bit mode
I set the bit pr sample to 32 in the driver construct increased the buffer length by a factor 2.
The result is what I saw when playing with example 22_i2s
Every second left/right sample set is missing,
I tried to hard code the sample code that get pushed to
and this is what I get
some thing is miss aligned in the driver and after 30 sec I get a
/Jorgen
Code: Select all
int ret; ret = 0;
int i;
for (i=0; i < no_samples; i++) {
#if defined(USE_DAC)
short samp = mono_to_8bit_stereo(short_sample_buff[i]);
#else
int samp = mono_to_16bit_stereo(short_sample_buff[i]);
char samp2x32[8];
samp2x32[0] = 0;
samp2x32[1] = 0;
samp2x32[2] = 0;
samp2x32[3] = 0;
samp2x32[4] = 0xff;
samp2x32[5] = 0;
samp2x32[6] = 0;
samp2x32[7] = 0;
#endif
//Dependent on the amount of buffer we have too much or too little, we're going to add or remove
//samples. This basically does error diffusion on the sample added or removed.
if (sampErr>(1<<24)) {
sampErr-=(1<<24);
//...and don't output an i2s sample
} else if (sampErr<-(1<<24)) {
sampErr+=(1<<24);
//..and output 2 samples instead of one.
i2s_push_sample(I2S_NUM_0, (char *)&samp2x32, portMAX_DELAY);
i2s_push_sample(I2S_NUM_0, (char *)&samp2x32, portMAX_DELAY);
} else {
//Just output the sample.
ret = i2s_push_sample(I2S_NUM_0, (char *)&samp2x32, portMAX_DELAY);
}
}
printf("Number of char pushed:%d #samples:%d\n",ret,no_samples);
}
The result is what I saw when playing with example 22_i2s
Every second left/right sample set is missing,
I tried to hard code the sample code that get pushed to
Code: Select all
char samp2x32[8];
samp2x32[0] = 1;
samp2x32[1] = 3;
samp2x32[2] = 7;
samp2x32[3] = 0x0f;
samp2x32[4] = 0x1f;
samp2x32[5] = 0x3f;
samp2x32[6] = 0x7f;
samp2x32[7] = 0xff;
some thing is miss aligned in the driver and after 30 sec I get a
Code: Select all
I (38679) http_client: ... done reading from socket. Last read return=0 errno=128
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
Oops you're right, that only works if some freertos config option is changed in menuconfig. Fixed it.Jakobsen wrote: uxTaskGetStackHigh.... issued a core dump ...
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
Interesting - since I couldn't get it to work in 8-Bit mode either, maybe theres a bug in the driver somewhere?Jakobsen wrote:Still no good new for the i2s driver in 32 bit mode
If your HTTP connection gets dropped after some time, it can be a sign that you're reading too slowly and the server has to kick you out so you don't consume excessive amounts of buffer.
Re: ESP32 Webradio
YES - had to do a hack in the i2s driver
When I set the number of bits pr sample to 32, this call for 8 bytes pr sample when calling i2s_push_sample. This works for 16 bits pr sample where i2s_push_sample calls for 4 byte. So just for a try I hack the i2s in the 32 bit setting to only put 4 bits to the DMA buffer - And this look like nice music to me ......
It is 'only' 16 bits mono in both channels but that is the smalls web enable stack I have seen.
Here is the very dirty code:
I will connect to the amplifier we have build and post the results tomorrow
/jorgen
When I set the number of bits pr sample to 32, this call for 8 bytes pr sample when calling i2s_push_sample. This works for 16 bits pr sample where i2s_push_sample calls for 4 byte. So just for a try I hack the i2s in the 32 bit setting to only put 4 bits to the DMA buffer - And this look like nice music to me ......
It is 'only' 16 bits mono in both channels but that is the smalls web enable stack I have seen.
Here is the very dirty code:
Code: Select all
data_ptr = (char*)p_i2s_obj[i2s_num]->tx->curr_ptr;
data_ptr += p_i2s_obj[i2s_num]->tx->rw_pos;
for (i = 0; i < p_i2s_obj[i2s_num]->bytes_per_sample; i++) {
*data_ptr++ = *sample++;
bytes_to_push ++;
}
if (p_i2s_obj[i2s_num]->channel_num == 3) { <--------------------------odd number of channels :-)
for (i = 0; i < p_i2s_obj[i2s_num]->bytes_per_sample; i++) {
*data_ptr++ = *sample++;
bytes_to_push ++;
}
}
p_i2s_obj[i2s_num]->tx->rw_pos += p_i2s_obj[i2s_num]->bytes_per_sample; // * p_i2s_obj[i2s_num]->channel_num;
return bytes_to_push;
}
I will connect to the amplifier we have build and post the results tomorrow
/jorgen
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
-
- Posts: 263
- Joined: Sun Jun 19, 2016 12:00 am
Re: ESP32 Webradio
Not sure I understood what you did there, but I'll have a closer look this evening.
Who is online
Users browsing this forum: No registered users and 9 guests