Using a Focusrite 18i8 under Linux

Focusrite’s Scarlett USB audio interfaces are cost-effective units with a wide range of input and output options. Out of the box they can be used by most digital audio workstations on Linux because they are USB class-compliant. However, besides the entry-level models (Solo, 2i2 and 2i4), you will certainly miss a few features for recording that just cannot be accessed due to a lack hardware controls. For these you need to use the Focusrite Control software which – as you can imagine – is available only for Mac and Windows. Fortunately, there is a device specific ALSA driver for the Scarlett devices that exposes mix controls to set gains on the different ins and outs as well as controls to enable Hi-Z or Pad modes on certain inputs. Unfortunately, using alsamixer to set these values is a huge PITA.

Now Robin Gareus, a very active contributor to Ardour, JACK and LV2 made the scarlett-mixer for his Scarlett 18i6 that allows one to control all the parameters with an easy-to-use graphical user interface. Now, I counted one and one together, made the appropriate changes and added support for the 18i8. So, no longer do I need to resort to the borderline crazy Alsa Json Gateway software 🙌

OpenCL resource tracking

I wrote about the woes I had with the abysmal OpenCL implementations by both AMD and NVIDIA. Now, it’s not always the fault of others and I recently had to debug a GPU memory leak originating from our own software. The first thing I needed to indentify was if all OpenCL resources were referenced and dereferenced equally. However, the entire system is (as usual I suppose) a dynamic pile of layers of abstractions, so simple reasoning from the code was out of the question rather quickly. I remembered the GObject tracking library from which I took the interception and backtrace bits, re-implemented the OpenCL calls dealing with resource allocation and unreferencing to make the LD_PRELOAD library Usage is similar to the GObject tracking library gobject-list:

$ LD_PRELOAD=/path/to/ ./app

with an example output like (now):

OpenCL objects alive
Contexts        1/1
Command queues  0/1
Buffers         0/9
Samplers        0/0
Kernels         3/11

Memory leaks
Leaking         0 B

Moving music content

I decided to move all music and bass related content to its own platform over at because it does not really fit the technical stuff here. No redirects were set up, so if you happened to have linked there … update your links accordingly.

Converting PDF pages to a single image

I am always amazed how far one can get by chaining the output of simple programs to create something bigger. This time, I had to convert the pages of a PDF file to a single PNG thumbnail image. As I learned in five minutes this is super simple with pdftoppm, Imagemagick’s convert tool and a Makefile to hook it up together:

%.png: %.pdf
	pdftoppm -png $< tmp
	convert +append tmp-* -resize x320 -unsharp 0x1 $@
	rm tmp-*

What I do here is calling pdftoppm to generate numbered PNG files with a tmp- prefix. convert reads them, appends them horizontally (denoted by the + sign), resizes the final image to a height of 320 pixels and filters the output with an unsharp mask to “recover” some of the lost sharpness.

To make the pages stand out you can also add a black single pixel frame and a white separation border with

%.png: %.pdf
	convert $<-*.png -resize x320 -unsharp 0x1 -bordercolor black -border 1x1 -bordercolor white -border 2x2 +append $@