[sdiy] Detuning in Digital

Olivier Gillet ol.gillet at gmail.com
Mon Apr 2 10:20:47 CEST 2012


In all my projects I represent pitch internally as a 14-bits number.

7 highest bits = MIDI note.
7 lowest notes = fine pitch (this means fine pitch is not adjustable
in cents but rather in 128th, but I don't think it's an issue).

I use a 12x128 entries full lookup table with whatever pitch-dependent
quantity I am manipulating (eg: timer count for DCOs ; phase increment
for digital oscillators) ; for only one octave. I use shifts to deduce
the value for the other octaves.

So the whole algorithm is, given a 14-bits pitch value:
1/ transpose it (add 12 x 128 or sub 12 x 128) until it falls in the
range covered by the lookup table and count the number of octaves it
has been shifted by (it's a loop with at most 10 iterations, no
division / modulo).
2/ lookup the pitch value in the table.
3/ shift by the number of octaves found at step 1.

When memory is a constraint, my top (or bottom) octave table contains
only one half or one fourth of the data points and I use linear
interpolation. No log, floating point, etc... It is reasonable to
think that an approach like that might have been used on older synths.

Olivier



More information about the Synth-diy mailing list