Skip to main content
  1. Writing/

Knobs

Development Plugin Python Tools
knobs is a command-line utility to generate synth knob animations.

Overview
#

While learning how to build audio plugins, I needed to generate animations for turning a knob. This is accomplished by

  1. Taking an image with the knob at zero.
  2. Rotating the image as many times as we want until the pointer is at eleven (the more intermediate images, the smoother the knob will be).
  3. Stitching all the images together in a single image.

When it comes to building the UI for your audio plugin, you bind a parameter to this image, and the engine will scrub through the animation as the parameter value changes, making it look like the knob is turning.

After struggling with GIMP and Script-Fu for a bit, I decided to do this in Python. I found a post by Thomas Faltenbach describing this exact problem , along with some code, which I promptly stoleadapted. I believe I have simplified a few things in the process.

Back of the napkin
#

If you want to look at the code , this is roughly what’s happening:

As you can see, the red knob needs to travel 270° between its minimum and maximum positions, while the blue knob will need to travel 315°. If we want to accomplish this with 10 images, we need to rotate each image by 30° each time for the red knob, and 35° for the blue one. The starting angle is measured from 0° to the pointer’s minimum position.

I put together two very crude knobs showing what this looks like in action. This is what both knobs look like when resting at zero:

225°255°

These are the resulting animations:

225°255°

You can get the code from GitHub.