Linux Audio

I’ve recently started learning about signal processing, and a programming language called faust. They are very linux focused, and so I figured the best way to get up and running with it would be to dive into linux, it’s been a while since I really gave linux a fair look, so I was due for it.

Without digressing too far, I would like to announce that I now quite like linux, and I could pretty much use if for all of my home computing apart from gaming.

Anyhow I’m running Ubuntu Studio which is an audio-focused Ubuntu derivative, and there was one little snag (probably because I don’t have a separate low-latency audio capture device), which is to do with a Linux audio platform called JACK. JACK and Pulse Audio (Ubuntu’s built in audio platform) don’t always get on, or at least they weren’t taught to share – if an process, such as spotfify, launches and triggers pulse audio to grab control of the audio hardware, jack just plain won’t work. So, the way to make sure this doesn’t happen is to start JACK first, and then funnel all Pulse Audio apps through it out to the hardware. This is pretty straight forward, but it requires you to set the “PulseAudio JACK Sink” as the default output device in PulseAudio each time you start up, which is easy, but too repetitious for the engineer in me. Anyhow turns out there’s a CLI (Command-line Interface) for Pulse Audio, so I wrote a script.

First things first, we need to start JACK:

jack_control start

We then need to set the sink/source for pulse audio so that JACK sits between the hardware and PulseAudio

pacmd set-default-sink "jack_out"
pacmd set-default-source "jack_in"

I also had some weirdness with the volume on my front audio port getting set to randomly low values, so I forced that port to 100%:

pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo 100%

That was great, but my headphones (and certainly not my speakers) are not exactly studio monitors, so they need a bit of EQ’ing. To do this I used JackRack, and the Multiband EQ. To make this work I had to connect JACKRack between PulseAudio, and the JACK system out. This can be done via a tool like QJACKCtl, but you can script it as well.

To start JACKRack:

jack-rack /home/guy/Code/JackInit/headphone_eq.xml &

Don’t for get the & to so that your terminal session doesn’t get blocked. Then you can connect JACKRack between PulseAudio and the system out:

jack_connect PulseAudio\ JACK\ Sink:front-left jack_rack:in_1
jack_connect PulseAudio\ JACK\ Sink:front-right jack_rack:in_2
jack_connect jack_rack:out_1 system:playback_1
jack_connect jack_rack:out_2 system:playback_2

And finally remove the direct connection from PulseAudio to the system out:

jack_disconnect PulseAudio\ JACK\ Sink:front-left system:playback_1
jack_disconnect PulseAudio\ JACK\ Sink:front-right system:playback_2

I put all these into some scripts, and set Xfce up to run the script on startup, using the GUI.

The scripts are up on github with a few embellishments.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s