loop from flash
loop from flash
I am trying to seamlessly loop a tone from flash.
I started from play_tone_mp3_example but I cannot get the tone to loop.
I made my own version of tone_stream.c and tried to reset the byte postition in the read function. But whatever I do, the stream stops after all bytes have been played. How can I start the stream from the beginning when it reaches the end?
Any hints or examples are highly appreciated
I started from play_tone_mp3_example but I cannot get the tone to loop.
I made my own version of tone_stream.c and tried to reset the byte postition in the read function. But whatever I do, the stream stops after all bytes have been played. How can I start the stream from the beginning when it reaches the end?
Any hints or examples are highly appreciated
Re: loop from flash
Hi audiophil.
It would help if you post the code you've changed. I just had a look, and was able to loop successfully by making this change:
Modify tone_stream.c at line 196, from:
to:
David.
It would help if you post the code you've changed. I just had a look, and was able to loop successfully by making this change:
Modify tone_stream.c at line 196, from:
Code: Select all
if (info.byte_pos + len > info.total_bytes) {
len = info.total_bytes - info.byte_pos;
}
Code: Select all
if (info.byte_pos == info.total_bytes) {
info.byte_pos = 0;
} else
if (info.byte_pos + len > info.total_bytes) {
len = info.total_bytes - info.byte_pos;
}
Re: loop from flash
Thank you very much, David, your answer worked for looping an mp3 file from flash. Unfortunately, it does not work to seamlessly loop the file. I tried to modify the example to work with a wav file and wav decoder. But the same code plays the wav file only once and produces the following output:
Furthermore, I don't understand why none of the LOGI statements I put in tone_stream.c cause an output (although changes to the code have an effect)
Code: Select all
I (416) MY_TONE_WAV_EXAMPLE: [3.1] Listening event from all elements of pipeline
I (426) MY_TONE_WAV_EXAMPLE: [ 4 ] Start audio_pipeline
E (426) AUDIO_ELEMENT: IN-[my_tone] AEL_STATUS_ERROR_INPUT
E (436) AUDIO_ELEMENT: [my_tone] ERROR_PROCESS, AEL_IO_FAIL
E (436) AUDIO_ELEMENT: [my_tone] AEL_MSG_CMD_ERROR
E (446) AUDIO_ELEMENT: [my_tone] AEL_MSG_CMD_ERROR
W (456) AUDIO_ELEMENT: IN-[wav] AEL_IO_ABORT
I (456) MY_TONE_WAV_EXAMPLE: [ 4 ] Listen for all pipeline events
W (486) MY_TONE_WAV_EXAMPLE: [ * ] Stop event received
I (486) MY_TONE_WAV_EXAMPLE: [ 5 ] Stop audio_pipeline
Re: loop from flash
Can you share the code changes you're making so I can have a look at what's happening?
Re: loop from flash
Changes I made in play_tone_mp3_example.c:
line 19: to
line 23-27:
to
because caused the build to fail
line 34:
to
line64:
to
line 68:
to
line 92:
to
line 95:
to
line 119:
to
line 131:
to
the changes I made in tone_stream.c are exactly as you suggested.
line 19:
Code: Select all
#include "mp3_decoder.h"
Code: Select all
#include "wav_decoder.h"
Code: Select all
#if __has_include("audio_tone_uri.h")
#include "audio_tone_uri.h"
#else
#error "please refer the README, and then make the tone file"
#endif
Code: Select all
#include "audio_tone_uri.h"
Code: Select all
#if __has_include("audio_tone_uri.h")
line 34:
Code: Select all
audio_element_handle_t tone_stream_reader, i2s_stream_writer, mp3_decoder;
Code: Select all
audio_element_handle_t tone_stream_reader, i2s_stream_writer, wav_decoder;
Code: Select all
audio_pipeline_register(pipeline, mp3_decoder, "mp3");
Code: Select all
audio_pipeline_register(pipeline, wav_decoder, "wav");
Code: Select all
audio_pipeline_link(pipeline, (const char *[]) {"tone", "mp3", "i2s"}, 3);
Code: Select all
audio_pipeline_link(pipeline, (const char *[]) {"tone", "wav", "i2s"}, 3);
Code: Select all
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) mp3_decoder
Code: Select all
if (msg.source_type == AUDIO_ELEMENT_TYPE_ELEMENT && msg.source == (void *) wav_decoder
Code: Select all
audio_element_getinfo(mp3_decoder, &music_info);
Code: Select all
audio_element_getinfo(wav_decoder, &music_info);
Code: Select all
audio_pipeline_unregister(pipeline, mp3_decoder);
Code: Select all
audio_pipeline_unregister(pipeline, wav_decoder);
Code: Select all
audio_element_deinit(mp3_decoder);
Code: Select all
audio_element_deinit(wav_decoder);
Re: loop from flash
Thanks. I'm not sure what's going on. It looks like the _flash_read is returning ESP_FAIL although I'm not sure as I would be expecting to see a log statement. Not sure why you don't see these.
If _flash_read fails, it _may_ be because you have problem with the generation of audio-esp.bin and the include file. But I can just speculate... Did you "make clean" and recompiled everything after these changes?
If _flash_read fails, it _may_ be because you have problem with the generation of audio-esp.bin and the include file. But I can just speculate... Did you "make clean" and recompiled everything after these changes?
Re: loop from flash
Thank you,
Yes, it's indeed strange that no log ouput is generated from that file. Do I need to setup the logging somehow? I tested another example and it seems like no LOG output is sent to the serial monitor from other files than the "main" c file.
I don't think that the generation of audio-esp fails because the tone plays fine once. Furthermore I tried another wav format (float instead of int16), which generated an error output that 32bit wav files would not not supported.
I cleaned the build several times but this did not help either.
Yes, it's indeed strange that no log ouput is generated from that file. Do I need to setup the logging somehow? I tested another example and it seems like no LOG output is sent to the serial monitor from other files than the "main" c file.
I don't think that the generation of audio-esp fails because the tone plays fine once. Furthermore I tried another wav format (float instead of int16), which generated an error output that 32bit wav files would not not supported.
I cleaned the build several times but this did not help either.
Who is online
Users browsing this forum: ESP_Sprite and 17 guests