PDA

View Full Version : gapless playback with mp3 - another shot



Familie Tromp
2005-03-11, 01:26
Hello Phil,

Information about amount of frames etc. is found on the following
site. It says too that frames are added at the end AND the beginning
of each mp3 file.

http://lame.sourceforge.net/tech-FAQ.txt


"3. Why does LAME add silence to the end of each song?

Extra padding at the end of a file can be caused by a couple of things:

1. Because the MDCT's are overlapped, it looks something like this:

<--576 MDCT coefficients--><--576 MDCT coefficients--><--576 MDCT
coefficients-->
<-- 576 samples PCM output --><-- 576 samples PCM output -->

So no matter where you truncate your MP3 file, the last 288 samples of
that granule will not be decoded. So LAME appends 288 samples of
padding to the input file to guarantee all input samples will be
decoded.


2. If the number of samples is not an exact multiple of 1152,
then last frame of data is padded with 0's so that it has 1152
samples.


Before lame3.56, we just added a few extra frames to make sure all
internal buffers would be flushed. In lame3.56, we tried to pad
with the exact minimum number of samples needed. And in lame3.80,
we finally fixed the bitstream flushing so that the final mp3
frame is properly padded with ancillary data. "


Regards,

Karel Tromp


<reaction Phil Karn>
Ah, I see. And I take it there's no field in the header that tells you
how many audio samples are *really* in the track? If you had that, then
you could just pad out the data during encode, and discard extra samples
during decode.

What is the size quanta, i.e., how much padding can be needed, worst
case?

