Hacker News new | ask | show | jobs
by av500 2440 days ago
not in code, but I think I answered a few questions. there was also the fact that another MP3 player I was involved in, the Terratec M3PO had a feature to change the MP3 playback speed and the Rockbox people wondered for years how we did that on the limited DSP that it had (same as on Archos products) - took them a long time and some hints to figure out :)
1 comments

Can you tell us how you managed this now, or are you not technically allowed to even today?
probably custom code for the MAS DSP.
nope, the MAS had MP3 decode fixed in ROM and while you could upload your own algo into the RAM and run it, that meant no MP3 decode at the same time :)
So how exactly did you do it? You can't leave me hanging now.
MPEG layer 3 (MP3) differs from layers 1 and 2 in the fact that the frame data for a given audio frame can be spread out over several consecutive MP3 frames, that makes the stream effectively VBR (variable bitrate) even if the total bitrate is fixed at e.g. 128kbit/s. due to that you cannot simply cut at MP3 frame boundaries.

I wrote code to on-the-fly and in-memory convert a fixed bitrate MP3 stream into a variable bitrate one with differing frame length for each frame, adding padding data if needed to adhere to the allowed standard frame sizes. Once I had that I could drop or repeat MP3 frames, thus making the music play faster or slower. Since the reconstruction filters in MP3 decoder where already working across frame boundaries, they would also help to smooth over the artificial transitions introduced by this.

This works nicely up to a speed change of +/- 10%, going much slower would e.g. noticeably double snare drum hits or other percussive sounds.

of course you can also reassemble the frames in reverse order, I have a prototype MP3 "DJ" player where you can use a jog wheel to scrub forwards and backwards through an MP3 file without decoding it.

there, my secret is out :)

wow, really interesting
BTW, the original motivation to write that code was a bug in an early version of the DSP chip, it would produce a loud "click" each time the MP3 data stream stopped or started. so instead of stopping the stream I would either play a file (processed as per above) or if stopped or paused repeately insert a frame of "silence" that I encoded for every possible sampling frequency. luckily total silence is a really short frame to store