Auto Tune: Path to stability

I added autotune functionality to the analog VCOs and VCFs in the Zoxnoxious synthesizer awhile back. I thought I’d do a quick writeup here. While it was somewhat complicated to develop, it’s quite simple in explanation. There is some math, but it’s not all that scary.

Why do the voice cards require calibration? The analog components will drift a bit as they warm up, and also tracking may vary over a range of octaves. Calibration is a quick way to address both drift and tracking. One might do calibration at power on and a again once everything warms up.

I’m going to assume the reader is familiar with the volts/octave synth standard for tuning. Apply a voltage, get a frequency. Add a volt and the frequency doubles, or goes up one octave.

With the frequency doubling each octave, the above graph looks a lot better if the y-scale is set to logarithmic.

The volts/oct does not say what voltage produces what frequency. So the circuit designer will do this. I’ve also throw on the slide all the scary math equations we’ll be using.

Freq versus voltage where zero volts gives an A0. Also note the formula for finding the voltage difference between two frequencies. We’ll be using that.

Next, I use the Raspberry Pi to measure frequency across the range of octaves. The interval between measurements is something to consider. An interval seems about right.

The Pi applies a voltage (well, DAC value really) and it knows what frequency to expect. It also measures the actual frequency the analog component produces via the Pi’s GPIO pins.

Expected output and measured output across 7 octaves. The expected points are shown in blue, the measured output is the red stars. We’ll do some calibration on the points highlighted.

Start with the low measurement point and calculate how much it deviates from expected.

What I’ll describe below is a static calibration. Basically, take the synth offline for ~20 seconds and snapshot the characteristics of the analog components and assume that’s good ’nuff. If conditions change and tuning isn’t spot on, another static calibration can be done. A different method would be dynamic calibration, where one is monitoring and making adjustments while the synth is in operation. I’m not doing dynamic calibration.

Adjusting the measurement at 1V. Calculate the voltage difference between measured and expected.

This first point tells us if the frontend requests 0.97 volts we should actually output 1 volt. This point in isolation says nothing about what to do if they request any other voltage. We’ll get to that.

Now look at the second point, one octave up.

Adjust the measurement at 2V. Calculate the voltage difference again. This one gets adjusted to the right, versus the previous one to the left.

Similar to the previous, this says what to do if the user requests exactly 2.04 volts. Not all that useful just yet. We’re getting there.

Now we’ve adjusted two points. Let’s see those together on a graph.

The analog component should be operating at 1 Volt/Octave. Here’s the leap. We’ll assume that is true between our two measurements. Then create a correction table that we can use to lookup and voltage between these points.

A correction table of values is created between the measurement points using linear interpolation.

Create a table between the two points. In the examples I’m using voltage. In reality the code deals with discrete 12-bit DAC values. But it’s all the same at the end of the day. It’s a bit easier to comprehend using voltages.

The table makes it easy since we just remap every voltage requested by the frontend. Memory on microcontrollers is cheap. An alternative would be to store the slope and calculate on the fly, so you’d only need to store the slope between the points.

Using the correction table makes it easy to remap input values to output.

What we did above was for a single octave. This process gets repeated across the range of octaves for the synthesizer.

And that is how calibration is done on the Zoxnoxious synthesizer.

Leave a comment

Design a site like this with WordPress.com
Get started