vidurapparao
2005-03-11, 08:27
It seems like the LAME INFO tag (described at
http://gabriel.mp3-tech.org/mp3infotag.html) does include the number of
padding samples. Bugs 1026 and 838 (they should probably be DUPed) cover
this issue. I think it's a fixable problem for Squeezebox2...possibly
not for initial launch, but shortly thereafter.

--Vidur

Familie Tromp wrote:

> Hello Phil,
>
> Information about amount of frames etc. is found on the following
> site. It says too that frames are added at the end AND the beginning
> of each mp3 file.
>
> http://lame.sourceforge.net/tech-FAQ.txt
>
>
> "3. Why does LAME add silence to the end of each song?
>
> Extra padding at the end of a file can be caused by a couple of things:
>
> 1. Because the MDCT's are overlapped, it looks something like this:
>
> <--576 MDCT coefficients--><--576 MDCT coefficients--><--576 MDCT
> coefficients-->
> <-- 576 samples PCM output --><-- 576 samples PCM output -->
>
> So no matter where you truncate your MP3 file, the last 288 samples of
> that granule will not be decoded. So LAME appends 288 samples of
> padding to the input file to guarantee all input samples will be
> decoded.
>
>
> 2. If the number of samples is not an exact multiple of 1152,
> then last frame of data is padded with 0's so that it has 1152
> samples.
>
>
> Before lame3.56, we just added a few extra frames to make sure all
> internal buffers would be flushed. In lame3.56, we tried to pad
> with the exact minimum number of samples needed. And in lame3.80,
> we finally fixed the bitstream flushing so that the final mp3
> frame is properly padded with ancillary data. "
>
>
> Regards,
>
> Karel Tromp
>
>
> <reaction Phil Karn>
> Ah, I see. And I take it there's no field in the header that tells you
> how many audio samples are *really* in the track? If you had that, then
> you could just pad out the data during encode, and discard extra samples
> during decode.
>
> What is the size quanta, i.e., how much padding can be needed, worst
> case?
>

Karel Tromp
2005-03-12, 05:04
As an proud owner of the SB1: would it be difficult to implement it on
the SB1 or solve it in Slimserver?

Karel


On Fri, 11 Mar 2005 07:27:51 -0800, Vidur Apparao <vidur (AT) slimdevices (DOT) com> wrote:
>
> It seems like the LAME INFO tag (described at
> http://gabriel.mp3-tech.org/mp3infotag.html) does include the number of
> padding samples. Bugs 1026 and 838 (they should probably be DUPed) cover
> this issue. I think it's a fixable problem for Squeezebox2...possibly
> not for initial launch, but shortly thereafter.
>
> --Vidur
>
> Familie Tromp wrote:
>
> > Hello Phil,
> >
> > Information about amount of frames etc. is found on the following
> > site. It says too that frames are added at the end AND the beginning
> > of each mp3 file.
> >
> > http://lame.sourceforge.net/tech-FAQ.txt
> >
> >
> > "3. Why does LAME add silence to the end of each song?
> >
> > Extra padding at the end of a file can be caused by a couple of things:
> >
> > 1. Because the MDCT's are overlapped, it looks something like this:
> >
> > <--576 MDCT coefficients--><--576 MDCT coefficients--><--576 MDCT
> > coefficients-->
> > <-- 576 samples PCM output --><-- 576 samples PCM output -->
> >
> > So no matter where you truncate your MP3 file, the last 288 samples of
> > that granule will not be decoded. So LAME appends 288 samples of
> > padding to the input file to guarantee all input samples will be
> > decoded.
> >
> >
> > 2. If the number of samples is not an exact multiple of 1152,
> > then last frame of data is padded with 0's so that it has 1152
> > samples.
> >
> >
> > Before lame3.56, we just added a few extra frames to make sure all
> > internal buffers would be flushed. In lame3.56, we tried to pad
> > with the exact minimum number of samples needed. And in lame3.80,
> > we finally fixed the bitstream flushing so that the final mp3
> > frame is properly padded with ancillary data. "
> >
> >
> > Regards,
> >
> > Karel Tromp
> >
> >
> > <reaction Phil Karn>
> > Ah, I see. And I take it there's no field in the header that tells you
> > how many audio samples are *really* in the track? If you had that, then
> > you could just pad out the data during encode, and discard extra samples
> > during decode.
> >
> > What is the size quanta, i.e., how much padding can be needed, worst
> > case?
> >

Karel Tromp
2005-03-15, 12:48
<kick>


On Sat, 12 Mar 2005 13:04:57 +0100, Karel Tromp <slimkarel (AT) gmail (DOT) com> wrote:
> As an proud owner of the SB1: would it be difficult to implement it on
> the SB1 or solve it in Slimserver?
>
> Karel
>
>
> On Fri, 11 Mar 2005 07:27:51 -0800, Vidur Apparao <vidur (AT) slimdevices (DOT) com> wrote:
> >
> > It seems like the LAME INFO tag (described at
> > http://gabriel.mp3-tech.org/mp3infotag.html) does include the number of
> > padding samples. Bugs 1026 and 838 (they should probably be DUPed) cover
> > this issue. I think it's a fixable problem for Squeezebox2...possibly
> > not for initial launch, but shortly thereafter.
> >
> > --Vidur
> >
> > Familie Tromp wrote:
> >
> > > Hello Phil,
> > >
> > > Information about amount of frames etc. is found on the following
> > > site. It says too that frames are added at the end AND the beginning
> > > of each mp3 file.
> > >
> > > http://lame.sourceforge.net/tech-FAQ.txt
> > >
> > >
> > > "3. Why does LAME add silence to the end of each song?
> > >
> > > Extra padding at the end of a file can be caused by a couple of things:
> > >
> > > 1. Because the MDCT's are overlapped, it looks something like this:
> > >
> > > <--576 MDCT coefficients--><--576 MDCT coefficients--><--576 MDCT
> > > coefficients-->
> > > <-- 576 samples PCM output --><-- 576 samples PCM output -->
> > >
> > > So no matter where you truncate your MP3 file, the last 288 samples of
> > > that granule will not be decoded. So LAME appends 288 samples of
> > > padding to the input file to guarantee all input samples will be
> > > decoded.
> > >
> > >
> > > 2. If the number of samples is not an exact multiple of 1152,
> > > then last frame of data is padded with 0's so that it has 1152
> > > samples.
> > >
> > >
> > > Before lame3.56, we just added a few extra frames to make sure all
> > > internal buffers would be flushed. In lame3.56, we tried to pad
> > > with the exact minimum number of samples needed. And in lame3.80,
> > > we finally fixed the bitstream flushing so that the final mp3
> > > frame is properly padded with ancillary data. "
> > >
> > >
> > > Regards,
> > >
> > > Karel Tromp
> > >
> > >
> > > <reaction Phil Karn>
> > > Ah, I see. And I take it there's no field in the header that tells you
> > > how many audio samples are *really* in the track? If you had that, then
> > > you could just pad out the data during encode, and discard extra samples
> > > during decode.
> > >
> > > What is the size quanta, i.e., how much padding can be needed, worst
> > > case?
> > >

Jason Holtzapple
2005-03-15, 13:00
Is there any particular reason you can't use a CD-length mp3 file +
cuesheet? I've been using these since the beginning* to get gapless
playback on slimp3 & squeezebox.

* 2002

Karel Tromp
2005-03-15, 14:58
I have now app. 7500 mp3 files/tracks. Following your procedure I have
to re-encode all of my cd's or glue-ing them together with audacity or
some other program. Besides that, I just want to choose tracks from a
album to make mp3-cd's for use in vacation. Therefore I think ripping
entire albums into one single mp3 is no option.

Karel


On Tue, 15 Mar 2005 13:00:38 -0700, Jason Holtzapple
<jasonholtzapple (AT) yahoo (DOT) com> wrote:
> Is there any particular reason you can't use a CD-length mp3 file +
> cuesheet? I've been using these since the beginning* to get gapless
> playback on slimp3 & squeezebox.
>
> * 2002
>

Jason Holtzapple
2005-03-15, 15:23
Karel Tromp wrote:
> I have now app. 7500 mp3 files/tracks. Following your procedure I have
> to re-encode all of my cd's or glue-ing them together with audacity or
> some other program. Besides that, I just want to choose tracks from a
> album to make mp3-cd's for use in vacation. Therefore I think ripping
> entire albums into one single mp3 is no option.

Still, if you access to a Windows machine, I'd consider ripping new
albums this way. It's rather easy to make a mix from cuesheet'd
albums with Foobar2000, for example, and burn the resulting wavs with
any burning program. Similar programs might exist on other platforms.

> On Tue, 15 Mar 2005 13:00:38 -0700, Jason Holtzapple
> <jasonholtzapple (AT) yahoo (DOT) com> wrote:
>
>>Is there any particular reason you can't use a CD-length mp3 file +
>>cuesheet? I've been using these since the beginning* to get gapless
>>playback on slimp3 & squeezebox.
>>
>>* 2002

Karel Tromp
2005-03-15, 15:40
You're right when I want to produce mixed cd's (wav). I use foobar for
managing my mp3 files. Can I use it too for burning mp3 cd's (with the
cue-sheet you mentioned?)


On Tue, 15 Mar 2005 15:23:45 -0700, Jason Holtzapple
<jasonholtzapple (AT) yahoo (DOT) com> wrote:
> Karel Tromp wrote:
> > I have now app. 7500 mp3 files/tracks. Following your procedure I have
> > to re-encode all of my cd's or glue-ing them together with audacity or
> > some other program. Besides that, I just want to choose tracks from a
> > album to make mp3-cd's for use in vacation. Therefore I think ripping
> > entire albums into one single mp3 is no option.
>
> Still, if you access to a Windows machine, I'd consider ripping new
> albums this way. It's rather easy to make a mix from cuesheet'd
> albums with Foobar2000, for example, and burn the resulting wavs with
> any burning program. Similar programs might exist on other platforms.
>
> > On Tue, 15 Mar 2005 13:00:38 -0700, Jason Holtzapple
> > <jasonholtzapple (AT) yahoo (DOT) com> wrote:
> >
> >>Is there any particular reason you can't use a CD-length mp3 file +
> >>cuesheet? I've been using these since the beginning* to get gapless
> >>playback on slimp3 & squeezebox.
> >>
> >>* 2002
>

Jason Holtzapple
2005-03-15, 15:51
Karel Tromp wrote:
> You're right when I want to produce mixed cd's (wav). I use foobar for
> managing my mp3 files. Can I use it too for burning mp3 cd's (with the
> cue-sheet you mentioned?)

I'm not sure - I've never used foobar for this purpose. However I have
used mp3directcut to cut tracks directly from an album length mp3 to
individual mp3 files.

Karel Tromp
2005-03-15, 15:58
OK, I shall give it a try and encode something. BTW I use EAC for
encoding, I think it's covered there.

Karel


On Tue, 15 Mar 2005 15:51:23 -0700, Jason Holtzapple
<jasonholtzapple (AT) yahoo (DOT) com> wrote:
> Karel Tromp wrote:
> > You're right when I want to produce mixed cd's (wav). I use foobar for
> > managing my mp3 files. Can I use it too for burning mp3 cd's (with the
> > cue-sheet you mentioned?)
>
> I'm not sure - I've never used foobar for this purpose. However I have
> used mp3directcut to cut tracks directly from an album length mp3 to
> individual mp3 files.
>