# Playback glitching with ALSA

**URL:** <https://forum.juce.com/t/playback-glitching-with-alsa/14210>\
**Category:** Linux\
**Created:** [January 25, 2015, 6:37pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210 "2015-01-25T18:37:51Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![njoliat](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/njoliat/32/931_2.png) [@njoliat](https://forum.juce.com/u/njoliat)\
**Post date:** [January 25, 2015, 6:37pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/1 "2015-01-25T18:37:51Z")

</div>

Hi,  
I'm getting glitchy / choppy audio output from some of the JUCE example projects.&nbsp; I'm running up-to-date Arch Linux (kernel 3.18.2-2) and I have the JUCE source from git, current as of today (commit 0401.)&nbsp; I noticed this glitchiing while running the Audio Plugin Host, but I also hear it in the Demo project (e.g. Synthesizers, File Playback) and BouncingBallWavetableDemo.

In Demo, if I increase the buffer size (e.g. between 512 and 4096) the glitching gets slightly slower and steadier, from many dropouts per second (maybe \>10) to more like one per second.

Qualitatively the audio glitches sound like what's described here: http://www.juce.com/forum/topic/choppy-playback-scientific-linux  
However, it sounded like that poster's problem was specific to pulseaudio, whereas I don't have pulseaudio installed and am just using ALSA.

Any ideas, or other information I can provide?  
Thank you!

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 26, 2015, 12:13am UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/2 "2015-01-26T00:13:18Z")

</div>

Very hard to debug ALSA things like this without actually having the same device (and system) to test myself. ALSA&nbsp;devices&nbsp;seem to vary a lot in their behaviour.. All I can suggest is maybe running a profiler or debugging into the low level code to try to narrow down the area that's causing trouble. Happy to do what I can if you have any more clues..

---

<div class="post-metadata">

