I have a stereo 16k 16 bit file that I want to be able to seamlessly loop for ever. In other words when played on any player set to loop play it seamlessly goes round and round and you can’t tell where the loop point is. Its for background ambience in a game. It is effectively a drone that is always heard in the background.
I have removed DC offset found a zero crossing point located at the same sample in time on both the left and right channels and looped the file at this point.
I can see that the first sample in both channels is zero crosspoint at the start of my file.
I can see that the last sample in both channels is zero crosspoint at the end of my file.
I hear a click. Why??? The samples are at zero at that instant in time!
Also even applying a 20 sample fade in at the start and a 20 sample fade out at the end still gives me a click! Can someone help explain what is going on??
By the way I have experienced this before with another file but gave up that time, so I doubt its the file itself. There is something wrong in my understanding of how this file is playing back or how audacity is working.
Change in frequency content:
In this example, there is a sudden change to a higher frequency. Notice the kink in the waveform at the join - that will produce a slight click.
To avoid clicks you need a smooth transition.
Change in amplitude:
In this example, there is a sudden change in the waveform amplitude. Again, notice the kink in the waveform at the join.
To avid clicks you need a smooth transition.
Hardware issue.
Some sound cards create a click when starting playback, and thus a click when they restart on “loop play”.
Applications that are specifically designed for looping can usually avoid this problem by clever handling of the audio buffers. Audacity is not specifically designed for looping and relies on the sound card to handle playback “properly” (to not click at the start of playback). You can test if this is the issue by selecting the section that you want to loop, and copy/paste it end to end. Click on the split line to join the two sections and then play across the join. If there is a click, then the problem is with your edit.
MP3 and other lossy formats.
MP3 is unsuitable for looping because the format does not specify the encoder/decoder delay, thus there is always a short gap at the start, which will cause a click when looping. The solution is to use an uncompressed audio format such as WAV.
Its no 3 above. The loop point play perfectly when back to back.
I was using just the crappy on-board PC sound for editing because it can handle any sample rate that you set in Audacity. My Focusrite Pro soundcard cannot though, it seems to be locked to only the standard sample rates and audacity throws an error when I select it as the playback device at 16kHz (not in the list of sample rates in the soundcards menus). Time to get onto Focusrite!
I was wondering if I could explore this a little further as I am struggling to find a resolution to this.
I am awaiting a response from Focusrite.
I get the issue with the on board motherboard sound and my Focusrite Saffire 56. No combination of Host and Device seem to make a difference. I am not using an ASIO driver because Audacity does not directly support it. Will using an ASIO driver solve this issue? Can I presume that for instance if I used another program which supports ASIO that a seamless loop would occur? Is this a hardware issue, driver issue or software issue? I’m trying to workout what I need to replace to fix this.
I’m finding it hard to believe that my Focusrite is just simply unable to reliably loop any audio from any software using any driver (ASIO, WDM KS, WASAPI etc). It just doesn’t seem right???
Just to summarise what I have tried
Update onboard motherboard sound driver via windows auto search. It did this successfully, but no change when playing back via that hardware, click still there.
Tried WDM-KS, WASAPI, MME and DirectSound driver on onboard motherboard sound with no change. click still there.
Tried latency settings of 3000ms, 2ms and 0ms on all drivers that could support it. Still click.
Tried WMD-KS driver with Focusrite. No change. Focusrite on latest firmware, software etc.
Its very important to me to be able to fix this. I cannot hand over audio assets unless I can correctly monitor them before doing so, its a tad risky!
First, lets see what happens if you try to loop audio that we know for certain is a perfect loop.
Close and re-open Audacity (new empty project)
From the Audacity Generate menu, generate a 2 second with the default frequency (440 Hz) and amplitude (0.8).
Hold down the shift key and click the Play button (loop play).
What happens?
I get perfectly looped audio! On both on board sound and my Focusrite.
However, this slightly contradicts the test from before:
Find the zero cross point in both left and right channel at the same instance in time.
Cut the first half and insert it to a new track with a slight overlap occurring with the second half/original track.
Loop play all of it. Hear a click
paste the first track on the end of the second track at the last sample. Play over the merge point. Perfect audio.
If the waveform is the problem I don’t understand why. I have two zero samples in a row in both channels where the cut is being made. My understanding is that this would mean no click.
The difference between the two waforms Is very apparent. One a pure sine and another which is actually like the low freq content of pink noise.
Can someone with a good knowledge of waveforms please help explain what why a complex waveform behaves differently to a sine wave when looping?
You could try ASIO for example in the trial version of Reaper. But I somewhat doubt ASIO would help.
You mentioned (I think) that you selected 16000 Hz project rate in Audacity (which rate your Focusrite does not support) and you got “Error Opening Sound Device”.
Really what should happen (as I understand it) is that Audacity will try to resample that 16000 Hz audio to the next highest “rate-to-try” that it detects your device supports. Then Audacity sends that resampled rate to Focusrite. It seems this doesn’t always work correctly.
Can you set project rate to 16000 Hz, generate a tone (which should then be 16000 Hz sample rate) then play that to Focusrite.
When you get the error, what does “Actual Rate” say bottom right of Audacity?
What rates are listed as supported in the Focusrite control panel (if it has one)?
Note that even if you did not get an error, the resampling up to a rate supported by your card is lossy and could even be causing the loop glitch with real-world audio. External sound cards are much more touchy about sample rates being matched everywhere (including Windows) than motherboard audio. Generally, I would expect WDM-KS host to work with least fiddling in Windows “Sound” to match sample rate.
Are all your loop files low sample rate? What happens if you set project rate to 44100 Hz, export your loop as WAV (so you then have a 44100 Hz WAV), import that 44100 Hz WAV then loop that?
Can you set project rate to 16000 Hz, generate a tone (which should then be 16000 Hz sample rate) then play that to Focusrite.
No I get the “Error While Opening Sound Device. Please Check the Output Device Settings And the Project Sample Rate”
I’ve had confirmation that the focusrite does not support sample rates lower than 44.1kHz so the driver would have to upsample before sending to the Focusrite. However it seems to not want to do this.
What I have found is the following, when setting the project rate to 16kHz and generating a 440Hz sine tone on a stereo track with sample rate at 16kHz:
MME + Micrsosoft Sound Mapper - Output = Audio loops perfectly. “Actual Rate” = 16kHz
MME + Speakers (Realtek High Definition Audio) = Audio loops perfectly. “Actual Rate” = 16kHz
Windows DirectSound + Primary Sound Driver = Audio loops perfectly. “Actual Rate” = 16kHz
Windows DirectSound + Speakers (Realtek High Definition Audio) = Audio loops perfectly. “Actual Rate” = 16kHz
Windows WASAPI + Speakers (Realtek High Definition Audio) = Audio Loop Glitches. “Actual Rate” = 48kHz
Windows WDM-KS + Speakers (Realtek High Definition Audio) = Audio Loop Glitches. “Actual Rate” = 44.1kHz
Windows WDM-KS + Speakers (saffire Audio) = “Error While Opening Sound Device. Please Check the Output Device Settings And the Project Sample Rate”. But it switches to “Actual Rate” = 32kHz if you have it on any other rate. In its own dialogue its on 96kHz.
I then tested each host and playback device combination with my original file that had the issue and the results were exactly as above.
Clearly the issue is caused by up sampling by the driver before sending it onto the native hardware/virtual hardware.
I will try to see if there is a fix to this anywhere for the WASAPI and WMD-KS drivers. At least I know now what the issue is and that using an MME or DirectSound driver will playback the audio ok (oldschoool!).
If not already at 44100 or 48000, change the “Project Rate” (lower left corner of the main Audacity window to 44100 or 48000 (44100 is standard for CD audio and generally a good choice unless you are working with DVD video).
With the imported track selected, choose from the “Tracks” menu “Resample”, and resample to 44100 or 48000Hz (whichever you chose in step 2).
MME will upsample to 44100 Hz after Audacity sends it audio at 16000 Hz. As far as I know MME only supports that rate though it can resample most rates.
I suspect Audacity resampling to the next higher rate does not work as smoothly as it should. It looks like Audacity tried the next higher rate only, as if it thinks Saffire supports 32000 Hz. Can you post Help > Audio Device Info… from Audacity?
However if you have chosen to set Saffire on 96000 Hz then you should have Audacity project rate on 96000 Hz so that Saffire does have to do resampling. Why not set Saffire to 44100 Hz if you like to work with low quality files, and why not convert the low quality files to 44100 Hz (or resample them in Audacity as Steve suggests)?
Also be aware that WDM-KS only allows one application at a time to access the sound device. So if you played a song in an another application using WDM-KS and paused the song, Audacity won’t be able to play to that same device under WDM-KS.