Gapless Playback

Audio software developers forum.

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Gapless Playback

Permanent link to this post Posted by jesalbeta » Fri Jan 20, 2017 6:25 pm

Hi fellow forum users,

I am brand new to Audacity and would like to know a little more about gapless playback (perfect looping) is achieved, as almost every other media player has a pause/rebuffer lag (ranging from a slight 2-3 frames to upwards of 2-3 seconds) when set to loop mode. It is especially interesting to me as I have been creating seamlessly looping vines for around 3 years now: my Vine profile. I know that Vine achieves gapless playback through the repetition of media copies and crossfading (Vine Engineering Blog), but I was wondering how exactly it is processed through Audacity. Is it truly the repetition of a single file, with no pause/rebuffer lag resulting in a perfect loop, or does it work in ways similar to that of Vine, with helpful techniques such as loading copies primed for playback when the end of a file approaches? To put it bluntly, is it an authentic loop, or the illusion of an authentic loop? Any technical details on how gapless playback is achieved though Audacity, or even how gapless playback is achieved in general, would be greatly appreciated! I still have a lot more to learn about audio in a broader sense, as most of my knowledge previously surrounding it was tunnel visioned through Vine, so I apologize if this question sounds a bit newbie.

Glad to be joining the community,

- Jesal.
jesalbeta
 
Posts: 6
Joined: Fri Jan 20, 2017 6:18 pm
Operating System: Windows 7

Re: Gapless Playback

Permanent link to this post Posted by steve » Sat Jan 21, 2017 1:03 am

Are you asking about "loop play" with "shift + spacebar" or something else?
For loop play to loop without a glitch at the loop point, the end of the selection must match up exactly with the start of the selection - Audacity does not "cheat" (does not do crossfade tricks to make the loop sound better than in really is. This is important if you wish to make looping samples for use in a sampler or in a game or similar applications.
Last edited by steve on Sat Jan 21, 2017 1:59 am, edited 1 time in total.
Reason: fix bad edit
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44703
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Gapless Playback

Permanent link to this post Posted by kozikowski » Sat Jan 21, 2017 1:06 am

And correct me, but it only works if the selection fits in memory. If it doesn't, the machine has to smash the physical hard drive armature back and forth and you get serious gaps.

Koz
kozikowski
Forum Staff
 
Posts: 37983
Joined: Thu Aug 02, 2007 5:57 pm
Location: Los Angeles
Operating System: OS X 10.9 Mavericks

Re: Gapless Playback

Permanent link to this post Posted by steve » Sat Jan 21, 2017 1:16 am

kozikowski wrote:And correct me, but it only works if the selection fits in memory. If it doesn't, the machine has to smash the physical hard drive armature back and forth and you get serious gaps.

I'll correct you ;)
Audacity should be able to play a loop of any length "seamlessly" provided that the start and end of the selection match up exactly. During playback, audio data is read from disk in blocks of just over 1 MB each (remember all those little AU files?). While one block is playing, Audacity will be reading the next one from disk. One of the major benefits of Audacity saving the audio data as "blockfiles" is that it (Audacity) does not need to search through a long file to find the next bit of data to play - it just reads a small file for whatever "next bit" is required.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44703
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Gapless Playback

Permanent link to this post Posted by kozikowski » Sat Jan 21, 2017 1:37 am

the selection must match up exactly with the start of Audacity

Time zero? Why does it need to do that? Assuming the waveforms match what's the difference?

Koz
kozikowski
Forum Staff
 
Posts: 37983
Joined: Thu Aug 02, 2007 5:57 pm
Location: Los Angeles
Operating System: OS X 10.9 Mavericks

Re: Gapless Playback

Permanent link to this post Posted by steve » Sat Jan 21, 2017 2:00 am

Oops sorry - a bad edit on my part. That should read "the end of the selection must match up exactly with the start of the selection".
I've corrected my previous post.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44703
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Gapless Playback

Permanent link to this post Posted by jesalbeta » Sat Jan 21, 2017 7:52 pm

But even if I have an audio file that loops perfectly, Windows Media Player or VLC Media Player (or almost any other media player for that matter) will end up breaking a perfect loop with a slight gap/pause when set to loop mode. How does Audacity loop play keep the loop seamless? It is a larger amount of source/output buffer? I believe the problem with typical media players is that they restart the stream each time (correct me if I'm wrong)?
jesalbeta
 
Posts: 6
Joined: Fri Jan 20, 2017 6:18 pm
Operating System: Windows 7

Re: Gapless Playback

Permanent link to this post Posted by kozikowski » Sat Jan 21, 2017 11:33 pm

How does Audacity loop play keep the loop seamless?

As above up the thread, Audacity busts the music up into tiny chunks and cleverly juggles the chunks so there is always fresh music in memory at just exactly the right time, and it doesn't matter where the hole is.

The only requirement is musical, the end and beginning blue waves have to perfectly match.

It's a common request to want Audacity to force other software to work. The only thing we can do is make a clip with no obvious looping damage. The actual loop is up to them.

Koz
kozikowski
Forum Staff
 
Posts: 37983
Joined: Thu Aug 02, 2007 5:57 pm
Location: Los Angeles
Operating System: OS X 10.9 Mavericks

Re: Gapless Playback

Permanent link to this post Posted by kozikowski » Sat Jan 21, 2017 11:40 pm

In DVD burning land, it's common to mess up the opening menu which commonly loops a short segment of the movie behind the menu—Play, Select, Language, etc.

It's stupid simple. You are really playing one massive movie with all the loops perfectly built in. If you stick with it long enough, the DVD player will eventually reset and there will be a big frozen glitch, but nobody ever stays around that long.

Koz
kozikowski
Forum Staff
 
Posts: 37983
Joined: Thu Aug 02, 2007 5:57 pm
Location: Los Angeles
Operating System: OS X 10.9 Mavericks

Re: Gapless Playback

Permanent link to this post Posted by jesalbeta » Sun Jan 22, 2017 12:26 am

kozikowski wrote:
How does Audacity loop play keep the loop seamless?

... Audacity busts the music up into tiny chunks and cleverly juggles the chunks so there is always fresh music in memory at just exactly the right time ...


Is there any source code/detailed explanations of this exact process? I want to learn how gapless playback is achieved on the technical side.
jesalbeta
 
Posts: 6
Joined: Fri Jan 20, 2017 6:18 pm
Operating System: Windows 7

Next

Return to General Audio Programming



Who is online

Users browsing this forum: No registered users and 5 guests