OSC pots in Carla, KxStudio

Always get the same OSC port in Carla - KxStudio.


A few months ago I found an audio application called Carla, from KXProject. I's a fantastic app that allows you to control Jack connections in a graphic environment. It also works as a host for audio plugins. The best part is that you can control the hosted plugins by OSC messages, but unfortunately you get a random UDP port each time that you start the app which is very annoying. I'll show you a method to get the same OSC port all the time.


Carla, from KXProject, is an amazing application that you can download for free here. It allows you to connect/disconnect Jack clients using a well designed graphic interface. It's similar to Patchage but more advanced. I have used it for a few months in LMDE distribution and it seems to be very stable.

Beside the fact that it's a good app for controlling Jack, the coolest feature is its ability to host almost any type of audio plugin and control them by OSC messages! Yes, you can use any OSC controller to control your plugins and that's exactly what I was looking for. In the past I used Lemur Controller (for iPad) as a touch interface to control my audio programs and now I'm creating a Qt app with the same purpose. In both cases Carla has been the interface between the control interface and the audio plugins.

So, basically, every time that you run Carla it starts a UDP service. You can see the UDP port in Carla->Help->OSC. In this menu you can also see some simple examples about how to send OSC messages to Carla. But, as I told you before, each time that you run this program you will get a different UDP port, so you must check this menu every time that you run Carla and reconfigure your OSC controller.

How to get the same OSC UDP port in Carla

If you don't have problems compiling Carla from the source code this is the perfect solution for you. I tested this procedure in Carla 1.2.4 and Carla 2.0 beta 1 and it works fine in both versions. From now on I will consider Carla 2.0 beta 1. I will use gedit for editing the source code but you can use any text editor.

1. Download the source code for Carla


2. Open a terminal, go where you downloaded the file and uncompress it:

tar -xvf Carla-2.0beta1-src.tar.bz2

3. Open this cpp file with a text editor

gedit ./Carla-2.0beta1-src/source/backend/engine/CarlaEngineOsc.cpp

4. Search for this line of code (line 90)

fServerUDP = lo_server_new_with_proto(nullptr, LO_UDP, osc_error_handler_UDP);

5. Change the previous line by these 2 lines

const char* myPort = "12345";

fServerUDP = lo_server_new_with_proto(myPort, LO_UDP, osc_error_handler_UDP);

6. Dependencies

Before you compile Carla you need to install some libraries. In LMDE distribution I had to install the following packages:

sudo apt-get install liblo-dev libqt4-dev pyqt4-dev-tools mesa-common-dev libncurses5-dev libpulse-dev libalsa-ocaml-dev libgtk2.0-dev libgtk-3-dev qt5-default qttools5-dev-tools libmxml-dev libzita-* libsmf-dev libsndfile1-dev libfluidsynth-dev python3-pyqt4

7. Compile and install Carla:

make -j 8

make -j 8

sudo make install


Now you have Carla with a static UDP port. If you want to change the port you just need to go to step 4, change the port number, recompile and reinstall. That's it.

NOTE1: For some reason I don't understand you must compile twice. That's why "make" appears two times in step 7.

NOTE2: "-j 8" option in step 7 allows you to run 8 jobs at the same time. I use that option because I have an I7 processor that runs 8 threads. Check how many threads can run your processor and change this number. If you are not sure just run "make".

NOTE3: The most difficult part was to find the right lines of code to be modified and then find the dependencies. Now that you have all that here, this process should be straight forward.

NOTE4: Other Linux distributions may not have the same libraries than LMDE. If that's the case you might have some problems compiling Carla and you will need to find the missing dependencies. It would be nice if you can share you experience using this tutorial in other Linux distributions.