I’m a beginner with Juce building my first project. It’s a VST audio effect that I’m testing inside Reaper on Windows 10.
Using my laptop’s built-in DirectSound device everything is working smoothly.
When I switch to an an ASIO device (Focusrite Scarlett) I get intermittently scrambled, stuttering audio when the VST is turned on, even if the audio is playing on another channel in Reaper. It makes no difference whether Reaper’s transport is playing or stopped, although when playing the playback position also “jitters” visually.
When I switch back to DirectSound, the problem is gone again.
This is a setup I’ve used for a long time without issues and I’m pretty familiar with it, so I’m certain the problem is being caused by my new VST.
Incidentally, it happens to do all of its processing one sample at a time, so I don’t have any buffers in my code (except the ones JUCE creates). The effect certainly sounds like the read pointer of a buffer is being bounced around, though.
I’ve tried tweaking buffer size on my ASIO device and the thread priority in Reaper to no effect.
I had some time this evening to narrow this down to a region of my code that’s doing wet/dry blending. It’s the last thing I’d have thought would cause a problem, but the glitching completely vanishes when this code is commented out.
If I manage to figure out the root cause I’ll update this thread in case it helps the next person.
It’s interesting that it was OK for DirectSound. I’m guessing the issue might be to do with smaller buffer sizes rather than ASIO itself (as ASIO is pretty solid in JUCE).
I’m sure you’ll find a few people happy to comment on your code if you post an excerpt here.
Thanks for replying – I’ve ended up making many changes to try to track the problem down and despite being quite systematic the problem seems to have “just gone away” without it being clear which change – if any – fixed it. Very frustrating!
The code I thought I had it down to last night was completely innocent-looking, and this morning I’ve restored it without the issue seeming to come back. I’m certain it was an issue in my code (not drivers / other software / JUCE framework etc) but still unclear what the exact interaction was that caused the trouble.
I’ll have the opportunity to do a lot more testing over the next few weeks. If it returns I’ll be sure to report back…
Possibly un-related, but I recently had an experience with ASIO & an Apollo Twin Thunderbolt interface in Windows 10 where I was constantly getting stuttering audio (regardless of audio callback process load), and the solution was to turn off ‘Intel Speedstep’ in the BIOS of my laptop.
I’m usually a fan of late optimization when coding, so of course my code was pretty inefficient. Eventually I noticed the plugin was chewing up a lot of CPU even when idling; some maths-intensive code in the GUI was the culprit.
Crackles, pops, buffer skips etc seemed to be correlated with one of the cores redlining – my guess is that’s the core ASIO was using, although I have no idea how that works under the hood. That would explain why the problem was intermittent.
Anyway I spent a few hours this morning caching values and removing some other inefficiencies. Now it runs much cooler and I’m no longer getting any glitches.
@wavesequencer, your answer is related I think; the issue was certainly indicating a performance problem. I’ve made a note to try the BIOS change at some point, although I’m happy for now developing on a less-capable machine since I hope to release the VST into the wild eventually.