Linux/ALSA output broken


#1

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

 

the device is a HDA INTEL (non-usb 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.

 

Weird


#2

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.


#3

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

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


#4

Also make sure that JUCE is 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.


#5

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


#6

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.


#7

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.


#8

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


#9

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


#10

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.