I recently bought an electric guitar. But I didn’t buy an amplifier or an effects pedal. My plan was simple, connect my guitar to my Linux machine and use a virtual guitar amplifier. Traditionally a guitar amplifier amplifies the guitar signal and produces the sound through its speakers. Most modern amplifiers can also modify the tone produced.

But we have machines with billions of transistors, surely we can use them instead? That’s right, we can! On Linux, Guitarix is a virtual amplifier which also provides a lot of effects with minimal latency. It is FOSS and is designed to work with JACK. Lets start off by connecting your guitar to the linux machine.

Connections Link to heading

You need to connect your guitar to your Linux machine, while there are multiple ways for this, the simplest and most popular option is to use an audio interface. An audio interface converts the audio signal from the pickup into a digital signal for the machine. I picked up a 3rd Gen Scarlet 2i2 for 100€ from ebay-kleinanzeigen.

Scarlet 2i2 audio interface

We connect the guitar to the audio interface using a quarter inch cable.

Guitar

Finally, we connect the audio interface to the Linux machine; for the Scarlet 2i2, I simply plugged it into the USB-C port on the back.

Linux Configuration Link to heading

Install Guitarix Link to heading

Guitarix interacts with JACK to provide real-time, low-latency audio. For pipewire users, there is a pipewire implementation called pipewire-jack. We will use qpwgraph to create the correct audio routing, i.e. from the audio interface to Guitarix and from Guitarix to the speakers. To install these packages on Arch Linux, we can run:

1
sudo pacman -S guitarix pipewire-jack qpwgraph

Groups Link to heading

To ensure we have least latency for the user running guitarix we need to add them to the following group:

  • realtime (create if it doesn’t exist)
  • audio
1
2
3
sudo groupadd realtime # creates the group
sudo usermod -a -G realtime $USER
sudo usermod -a -G audio $USER

Make sure you logout/login (or reboot) to make sure your user is added to the groups. You can always check by running groups.

Latency Link to heading

To reduce the audio latency we want to set the required node.latency in pipewire-jack. To do this, we first copy the sample file to the user’s config:

1
cp  /usr/share/pipewire/jack.conf  ~/.config/pipewire/jack.conf

Then we change the node.latency value to 128/48000 by uncommenting and modifying the line.

Ulimit Link to heading

Finally, make sure that your ulimit -l value is set to unlimited. If not, you’ll see an error like system init *** mlockall failed . If your ulimit value is not unlimited, you can create an exception rule by creating the file /etc/security/limits.d/audio.conf with content:

1
2
@audio   -  rtprio     95
@audio   -  memlock    unlimited

QPWGraph Link to heading

In qpwgraph make sure you pipe the output of your audio interface to the input of guitarix and the output of guitarix to the input of your speakers.

QPWGraph showing connections

Conclusion Link to heading

Run Guitarix and see that you have no errors.

Guitarix

That’s it! You should now be able to play your guitar and hear the audio being routed from Guitarix to your speakers. Have fun rocking out! \m/


This is post 005 of #100DaysToOffload.