Hi, i?m not part of the FLAC project, but i have a question regarding FLAC and Gapless support I hope, I get an answer from some of you ;-) We are currently try to add Gapless support on our device If we rip an CD with our device, we can find out, that one track follow after another so we can recognize, that the tracks are gapless or not. But how can we find that out on already existing FLAC files (or other formats). Is there a marker inside the file, who tell me, that this File is a gapless file? Also gapless make only sense, if you have the follow up file also Example: CD Track 1 not gapless Track2 Gapless Track 3 Gapless Track 4 not gapless If I rip now all 4 titles and play them later the player must know, that Song 1 is not gapless but Song2 and 3 ?Fit? together. What will happen, if I delete Song3 . Is the player playing now from Song2 to Song4 gapless, which is not correct Anybody a good description for me, how this is solved on FLAC? Best regards/Mit freundlichen Gr??en Richard Sch?lein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20120117/457f932f/attachment.htm
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17.01.2012 12:44, Richard Sch?lein wrote:> Hi, > > > > i?m not part of the FLAC project, but i have a question regarding > FLAC and Gapless support? I hope, I get an answer from some of you > ;-) > > We are currently try to add Gapless support on our device? If we > rip an CD with our device, we can find out, that one track follow > after another so we can > > recognize, that the tracks are gapless or not. > > But how can we find that out on already existing FLAC files (or > other formats). Is there a marker inside the file, who tell me, > that this > > File is a gapless file? Also gapless make only sense, if you have > the follow up file also? > > > > Example: > > > > CD > > Track 1 not gapless > > Track2 Gapless > > Track 3 Gapless > > Track 4 not gapless > > > > If I rip now all 4 titles and play them later the player must know, > that Song 1 is not gapless but Song2 and 3 ?Fit? together. > > What will happen, if I delete Song3?. Is the player playing now > from Song2 to Song4 gapless, which is not correct? > > > > Anybody a good description for me, how this is solved on FLAC? > >AFAIK, gaplessness is the sole responsibility of the player. How do you know *at all* that tracks 1 and 4 on that CD are not gapless, but tracks 2 and 3 are? Anyway, no matter where you get that info from, you can put arbitrary metadata into FLAC files, including the information you need for gaplessness. Also note that many players support gapless playback. For audio files that do not fit together it doesn't make a difference: one file ends in a definitive fashion, then another one begins. Doesn't matter whether they are played gaplessly or not. When files fit together, gaplessness becomes apparent (if implemented). So most players usually do gaplessness regardless. Of course, if you remove "Track 3" in your example and try to play Track 4 after Track 2, gaplessness won't help. But then again, it's not FLAC's problem, it's the problem of the user removing 3rd track, and/or of the player not recognizing that tracks 2 and 4 don't fit (and even if player does recognize that - what would it do? Skip Track 2?). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPKvMNAAoJEOs4Jb6SI2CwP1sIAKtT2ar1dtlhMIaj8ufOEHM6 I9lyWZCryrix4kQ6T1R63wiXJPKKa0iy1DwmRF5vUsR8lW6tqC4jFhY94TXgR6tQ qi2fIqTu6rovRjl3wIuPliHd1k+k/55T0d1CN6A2EOgiEFLrq77HmGHj2+/jZbLE B5u7XrqnpN+8ZXRABRoe2duKHh74/8cDYT3cXcg5dbELfbEuYRKv4qgPs3PzISJH 3Ds+DBU7nFiokGRzkwq/GzX445deqjdvCcaa9PrBt7nMQcYpiVZYhXV552d8eHsd vToF3JLObXvUVuuImnPTrIYV6SsqXiSPTnyGvn++WRyuQFX7OTnr+v0pNO+nvyQ=+vQY -----END PGP SIGNATURE-----
On Tue, Jan 17, 2012 at 09:44:25AM +0100, rs at noveltech.de wrote:> We are currently try to add Gapless support on our device? If we rip an CD > with our device, we can find out, that one track follow after another so we > can > recognize, that the tracks are gapless or not.Are you aiming for maximum compatibility with how the source CD would be played on an average CD audio player? Or just trying to avoid the *extra* silence that is typically added by formats like MP3 and some of the software players/libraries? As you should know, the Red Book spec allows for indexes to be used to define "pre gaps" before tracks, that are not part of the track itself. It's also possible to violate the Red Book standard and add "track 0" before the first index, or other weird tricks to include "bonus" tracks on a disc that may or may not get ripped by common software. As far as I recall, even having no silence between each track violates the standard. Many people who use FLAC to archive entire CDs (as opposed to "albums" of tracks that may or may not be on the same CD) will rip the entire disc and store it in a single FLAC file, with the CUE sheet either as a separate file, embedded in the FLAC metadata, or both. This preserves the musical "flow" of the exact timing of the music and silence across the disc, regardless of each each track boundary.> But how can we find that out on already existing FLAC files (or other > formats). Is there a marker inside the file, who tell me, that this > File is a gapless file? Also gapless make only sense, if you have the follow > up file also?A file on its own cannot really be called "gapless", however that depends on how it was ripped. If a CD has deliberate silence between tracks it's usually there for very sensible musical reasons. I have been at mastering sessions where the mastering engineer added in silence, or edited the silence that was included on the final DAT or CD-R, and asked the artist/producer to listen to the difference. Typical DAT recorders add a standard gap between tracks, and older tape formats (such as Sony PCM-F1 on Betamax) have longer and less predictable gaps. A fraction of a second added (or removed) in between tracks can make a huge difference to how an album comes across. The aim of pregaps on a CD is to allow the track skip buttons to hit the beginning of the desired track, while also having the correct gap before the track when playing through from the previous track. Strictly, that silence isn't part of any track, but to preserve the overall flow most ripping software will add the silence to the end of the previous track. That way the tracks will all start at the beginning of the music, not on silence. For some albums, this fails on tracks where the pre-gap might actually be part of an intro or a segue from the previous track. I can't think of any specific examples, but many albums of live music will have a spoken intro before some tracks (mastered in the pre-gap).> If I rip now all 4 titles and play them later the player must know, that > Song 1 is not gapless but Song2 and 3 ?Fit? together. > > What will happen, if I delete Song3?. Is the player playing now from Song2 > to Song4 gapless, which is not correct?If track 3 is deleted (or the end user removes it from a playlist, or whatever) then the "fit" (or "flow") that was there (between tracks 2 and 3 and 4) has been changed. What happens depends on where the silence was placed in each track. This is not a new problem, as the very first CD audio players had the ability to skip tracks, either by programming a crude "playlist" or with a "shuffle" function.> Anybody a good description for me, how this is solved on FLAC?The most complete "solution" is the entire CD as a single FLAC file, with CUE sheet both in the FLAC metadata and a separate CUE file. That way, all the "bonus track" weirdness can be preserved. A more flexible solution is to use 1 FLAC file per track with decisions made as to how it will sound with and without all tracks present and in sequence. -- -Dec. --- "Mosaic is going to be on every computer in the world." - Marc Andreessen, 1994
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03.02.2012 1:11, Declan Kelly wrote:> Many people who use FLAC to archive entire CDs (as opposed to > "albums" of tracks that may or may not be on the same CD) will rip > the entire disc and store it in a single FLAC file, with the CUE > sheet either as a separate file, embedded in the FLAC metadata, or > both. > > This preserves the musical "flow" of the exact timing of the music > and silence across the disc, regardless of each each track > boundary. >A word of caution: 1) CUE sheets don't support timestamps past 99 minutes 59 seconds. Not a problem for audio CDs, but for bigger media it might be an issue. 2) GStreamer (which is something you might have to use as a multimedia framework for playing audio, if you're developing free software, or even proprietary software for some platforms) doesn't support CUE sheets natively, and i don't really recall any frameworks that do (not that i know that many...). CUE sheet support has to be implemented on top of the framework, and might not be as straightforward as it sounds (especially if you want to also have gapless playback). Clementine audio player, for example, still can't get CUE sheets right, and QuodLibet audio player doesn't support them at all. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPKwvTAAoJEOs4Jb6SI2CwFPMH/RGkAdQYi+z8oZq4B0e/BpEf UFkBc/YSv+o2JPEI8oFI7PRXYk3aES15JpN79F1roeY0x8QCBvY2fvVn0f8EJvip h3dGPuE3xhlq0MEG4KtBGmmcmtA70dwqDQCTIzUZOzaIAbppAkTAE5tifOGE425C 0Zm5K/fXiaoEai7rpPB/QvwxntYYDLcwnHFO673EqpNu7I8IP7haWaT+g9mQBld/ RBsbmrnR4+7QBpKhelGNBZoMa/ZPS5fZNi6I/DtLYhiq0k3djd/8GvTPI4DgbSWi F+wwi03Tu1Te/0DVH1HekmVRYsKeqZh4l+DIXB89Db0Bk1e2sMNh5/3++L771yg=IcGe -----END PGP SIGNATURE-----
Hi Richard, Your question spans two or three standards, and thus a complete answer is complicated. First of all, there is no information on a CD that indicates whether the audio is gapless or not. All audio on a CD is technically gapless (if not conceptually gapless) and must fall into track boundaries that start on multiples of the 2352-byte block (588 stereo samples). The first track of a CD can easily be aligned at the start of the audio, but the remaining tracks cannot precisely align the start of the audio with the start of the track without editing the audio. As a result, some tracks will have a random amount of silence between the start of the track and the start of the audio. If there is a conceptual gap in the audio, then the CD mastering engineer might increase or decrease the silence to align the start of the audio with the start of the track, but there is no indication in the data on the CD that this was done. If the original audio is gapless, then the CD mastering engineer only has two choices: allow some audio from the previous track to be heard at the start of the next track, or miss some of the audio for a track in order to avoid hearing the tail of the previous track. We're talking about 1/75th of a second at most, so usually these problems are easily missed or ignored. But, all the same, these problem exist, and if the mastering engineer adds a few samples of silence, then nothing in the CD format will tell you that this was done. Likewise, if the engineer deletes a few samples, nothing in the data will tell you. Audio from a CD source always comes in groups of 588 stereo samples. The bottom line is that if you think you "know" whether a pair of tracks on a CD have a gapless segue, then you will not always be correct. This is a fact that has nothing to do with CD, MP3, or FLAC. It's about the relation between the original audio and the limitations of the CD format. There are a few other details of the CD format that have to do with the imprecise specification of track markers and mute bits - information which is purposely vague in order to allow both cheap CD player hardware and more advanced CD players to follow the same loose guidelines. But these further details are a bit too far off topic for a FLAC mailing list. Second of all, the biggest issue with gapless playback is the mismatch between the CD block size of 588 stereo samples versus the MP3 block (frame) size of 1152 stereo samples. An even bigger issue is that while the audio samples in a CD block are not related to each other after they have been decoded, the samples in an MP3 frame are related. If you somehow knew that an audio track ended 100 samples before the end of a CD block (and you'll never know this) then you could just toss those samples and keep the preceding ones. However, you cannot discard MP3 samples without getting a glitch, because all 1152 samples in a frame affect each other. This is part of the definition of lossy encoding. Not only do you lose the precision of the original audio, but trying to use partial frames results in even further glitches. Thus, the origin of all problems with gapless playback are due to the mismatch between CD and MP3 block/frame sizes. The workaround for MP3 is to have extra tags in the file to remember the actual length of the CD track in multiples of 588 stereo samples, and then recreate the lossy audio without the extra samples in the last frame, even though that creates a small glitch. But not all MP3 encoders put the original CD block length in the file, so you really have trouble. Now, when you get to FLAC, you have a default block size of 4096 or 1152 for levels 0, 1, and 2. Neither of these match CD (4116 and 1176 are the closest). Fortunately, because FLAC is lossless, you can add or remove excess samples at the end of the last block without any glitches. Also, because FLAC is lossless, all encodings preserve the exact length of the original data, regardless of whether the final encoded block is padded or is of a smaller size. So, armed with all of the above information, you can see that all you need for gapless playback of FLAC is to honor the actual size of the audio data as stored in the FLAC file. Then, on playback, just make sure that the first sample of a new track is immediately following the last sample of the previous track. The only piece of information that is missing is whether these tracks are "supposed" to be played right after each other. However, that information is conceptual and is missing from the original CD data, so the problem has nothing to do with FLAC at all. The only way to "know" whether a track is gapless or not is to have some human being enter the information manually. There is no universal specification for this information. Of course, Apple has their own format in iTunes for gapless tracks, and I assume some other audio developers have their solutions, but my point is that you cannot depend upon the CD data itself to provide this information automatically. And, if the information cannot be obtained automatically from the CD, then there's no way for the FLAC format to automatically provide "gapless" information. At best, all you can do is recreate the original CD audio data as it existed on the original disc. FLAC is perfect for this because it preserves all the data that actually exists (all but the track lead-in and mute bits, which are not available to most CD ripping hardware anyway). Brian Willoughby Sound Consulting On Jan 17, 2012, at 00:44, Richard Sch?lein wrote:> We are currently try to add Gapless support on our device? If we > rip an CD with our device, we can find out, that one track follow > after another so we can recognize, that the tracks are gapless or not. > > But how can we find that out on already existing FLAC files (or > other formats). Is there a marker inside the file, who tell me, > that this File is a gapless file? Also gapless make only sense, if > you have the follow up file also? > > Example: > > CD > > Track 1 not gapless > > Track2 Gapless > > Track 3 Gapless > > Track 4 not gapless > > If I rip now all 4 titles and play them later the player must know, > that Song 1 is not gapless but Song2 and 3 ?Fit? together. > > What will happen, if I delete Song3?. Is the player playing now > from Song2 to Song4 gapless, which is not correct? > > Anybody a good description for me, how this is solved on FLAC?