Open Music Kontrollers

2014 - Week 32

There are endless ways how we can map x-dimension to pitch. This patch-a-week is focused on 12 tone equal temperament, the predominant scale in modern western music. We will elaborate a bit on how to map a continuous x-dimension (e.g. from the Chimaera) to pitch and frequency.

Fractional MIDI notes

Most musicians will be familiar with MIDI notes, let us therefore base our mapping on top of the latter. But as we are facing a continuous scale, and MIDI notes are integer, we will use the concept of fractional MIDI. As two MIDI notes are evenly spaced by 100 cents), we can easily derive a definition of a fractional MIDI value representing a continuous scale:

24 = C (1) 24.5 = C+50cents=C+14tone(2)24.75 = C+75cents=C+38tone(3) 25 = C# (4)

Linear mapping of x-dimension

With number of sensors n , octave oct and base note m0 , we can derive a linear mapping from x-dimension [0,1] to fractional MIDI notes m(x) . The formula for the base note may look a bit weird at first glance, but it has its reason, as the formula is adapted to the default engravings on the Chimaera controller. Depending on the case size, the engravings will slightly differ, e.g. the cyclic pattern will start at different offsets. This is needed in order to arrange a many complete pattern as possible on any case size. The formula will take the variable offset into account. The following equations will map the span of three sensors to one MIDI note, e.g. a 12 note, whereby the middle sensor will coincide with the integer note.

We start off by shifting the base MIDI note to the right octave’s C note, then subtract a 14 note (which corresponds to 1.5 sensors) and finally subtract by a variable offset. The offset off is straightforward to derive. The x-axis with its n sensors is divided in as many complete half-octaves (6 MIDI notes, each 3 sensors wide) and the remaining sensors are distributed equally to the bottom and the top of the scale, e.g. divided by 2 and the converted to fractional MIDI notes, e.g. divided by 3.

The final fraction MIDI note m(x) will then be a simple linear relationship of dimension x , offset by base note m0 .

off = n%18 6 =n%(63) 32 (1) m0 = oct120.5off(2)m(x) = m0+xn 3 (3)

linear x-mapping

Linear mapping from x-dimension to fractional MIDI for n=48 sensors and oct=2.

Stepwise mapping of x-dimension

Sometimes it will be handy to have integer MIDI notes only, without a continuous mapping. This can easily be achieved by rounding the continuous mapping m(x) to a stepwise mapping ms(x) which increases by integer values.

ms(x) = round(m(x))(1)

stepwise x-mapping

Stepwise mapping from x-dimension to fractional MIDI for n=48 and oct=2.

Polynomial mapping of x-dimension

And sometimes it may be advantageous to have something in between a linear and a stepwise mapping, e.g. a relationship where the main mapping is a stepwise, but between the steps, there will be a continuous relationship. When plotted, this looks like a curve with wide plateaus at each integer step. The higher the polynomial order k , the wider the plateau.

Such a polynomial mapping is calculated by first deriving the fractional difference mf(x) between linear and stepwise mapping. The fractional difference (which ranges over [0.5,0.5] ) is then put into its corresponding order k and rescaled to the original range and added to the stepwise mapping.

mf(x) = m(x)ms(x) (1)mp(x) = ms(x)+(mf(x)2k1 k )k for k=1,3,5,... (2)mp(x) = ms(x)+(mf(x)2k1 k )ksign(mf(x)) for k=2,4,6,...(3)

For an order k=1 we get the initial linear mapping. Note that there are two slightly differing formulae for even and odd polynomial orders.

polynomial k-2 x-mapping

Polynomial mapping from x-dimension to fractional MIDI for k=2, n=48 and oct=2.

polynomial k-3 x-mapping

Polynomial mapping from x-dimension to fractional MIDI for k=3, n=48 and oct=2.

polynomial k=5 x-mapping

Polynomial mapping from x-dimension to fractional MIDI for k=5, n=48 and oct=2.

polynomial k=9 x-mapping

Polynomial mapping from x-dimension to fractional MIDI for k=9, n=48 and oct=2.

A ready to use SuperCollider class incorporating all three types of x-dimension mapping (linear, stepwise, polynomial) can be get at our SuperCollider repository.

Last update - 15 Jul 2019

Copyright © 2014-2019, Hanspeter Portner, Open Music Kontrollers, cc-by-sa 4.0.