This project reproduces an audio glitch that occurs when using rtaudio to generate audio via PulseAudio on Linux.
I discovered this using VCV Rack 2.1.0+ and reported it on the VCV Rack forum. I subsequently determined the root cause to be a change in how rtaudio initializes PulseAudio. My proposed fix is in the patch file glitchfix.patch.
Andrew Belt suggested I report the issue and the proposed fix to Gary Scavone at his original rtaudio repo on GitHub.
This is my first step: a program that demonstrates there really is an issue in PulseAudio without my fix, and that the problem goes away when my fix is applied.
- Clone this repository on a Linux system that has PulseAudio installed.
- Clone the rtaudio repository.
cd rtaudio
git checkout c70f95e352b26e3bd486d6b2b23e3964f2b97a39
cd ../pulseaudio_glitch_demo
- Edit the
run
script and verify that the lineRTAUDIO_SOURCE=../rtaudio
correctly points to the directory where you cloned rtaudio. Make adjustments to the path as needed. ./run
You will hear an 80 Hz stereo sine wave. To reproduce the glitch, allow the program to continue running while you switch to other windows, run other things, etc. You will hear clicks and pops every now and then. On my system, the glitches happen even if I do nothing, but they happen a lot more if I open Google Chrome and start switching tabs around. But pretty much any normal user activity will cause the glitches sooner or later.
When you are done with the demo program, press ENTER and it will stop generating audio and quit.
Apply the patch glitchfix.patch to rtaudio, then repeat the steps above. The glitch will disappear.
My best understanding of the glitch is that it happened when this change was made.
VCV Rack 2.0.6 used a version of rtaudio before this change,
and it never glitched on my system. VCV Rack 2.1.0 and above included a fork of rtaudio with this change,
and it glitches. When I removed the code that set attr_ptr
to a non-null value in RtApiPulse::probeDeviceOpen
,
the glitch goes away again.
This is how I build and run VCV Rack on my own system, so that the audio renders correctly.