We’ve discussed this before, but I’ve made some new discoveries.
Load the same audio onto two tracks, ideally something long, like a song.
Simply toggling the loop option in the transport controls causes a change in the audio, resembling a chorus effect, which occurs due to the constructive and destructive interference of sound waves when two identical tracks fall out of sync.
Furthermore, an audible artifact occurs at the loop point, as the audio doesn’t resume exactly where it left off (it’s unclear whether it jumps forward or backward by a few frames). Toggling the loop function in the transport should not produce any such artifacts.
The playhead doesn’t even need to be positioned within the loop range. In fact, for testing purposes, it’s clearer to toggle the loop on and off while the playhead is positioned after the loop range; this makes it easier to hear the changes in the audio and the resulting artifacts (clicks).
Regards.
re. Looping causes audio tracks to desynchronize...
hi,
do you care and share a specific session and the audio sample file(s) as evidence, please?
thanks
re1. Loop causes desynchronize...
I’ve attached two video and sessions.
The first one shows what I’ve already pointed out.
The second one is surreal:
If we duplicate the audio clips, the loop becomes ineffective, the clip just keeps playing normally, ignoring the loop.
EDITED:
Forgive my ignorance... could this be due to latency compensation?
re2. Loop causes desynchronize...
hi, thanks for the file evidences
in the first case I'm having a hard time in reproducing the said desynchronization but it may well be true, eventually if one keeps switching the loop range and solo a track on and off like crazy when transport is rolling (like it's seen in the first video)
now for the second case it's where all my attention shall be focused to get it fixed asap. slapping my forehead crying out loud why this nuisance slipped through... the hard fact is that looping and hash-linked audio clips is complete FUBAR! nuff said.
will try to fix and squash this ugly one, soonish...
thanks anyway
UPDATE: hopefully fixed in qtractor >= v1.7.0.14git.346a2b
re3. Loop causes desynchronize...
As soon as I have a moment, I’ll compile and test it.
Regarding issue 1... it’s still there.
Switching to a standard kernel helped, but the problem persists.
If you reduce the Quantum to 128, it seems not to happen—but working at that setting is madness, at least on my machine. I suppose the margin is so small that desynchronization can’t occur, or perhaps it’s because the packets are smaller.
It’s as if, upon engaging the loop, samples from certain tracks that don’t fit into the current cycle spill over into the next one.
1_
I set it up this way (in an extreme manner) to demonstrate it... but simply pressing the transport loop button is enough to trigger it. I was working with a Quantum setting of 512.
2_
Muting a track, or setting it to "solo," can either fix or exacerbate the issue.
3_
Once the desynchronization occurs, it persists even after you disable the loop.
@bluebell also reported this; their workaround was to automate the mute function at the end of the loop. This suggests the issue isn’t exclusive to PipeWire.
If you don’t touch the transport’s mute button, everything works fine—but the moment you press it, you’re better off reloading the session before performing a final audio export.
Generally speaking, it’s harmless; however, I made some live recordings—using a stereo microphone for ambient sound and an instrument, and a mono input for vocals—where the phase cancellations caused by this desynchronization were both noticeable and problematic.
_
Looking for other potential causes:
Are sample rate conversions always applied, or only when necessary? In this case, they weren’t needed.
Given that it only happens when the loop is active, I’d take a look at the loop processing flow—to see what might be going on.
re4. Loop causes desynchronize...
Hi again Rui,
Following up on the tests with the previous files, I've been looking through qtractorAudioBuffer.cpp (also using Gemini) and I think I've found the exact condition causing the 1-quantum cycle offset when using buffer sizes ≥ 256.
The issue shows up specifically when comparing any audio file longer than 4 seconds (!m_bIntegral) against a file shorter than 4 seconds (m_bIntegral == true) or a MIDI track. Shortening the session loop markers doesn't avoid it, whereas splitting or consolidating the clip into files under 4 seconds immediately eliminates the drift.
Looking at the code, that exact one-period shift comes from how m_bIntegral, inSync(), and readMix() interact:
In qtractorAudioBuffer::open() and initSync(), any file whose length exceeds the maximum ring-buffer size (capped at iSampleRate << 2, i.e., 4 seconds) streams from disk with m_bIntegral = false.
On transport start or session loop wrap-around, setLoop() / reset() invalidate ReadSync and set m_iReadOffset = m_iOffset + m_iLength + 1.
On the very first process cycle (iFrameStart to iFrameEnd), inSync() sees that ReadSync is false and m_iReadOffset doesn't match iFrameStart + m_iOffset, so it drops the current cycle (returning false) and calls seek(iFrameEnd).
Because seek() schedules the disk read starting at iFrameEnd instead of iFrameStart, clips longer than 4 seconds consistently start one exact buffer period (iFrameEnd - iFrameStart) behind short clips (< 4s) or MIDI tracks.
In fact, there is a second very easy way to reproduce this same issue in readMix(): if you enable an internal clip loop on a file longer than 4 seconds that spans the exact length of the clip (m_iLoopEnd == m_iLength), on each wrap-around m_iReadOffset hits re (m_iOffset + m_iLength), triggers setSyncFlag(ReadSync, false) as if the clip had ended, and falls back into the inSync() -> seek(iFrameEnd) loop, accumulating delay on every repetition until the audio completely disappears. Extending the right edge of the clip past the loop end (m_iLength > m_iLoopEnd) stops it from happening.
At 64 or 128 frames, that initial delay is only ~1.3–2.6 ms and goes practically unnoticed, but at 256, 512, or 1024 frames (5.3–21.3 ms) the timing and phase offset becomes clearly audible.
Keep in mind that this diagnosis was done with the help of AI and might not be entirely accurate, though it fits the test results.
Sharing this in case it helps you reproduce it and see why those test files were drifting out of sync.
Best regards!
re5. Loop causes desynchronize...
it would be best use of it--the AIgent--if it suggest some hint to a fix that you can confirm ;)
(I rarely almost never run above 128fps :))
cheers
Add new comment