# Linux Audio Survival kit.

## Getting Super Audio Powers

Linux it's far from perfect , but, it own some features that make the audio production very handy and affordable, mostly of the software and audio applications can be interconnected and sync up through Jack turning our desktop in a super-flexible modular workstation.

#### Which Linux to use?

There are many Linux flavors and in a general sense is not a big difference between a distribution and another, we can turn whichever Linux flavor in a capable OS to audio production.

Some desktop environments have a better performance, and this is due to how they manage the graphical resources, I highly recommend distributions that use KDE plasma, XFCE or lxde as desktop environment, disable the desktop effect will improve your experience in terms of performance and response , this is specially true if you are running an old hardware

### Setup Linux for audio production&#x20;

In this guide we follow the complete process to set up our Linux on an audio capable operative system.

#### Installing the low latency kernel

open a terminal and type:

```
sudo apt install linux-lowlatency
```

#### Installing KXStudio repositories:&#x20;

**...Wait, why  to install KXStudio Repositories?**\
\
It’s not a mandatory step, but it’s highly recommended. KXStudio provides a wider range of specialized tools and more up-to-date versions for audio production. Unfortunately (at the time of revisiting this guide), the maintainer **FalkTX** has not released a new “official” repository signature for recent Ubuntu/Debian versions, so there’s **no full guarantee of compatibility**, even though most packages still work fine.

to install the KXStudio follow the instructions of this link:  \
\
<http://kxstudio.linuxaudio.org/Repositories>

#### Upgrading your system

code:

```
sudo apt update && sudo apt upgrade
```

{% hint style="info" %}
after a "sudo " command the system will ask the root password, it will be not shown in the screen
{% endhint %}

#### Installing Jack

code:

```
sudo apt install jackd2
```

#### Installing qjackctl

code:

```
sudo apt install qjackctl
```

#### Installing pulseaudio-module-jack

code:

```
sudo apt install pulseaudio-module-jack
```

#### optional Lightweight OSC library

```
sudo apt install jack-tools 
```

#### Configuring real time access:

Add your current user to the audio group\
code:

{% hint style="warning" %}
replace **"username"** in the code bellow by your computer user name
{% endhint %}

```
sudo adduser username audio
```

Give the audio group real time access editing /etc/security/limits.d/audio.conf&#x20;

Kubuntu code:

```
kate sudoedit /etc/security/limits.d/audio.conf
```

Xubuntu code:

```
sudo mousepad /etc/security/limits.d/audio.conf
```

Lubuntu code:

```
sudo leafpad /etc/security/limits.d/audio.conf
```

Ubuntu code:

```
sudo gedit /etc/security/limits.d/audio.conf
```

change the content of the file to this values:

```
@audio - rtprio 99 
@audio - memlock unlimited 
```

Reboot your system.\
code

```
sudo reboot
```

#### A quick Checkup of the audio capabilities

All available playback audio devices.\
code:

```
aplay -l
```

The list of available capture/recording audio devices\
code:

```
arecord -l
```

MIDI playback ports devices capabilities\
code:

```
aplaymidi -l
```

the MIDI recording audio ports\
code:

```
arecordmidi -l
```

### Configuring Jack

Jack (Jack Audio Connection Kit ) is a professional sound server daemon that  allow you  to route audio and MIDI between applications and connect hardware with software.

**Qjackctl** is a simple application to control the Jack sound server,  to launch it  open a terminal and type:

```
qjackctl
```

{% hint style="info" %}
You can launch the software applications  clicking them icon in the application menu.
{% endhint %}

![Qjackctl](/files/-LZwfMNhfFQ5RTNNANnK)

On the  Qjackctl UI hit "setup" , it will open the Jack audio connection kit setup window.

Press in the **Driver** selection menu and choose **alsa**,  it will be your audio backend interface to use.

![ALSA Driver](/files/-LZwePsrG9fgRYEQyEqh)

Then,  in the Interface selection menu choose your sound device, it could be your integrated sound device or a external hardware, in my setup I own a  focusrite Scarlett Solo and I choose this option in the list.

![Audio Interface](/files/-LZweUjEdkqHM_5fM1AE)

The next step is select the  ideal values  for the **Sample Rate**,  **Frames/Period** and **Period/Buffer** it is very important because find the right relationship between this values will have effect the quality and the performance of our system. While the numbers are higher we will have better audio quality, but it is not so easy, because this will have a direct effect on the latency too.

$$
(Frames / Sample Rate ) \* Periods = Latency
$$

![Theoretical Latency](/files/-LZwx86rN-x3lBtvhO2H)

You can swap different values until you find the ideal values,  or you can use this guide to find them:

[List of ideals Jack frame & period settings for USB interface](https://wiki.linuxaudio.org/wiki/list_of_jack_frame_period_settings_ideal_for_usb_interface)

Finally you must check  the "Realtime" option in the setings window and press "OK", all the changes will take effect the next time  that you run the Jack audio server.

#### A quick checkup

Open a console  and type:

```
jackd -d alsa --help
```

It should  give you back a list  of all available JACK server options of your audio backend.

![Jack options](/files/-LZzE6BnmazCxv6Q5vd4)

### CPU governor

Mostly of the Linux distribution are setting by default as "**powersave**" it sets the CPU statically to the lowest frequency within the borders of scaling\_min\_freq and scaling\_max\_freq.

To change the mode to "**performance**" open a console and type:\
code:

```
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
```

in order to set it back to "**powersave**" mode, open a terminal and type\
code:

```
echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
```

You can create  a script  to run in performance mode, open a text editor and type:

```
#!/bin/bash
clear
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
```

Save it in the home directory under the name "performance mode"  and you can run it in the console with&#x20;

```
./performance mode
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coroto.gitbook.io/linux-audio-survival-kit/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