**Author:** ![njoliat](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/njoliat/32/931_2.png) [@njoliat](https://forum.juce.com/u/njoliat)\
**Post date:** [January 28, 2015, 11:07pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/3 "2015-01-28T23:07:34Z")

</div>

Hi Jules, thanks for the reply.&nbsp; Unfortunately I do not yet have any ALSA log data (incidentally this seems surprisingly difficult, depending on certain kernel flags which are not set on my Arch system https://www.kernel.org/doc/Documentation/sound/alsa/Procfile.txt).&nbsp; So I'll understand if this still isn't enough data to help, but I did notice a new detail: the glitching goes away (including at small buffer sizes e.g. 64) if I have only audio outputs, and no inputs, active.&nbsp; (I observed this using the Demo app (Settings + Synthesizers demos) but I've also written several small JUCE programs that use only audio output and work fine on my system.)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 29, 2015, 9:55am UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/4 "2015-01-29T09:55:45Z")

</div>

Hmm, that's interesting. Because the inputs and outputs are separate, there's some nastiness in the ALSA wrapper to try to synchronise them, and that could be the culprit in cases where the input and output devices have a tendency to drift. I'll try to have a look into this..

---

<div class="post-metadata">

**Author:** ![sfeinstein](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@sfeinstein](https://forum.juce.com/u/sfeinstein)\
**Post date:** [March 12, 2015, 11:07pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/5 "2015-03-12T23:07:00Z")

</div>

I also find that I turn off the output [edit: I meant turn off the input] the glitch goes away.&nbsp; I was the original poster on the Scientific Linux post and it did appear to be pulseaudio at the time.&nbsp; The glitchiness was very occasional, so it was hard to determine if pulse was the cause - esp with all the popular discontent with pulse architecture etc.&nbsp;

But since then I have gotten this bad playback to happen with pulse completely disabled, both with the Juce Demo and my own code.&nbsp; Shutting off the input seems to make it go away.&nbsp; My current users don't need to record, so I can disable it in my app, but it would be nice to finally resolve this issue.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![njoliat](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/njoliat/32/931_2.png) [@njoliat](https://forum.juce.com/u/njoliat)\
**Post date:** [June 14, 2016, 5:59pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/6 "2016-06-14T17:59:05Z")

</div>

Has anybody made any progress with this? I noticed that the problem seems to go away if I run JUCE at a sample rate of 44100, but it occurs if I run it at 48k.

---

<div class="post-metadata">

**Author:** ![sprkng](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@sprkng](https://forum.juce.com/u/sprkng)\
**Post date:** [July 6, 2019, 11:59am UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/7 "2019-07-06T11:59:05Z")

</div>

Still no update on this? I have a very similar problem: Audio noise when input channels enabled, despite only playing a simple sine wave or something…

Using PulseAudio for both input/output, Xonar D1, Ubuntu 18.04.

Noise goes away if I reduce buffer size to 128 (default sample rate 44100Hz) or increase sample rate to 176400Hz (default buffer size 512) but anything in between get a pulsing buzz sound added to it

---

<div class="post-metadata">

**Author:** ![codePlay](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@codePlay](https://forum.juce.com/u/codePlay)\
**Post date:** [September 17, 2019, 1:30pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/8 "2019-09-17T13:30:57Z")

</div>

I measured time between callbacks to getNextAudioBlock(), and it is irregular.

This behavior is attenuated with smaller buffer sizes, and tasks that occupy most of the time interval that corresponds to the buffer. It seems the function is called as often as the CPU is capable of for a few cycles, then the rush is compensated by a delayed call.

When the CPU is busy enough, callbacks become more regular and audio works with inputs on. Without inputs, audio works well even with the irregular callbacks.

This test was on Debian 10, real time linux kernel, core i7 CPU.

---

<div class="post-metadata">

**Author:** ![aking7](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@aking7](https://forum.juce.com/u/aking7)\
**Post date:** [February 9, 2020, 4:05pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/9 "2020-02-09T16:05:05Z")

</div>

I am also struggling with this when using ALSA with Raspbian Buster on an RPi 3b+. Working great when audio inputs are disabled but get dropouts as soon as I enable them and have my AudioSource copy them to the output.

Edit: Very odd, but it seems to be fixed after installing `pulseaudio` and removing it again (I had it uninstalled to begin with).

Edit 2: The issue has returned after running audio for 20-30 mins.

---

<div class="post-metadata">

**Author:** ![johngalt91](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johngalt91](https://forum.juce.com/u/johngalt91)\
**Post date:** [March 29, 2020, 10:00pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/10 "2020-03-29T22:00:47Z")

</div>

> [@aking7](#):
>
> Edit: Very odd, but it seems to be fixed after installing `pulseaudio` and removing it again (I had it uninstalled to begin with).

I’ve been reading about ALSA and pulseaudio recently, and it seems some users in HiFi DACs forums have been having problems with it. IIRC some guys fixed it reseting the configuration of pulseaudio (but don’t quote me on that). Anyway, found Debian and Archlinux distro troubleshooting wikies talking about pulseaudio problems and solutions:

[https://wiki.debian.org/PulseAudio#Solving\_Problems](https://wiki.debian.org/PulseAudio#Solving_Problems)

[https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting](https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting)

Or even [totally disabling it and using only ALSA](https://kodi.wiki/view/PulseAudio/HOW-TO:_Disable_PulseAudio_and_use_ALSA_(without_removing_PulseAudio)_for_Ubuntu#Removing_PulseAudio_from_Ubuntu_-_why_it_may_not_be_such_a_good_idea)

Have you guys keep having this problem/solved it? I can’t test it yet since my Raspberry soundcard is yet to arrive

---

<div class="post-metadata">

**Author:** ![aking7](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@aking7](https://forum.juce.com/u/aking7)\
**Post date:** [March 30, 2020, 7:34pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/11 "2020-03-30T19:34:24Z")

</div>

Unfortunately, I’m still having the same problem. I bought a Raspberry Pi 4 that I need to configure and test it with.

---

<div class="post-metadata">

**Author:** ![johngalt91](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johngalt91](https://forum.juce.com/u/johngalt91)\
**Post date:** [March 30, 2020, 7:39pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/12 "2020-03-30T19:39:28Z")

</div>

Try disabling Pulseaudio and using only ALSA (if you run only 1 audio application at a time) or ditching Pulseaudio for Jack. Afaik Pulseaudio is a more “generic desktop” oriented audio server which I guess is fine for casual audio stuff (browsing, watching some video) but many people doing audio stuff are having some trouble with it, whereas Jack is more suited for those matters

---

<div class="post-metadata">

**Author:** ![aking7](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@aking7](https://forum.juce.com/u/aking7)\
**Post date:** [March 31, 2020, 7:43am UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/13 "2020-03-31T07:43:58Z")

</div>

It is already uninstalled, but I still have problems when using the ALSA inputs.

---

<div class="post-metadata">

**Author:** ![SimonH](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@SimonH](https://forum.juce.com/u/SimonH)\
**Post date:** [September 23, 2021, 1:24pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/14 "2021-09-23T13:24:52Z")

</div>

Hey all,  
I run in similar symptoms, you can hear here: [sound\_example\_link\_to\_dropbox](https://www.dropbox.com/s/nvj9x2ks5pcqmt9/23.09.21.m4a?dl=0) (sinewave and pitch are part of aimed effect)

I run into this issue on Ubuntu 20.04 with juce 5.4.7 (to reduce the sources of other errors i didnt update)

As a beginner in juce and c++ I have no idea how to solve it and would be truly grateful to get help.

Have you @aking7 @codePlay found a way to solve it?

---

<div class="post-metadata">

**Author:** ![wheel](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@wheel](https://forum.juce.com/u/wheel)\
**Post date:** [November 9, 2021, 6:49pm UTC](https://forum.juce.com/t/playback-glitching-with-alsa/14210/15 "2021-11-09T18:49:53Z")

</div>

for whom it may concern.  
high load cpu (around 80% in user space) and setting in a JUCE app a number of input channels to zero both mitigate cracks and pops. those workarounds get me confused.  
however, as I found out at Discord, the proper solution is launch jack server. just running **qtjackctl** should help out.
