OMK Logo
OMK Title

Patch-a-Week

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:

$$\begin{eqnarray} 24 &=& C \\ 24.5 &=& C + 50 cents &=& C + \frac{1}{4} tone\\ 24.75 &=& C + 75 cents &=& C + \frac{3}{8} tone\\ 25 &=& C\# \end{eqnarray}$$

Linear mapping of x-dimension

With number of sensors \(n\), octave \(oct\) and base note \(m_0\), 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 \(\frac{1}{2}\) 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 \(\frac{1}{4}\) 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 \(m_0\).

$$\begin{eqnarray} off &=& \frac{n \% 18}{6} = \frac{n \% (6 \cdot 3)}{3 \cdot 2}\\ m_0 &=& oct \cdot 12 - 0.5 - off \\ m(x) &=& m_0 + \frac{x \cdot n}{3} \end{eqnarray}$$

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 \(m_s(x)\) which increases by integer values.

$$\begin{eqnarray} m_s(x) &=& round(m(x)) \end{eqnarray}$$

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 \(m_f(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.

$$\begin{eqnarray} m_f(x) &=& m(x) - m_s(x) \\ m_p(x) &=& m_s(x) + (m_f(x) \cdot 2^\frac{k-1}{k})^k &for& k=1, 3, 5, ... \\ m_p(x) &=& m_s(x) + (m_f(x) \cdot 2^\frac{k-1}{k})^k \cdot sign(m_f(x)) &for& k=2, 4, 6, ... \end{eqnarray}$$

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

WANTED:
Beta Testers

After a high interest at Maker Faire Rome, we are now running a beta-testing campaign to collect more comprehensive feedback of first-hand experiences of our final Chimaera prototype design from interested individuals. Get in contact with us. Now.

Please support free/libre software and hardware designs.

or

donate bitcoins

or

request bank credentials via encrypted mail for SEPA transfers.

Last update - 09 February 2016

GitHub Google+ SoundCloud Vimeo

Copyright © 2014-2017, Hanspeter Portner, Open Music Kontrollers, cc-by-sa 4.0. Uses libre javascript.