As seen in issue #21, the MP3 decoder would barf on a single lost sync
error, even though it was not actually a fatel error.
Rewrote the logic to include another Input() on DNF failure, and only die
when Input() actually fails. Seems to fix the problem in issue #21 and also
did not break the WebRadio.
DecodeNextFrame had a leftover while(1) in the inner loop without any
additional Input() calls, which could lead to an infinite loop on an
error condition. Remove that unneeded loop. Addresses some of the
stuff found in issue #21
All objects can have a metadata and/or status report callback once created.
They will call the source program with the parsed ID3 tag, ICY StreamTitle,
or text and numeric error ID of any interesting event. It is up to the end
application to figure out what to do with this. Normally, you'd just print
it to the LCD or Serial port. But it is possible to detect, say, a buffer
overflow and then switch to a lower bitrate stream for example.
Adds a virtual loop() method to the file input and audio output objects.
By default does nothing, but it can be used to prefill buffers/etc. in the
case of a buffered input, or to update a volume meter on an output, etc.
The AudioGenerators all now call it as part of their own loop()s, so there
is no user intervention required to make it work.
Thanks to @armSeb for the idea with his SPI RAM code.
MP3 maximum frame size of 1441 bytes, and now that there is a real
buffering class available it makes no sense to include additional space
in ths decoder. Reduce to the minimum to save memory in default case.
Fixes issue #5 about choppy audio on low bitrate, mono MP3s.
The number of 32-sample elements to generate per MP3 data frame was
set to 36 as that was what I saw on all my source files. However, on
mono files only half the number of samples are to be generated and
you'd end up with the synthesizer bands running out of energy and
have periods of 0-samples between proper data.
Now simply check each decoded frame for the proper NSMAX value and
only generate that many. Tested on force.mp3 in the issue referenced.