[Lazarus] Update sound shop my next tutoring project

José Mejuto joshyfun at gmail.com
Thu May 16 02:13:23 CEST 2019


El 15/05/2019 a las 20:35, Anthony Walter via lazarus escribió:
> I just looked at you MP3 decoder source. It looks like it mimics the 
> mpg123 API which is perfect. The only question I have is what is the 
> best way to seek to a time in an MP3 memory buffer for use with 
> your pdmp3_feed and pdmp3_read functions? I don't want to decode whole 
> MP3 streams into PCM wave data, rather I want to be able to do random 
> moves using pointer given a time offset from the start of the MP3 sample 
> data and decode a small portion.
> 

Hello,

To perform random seek in mp3 streams you must process each header in 
the mp3 file and take note where each header start, so create some kind 
of index file. For mp3 in CBR mode you can calculate skips as each frame 
is constant in size, but in VBR you must create the index, the big 
problem is that to know if an mp3 is VBR or CBR you must read all 
headers :-( Some extensions in ID3 tags store the index for headers, 
others in ancillary data.

To decode after seek you must skip back 9 frames (if available), start 
to decode and discard the sound associated with that 9 frames, and the 
continue decoding and using data. The reason is that mp3 frames can 
share data using "byte reservoir" fields across up to 9 frames and if 
you do not discard that sound you are in risk of start the play with 
some nice bleeps, blurps, shrrrss, or any other non expected sound.

-- 



More information about the lazarus mailing list