# Linux/ALSA output broken

**URL:** <https://forum.juce.com/t/linux-alsa-output-broken/15905>\
**Category:** Linux\
**Created:** [November 9, 2015, 1:54pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905 "2015-11-09T13:54:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [November 9, 2015, 1:54pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/1 "2015-11-09T13:54:02Z")

</div>

I'm using the latest JUCE and the DEMO code only, i always get crackling or distorion, i tried raising the thread priority to the max (no luck) renice (no luck) i compiled a low latency kernel (no luck). all other apps in the system work fine with ALSA, i remove pulseaudio completly from the system so there is just pure ALSA

&nbsp;

the device is a HDA INTEL (non-usb&nbsp;device)

```
[root@AMDC2543:~]# aplay -l
****List of PLAYBACK Hardware Devices****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

[root@AMDC2543:~]# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:16.3 Serial controller: Intel Corporation 7 Series/C210 Series Chipset Family KT Controller (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
```

I found one thing that helps, not opening any INPUTS (the demo opens two first inputs by default) but if i close the input devices the distortion goes away.

&nbsp;

Weird

---

<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:** [November 9, 2015, 2:24pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/2 "2015-11-09T14:24:04Z")

</div>

It's probably the synchronising of the input and output streams then.. We've certainly optimised things quite a bit recently as we use ALSA for the Seaboard Grand's built-in synth, which needs to be super-efficient and low latency, but that's not using input channels, of course.

There's actually some work we're planning to do where we use a new synchronisation device to replace some of the older code - when we do that, hopefully this should magically be fixed.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [November 9, 2015, 4:35pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/3 "2015-11-09T16:35:17Z")

</div>

Well i'm sure it won't be magic, just your infinite wisdom :)

I'll wait patiently for the result. Thank you.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [November 10, 2015, 2:18pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/4 "2015-11-10T14:18:38Z")

</div>

Also make sure that JUCE is&nbsp;not using pulseaudio: check this in the audio settings page in JUCE demo. Pulseaudio is not designed for low-latency and you need to increase the buffer size quite substantially to get rid of any crackling. I suggest you select a "real" ALSA output device and not pulseaudio.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [November 10, 2015, 4:33pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/5 "2015-11-10T16:33:31Z")

</div>

Yeah that's the first thing i do, i removed pulseaudio from the OS.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [November 10, 2015, 5:22pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/6 "2015-11-10T17:22:45Z")

</div>

Hmmm this is strange. Are you compiling in debug mode maybe? Try recompiling with "make CONFIG=Release". BTW: I also have the same sound card and audio works fine on my machine in Ubuntu 15.10 even for tiny buffer sizes.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [November 12, 2015, 2:35pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/7 "2015-11-12T14:35:45Z")

</div>

Like i wrote it works fine for me too BUT i need to disable ALL inputs in the audiodevicemanager otherwise i get cracks and distortion. It doesn't make any difference if it's debug/release if the nice is -20 and the alsa thread priority is 10 even with the biffer size @1024.

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 29, 2017, 11:06pm UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/8 "2017-03-29T23:06:02Z")

</div>

hi Jules  
Can I ask what kernel settings you used and how you set priorities in the application to make it run well? I have some audio dropouts with my JUCE application running on mainline 4.10 and I’m wondering if it has to do with kernel settings and/or priority settings in my application.  
thanks  
B

---

<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:** [March 30, 2017, 7:35am UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/9 "2017-03-30T07:35:24Z")

</div>

I didn’t do any kernel tweaking myself, but maybe @ftonello could comment…

---

<div class="post-metadata">

**Author:** ![ftonello](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ftonello/32/149_2.png) [@ftonello](https://forum.juce.com/u/ftonello)\
**Post date:** [March 30, 2017, 10:08am UTC](https://forum.juce.com/t/linux-alsa-output-broken/15905/10 "2017-03-30T10:08:20Z")

</div>

Hi @bschiett,  
It could be many things. JUCE already creates a Real-Time thread in Linux for audio rendering. But it depends on your system. Few things you have to figure it out:

- What is the system load?
- How many programs are running?
- Perhaps you are taking too long to process your audio and missing frames?

Usually I use tools like `htop` to see CPU usage, threads priorities, etc. And `perf` or `lttng` to profile my program.

If you have many tasks running at the same time and small buffer size, you most-likely need to go with a Real-Time kernel to ensure that your audio rendering thread don’t get preempted and always run when it needs to run.
