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.
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
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 :)