For some time I am learning how to record music on GNU/Linux. A very handy tool for managing your JACK connections is qjackctl, a small tool that allows you to set up the JACK audio server, draw connections between client and a lot more. There are more tools that do that, but none of them did the job as good as qjackctl, despite the fact that qjackctl was not the most appealing candidate in terms of visual appearance.
This led me to dive into the qjackctl source code and see what’s going on inside. Well, there seems to be a reason qjackctl has stuck on version 0.3.x. qjackctl serves its purpose while the code was hard to maintain. The original author, Rui Nuno Capela, admitted that himself. At the same time, I was developing QJack for a different purpose, a Qt/C++ wrapper around the libjack C API. In an object oriented environment you do not want to have global callback functions, even more, with a Qt based program, you’d like to have signals and slots. I thought cleaning up qjackctl and integrating QJack to make an example of how you can benefit from using QJack (in terms of stability and clean code) was a good idea.
It was not. I spent countless hours refactoring code, but it’s almost done. And now that I can start rebuilding (and adding!) features, the fun begins. I started with the connections panel. Here is a direct comparison of the original version and the improved one.
At first sight, pretty similar – under the hood, entirely different. On the visual side I didn’t want to reinvent the wheel, I just improved what was already there:
- Alternating row color help you to visually assign a connection to the port’s name
- Antialiasing on port connections
- The scroll bar of the left tree widget moved to the left in order to not distract the visual connection between cable and port
- Audio and midi ports can be viewed in a single view rather than in separate tabs
- It is now possible to choose between four different selection modes rather than just single selection, so you can choose multiple ports and connect them instead of repeatedly selecting another port and clicking connect or dragging
- In addition to expanding all items, you can collapse all items
- Better icons (where applicable)
- No gap between cables and ports
- Cable colors now have a meaning: Red color (red = positive, source) means you selected a send port that the cable is connected to, blue color (blue = negative, sink) indicates you selected a return port that the cable is connected to, green means that both selected ports are connected through that cable.
- The “cable area” is scrollable. If you hover over it, scrolling will scroll both port views by the same amount
In conclusion, being flexible through refactoring code that does not directly belong to the user interface lowered a lot of technical barriers for cleaning up and extended the traditional functionality with new, meaningful features.
You can following qjackctl refactoring here: https://github.com/cybercatalyst/qjackctl/commits/refactoring
If you are interested in QJack, see here: https://github.com/cybercatalyst/QJack