Commit Graph

15 Commits

Author SHA1 Message Date
Jeff Epler d67acb8a64 MP3Decoder: Fix playback stopping issue
Closes: #5164
2021-08-17 10:03:47 -05:00
Dan Halbert 33bbb8b1f4 RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Jeff Epler bdab6c12d4 MP3Decoder: take advantage of background callback
Before this, the mp3 file would be read into the in-memory buffer
only when new samples were actually needed.  This meant that the time
to read mp3 content always counted against the ~22ms audio buffer length.

Now, when there's at least 1 full disk block of free space in the input
buffer, we can request that the buffer be filled _after_ returning from
audiomp3_mp3file_get_buffer and actually filling the DMA pointers.  In
this way, the time taken for reading MP3 data from flash/SD is less
likely to cause an underrun of audio DMA.

The existing calls to fill the inbuf remain, but in most cases during
streaming these become no-ops because the buffer will be over half full.
2020-07-15 09:26:47 -05:00
Jeff Epler dd6010a17e Fix more build problems 2020-01-06 13:35:43 -06:00
Jeff Epler dc729718eb audiomp3: rename to MP3Decoder 2020-01-06 07:51:41 -06:00
Jeff Epler ec22520992 MP3File: Add rms_level property
This lets a music player show it vu-meter style
2020-01-02 15:23:42 -06:00
Jeff Epler 97bb46c047 MP3File: tweak buffer handling
After adding the ability to change files in an existing MP3File object,
it became apparent that at the beginning of a track some part of an
existing buffer was playing first.

I noticed that in get_buffer, the just-populated buffer wasn't being
returned, but the other one was.  But still after fixing this, I heard
wrong audio at the beginning of a track, so I took the heavy duty approach
and zeroed the buffers out.  That means there's a remaining bug to chase,
which is merely hidden by the memset()s.
2019-12-24 09:43:15 -06:00
Jeff Epler 00628a7ddd MP3File: whitespace 2019-12-23 09:36:50 -06:00
Jeff Epler 02154caf24 MP3File: Add a settable ".file" property
This enables jeplayer to allocate just one MP3File at startup, rather
than have to make repeated large allocations while the application is
running.

The buffers have to be allocated their theoretical maximum, but that
doesn't matter much as all the real-life MP3 files I checked needed
that much allocation anyway.
2019-12-23 09:36:46 -06:00
Jeff Epler 91a1706160 MP3: look harder for frame info
Apparently sometimes, a proper "frame info" block is not found after
a "sync word".  Keep looking for one as needed, instead of giving up
after one try.

This was one reason that the "bartlebeats" mp3s would not play.
2019-12-13 18:31:12 -06:00
Jeff Epler bf9b7e7ece MP3: skip ID3V2 metadata
This was one reason that the "bartlebeats" mp3s would not play.
2019-12-13 18:31:12 -06:00
Jeff Epler 1cdac3f16a MP3File: Fix stereo playback on samd AudioOut
There were several problems with the way this worked -- the read_count
approach was too complicated and I made a mistake "simplifying" it from
WaveFile.  And when the right channel was returned, it was off by 1 byte,
making it into static.

Instead, directly track which is the "other" channel that has data
available, and by using the right data type make the "+ channel"
arithmetic give the right result.

This requires a double cast (int16_t*)(void*) due to an alignment warning;
the alignment is now ensured manually, but the compiler doesn't make the
necessary inference that the low address bit must be clear.
2019-12-12 08:44:15 -06:00
Jeff Epler 8c841af946 MP3File: Avoid crash in get_buffer when deinitted
When a playing mp3 is deinitted, it's possible to reach get_buffer,
but all the internal pointers are NULL.  This would lead to a hard fault.
Avoid it by returning GET_BUFFER_ERROR instead.
2019-12-11 22:04:10 -06:00
Jeff Epler a08d9e6d8e audiocore: Add MP3File using Adafruit_MP3 library 2019-12-10 14:03:06 -06:00