Closed podaen closed 2 years ago
Here they go deeper in to the framesize
https://titanwolf.org/Network/Articles/Article?AID=25550046-6a8f-4386-90eb-a3098bb9ac8b
I will post all frame size of 1 folder with trouble
The framesize changes in one file form 1044 to 1045 to 1044 to ... if we go further in the file.
This is what I can tell you about framesizes. I hope it helps...
https://github.com/pschatzmann/arduino-libhelix/blob/main/src/MP3DecoderHelix.h
The decoder tries to find the next SynchWord in the stream. It usually struggles if it finds some metadata instead of audio, but it then just continues with the next frame...
It usually struggles if it finds some metadata instead
Those only occure in the beginning or the end of the file. It changes all over the file.
I have some data that can find precise the end and the bigining of the next frame.
Not sure if it helps but you can try to increase
On the first view I will say no, but I will try it and I let you know if ith helps.
Where do I need to decare it?
Ok. I found it at MP3DecoderHelix.h.
Not sure in what changing it... The frame size is 1045 or 1044 for those files and is less than the max frame size of 1600
Soo what I get is that you are looking for sync words to determ the beginning and end of the frame. but I get the message of invallid frame size a lot. Would it not be beter to calclulated the frame size like this
Frame Size = ( (Samples Per Frame / 8 * Bitrate) / Sampling Rate) + Padding Size
I am not sure - but maybe the issue is that you get an error message - because this also has a negiative impact. So maybe it just helps to prevent messages in libhelix
Than how could I prevent it?
I think you can add a
to your sketch
I had to added it to the helix_log.h to make it work. Still have that issue in the middle of a file.
in those message is was saying the framesize was 0 or -1. Can't miss a frame to play to song correctly I think... And that is what I am hearing, fast skipping forward. Other ideas?
hmmm, I tried this now and it's getting a lot beter now. Not sure why but it helps.
//#define MP3_MAX_OUTPUT_SIZE 1024 * 5
define MP3_MAX_OUTPUT_SIZE 2048 * 5
//#define MP3_MAX_FRAME_SIZE 1600
define MP3_MAX_FRAME_SIZE 3200
Thanks for doing this research! I made an internet radio receiver based on the icystream example from the audio-tools library. Worked great, except some stream URLs produced audio dropouts and invalid framesize warnings. I applied podean's changes to arduino-libhelix / src / MP3DecoderHelix.h and the problem was solved 100%. Maybe these could be the defaults in future releases? Or settable as decoder parameters in the main sketch?
I am a little bit reluctant to increase the default values because this increases the RAM use considerably. You can call the following methods in your sketch to increase these values:
I also updated the README to provide the related information...
Here is a working example of how to use the new setMaxPCMSize and setMaxFrameSize methods with a typical set of streams in arduino-audio-tools. I add it here because it took me awhile to figure out the syntax when libhelix is used within the EncodedAudioStream. I hope this is correct, and that it will help somebody. (It seems to work in my application).
The constructors: Streams: ICYstream "url" -> EncodedAudioStream "decMP3" -> VolumeStream "volume" -> I2SStream "i2s"
ICYStream url; // called without (ssid, password) because I already set up
I2SStream i2s;
MP3DecoderHelix mp3;
VolumeStream volume(i2s); // for volume control option
EncodedAudioStream decMP3(&volume, &mp3); // Decoding stream
StreamCopy copierMP3(decMP3, url); // copy mp3 url to decoder (and push updates to dependent streams)
The setup I only show the decoder setup here. Other streams are standard as per examples.
decMP3.begin(); // start decoder
mp3.setMaxPCMSize(2048 * 5); // default is 1024 * 5
mp3.setMaxFrameSize(3200); // default is 1600
As I was saying in audio tools I have some troubles with playing some files. Convert the doesn't solve the problem soo that's why I make topic here.
1) All those files have a low bitrate 2) I discoverd it is codec indipended. All those songs have an invalid frame size.
It is clear that framesize can be diffrent. I did a quick search and I found this...
http://blog.coryhill.net/2009/06/calculating-mp3-frame-length.html
They say that in reality framesize can be diffrent. What framesizes do you handle?