Lionel Ulmer wrote:
But when I look at the the time the frame will take to play : 1152 / 2 (stereo) / 2 (16 bit per sample) / 48000 = 0.006 ms
1152 is the number of samples from the frame, regardless of the number of channels or your output resolution. So, your calculation should be:
1152 / 48000 = 0.024 seconds
which agrees with your frame.header.duration. Incidentally, you should also find the sampling frequency (48000) in frame.header.samplerate (or synth.pcm.samplerate after synthesis).
By the way, out of curiosity, is the MP3 frame always the same size or can it be variable from stream to stream or even in a stream ? Is it possible to get the frame size without decoding a frame ?
If by frame size you mean number of bytes, it is not always the same size. It depends on the sampling frequency, the bitrate (which may be variable, i.e. change from frame to frame), and whether a "padding" slot is necessary to maintain a particular bitrate.
After calling mad_header_decode(), you can determine the frame size from:
stream.next_frame - stream.this_frame
Thanks for your explanation on the timers... I think you should add your post somewhere in the docs section of the source tree :-)
Yes, eventually I will have more complete documentation, but at least now the information is online in the mad-dev archive which was part of my purpose in posting it. :-)
Cheers, -rob