The MIDI hand: Documentation

All physical component interactions are interpreted by a Python program to send MIDI messages to a MAX/MSP interface that interacts with audio. This page describes in more details the components functionalities.

Buttons

Each button sends a MIDI message through the same status byte and has a unique MIDI note (A = 1; B = 2; C = 6; D = 10) in the data byte. (more info)

These specific values always give a unique result when being added together, allowing each specific button combination to be interpreted correctly.

The note values are then added to a counter, which is sent through a MIDI Note ON/OFF message:

midiNoteOn(chan, COUNTER, vel)

Micro:bit sensors

The micro:bit integrated sensors are also used to interact with audio in MAX/MSP. All MIDI messages from sensors are sent continuously with a 20ms gap between each.

Conversion of sensors data to MIDI

In this project, three sensor parameters are used:

  • compass heading
  • accelerometer Y and Z axis coordinates

The data is converted to MIDI velocity (range: 0-127) with the following equation:

round(abs(X / Y) * 127))

Where X is the sensor data and Y is a constant defined by the range of data of the component (e.g: 359 for compass sensor).

The data is then sent through a MIDI Control Change (CC) message:

midiControlChange(chan, n, compass_heading)

Compass

The compass heading is mapped to the parameters (cut-off frequency and resonance) of a biquad filter in MAX/MSP.

The compass heading interpretation can be summarised with the following figure.

Potentiometer

The control of the filter is designed for the user to be oriented to the precise north direction when manipulating the MIDI hand. 

This requirement is obviously not practical for most situations, so a potentiometer has been added to the circuit to “re-calibrate” the compass heading direction.

The potentiometer can be tweaked to an estimated range of 270°. The data is interpreted into MIDI data and is then converted to positive and negative values.

Example

In this situation, the user is facing the North East. By tweaking the potentiometer 45° to the left, the new orientation will be heading back in the north direction.

(When happening in the Python program and MAX/MSP patch, this processing happens in MIDI values (1-127), but this example has been kept in angle degrees to facilitate the explication).

Sensitivity

Because it is very difficult and not natural to keep the arm steady, the compass will be picking up slight variations of heading all the time, creating a “shivering” filter that will not sound pleasantly to the human ear.

The sensitivity of the compass can be adjusted: when the filter button (A) is pressed, the cut-off frequency value is stored. It is then only updated when meeting the following condition:

nX > x + S or nX < x -s

Where x is the stored value, S is the sensitivity value and nX is the new value. 

The value of the cut-off frequency is then updated linearly from x to nX in a specific amount of time depending on the S value (S * 100 ms).

Example

In this situation, the user is facing north, and presses A to activate the filter. The sensitivity is set to 7. If the user’s movement is slightly moving and creates shivering, the filter is not updated, but when the user has moved more than the sensitivity threshold, the filter is then updated in S * 100 ms = 700 ms.

Accelerometer

The Y axis of the accelerometer is mapped to the volume control and a frequency shifter effect in MAX/MSP.

Volume control and frequency shifter

The Y axis is interpreted in MIDI data where the maximum positive value = 1 and the minimum negative value = 1/127. The Y axis controls the volume with the following equation:

sig * (y + 0.5 / 127)

Where sig is the original signal and y is the Y axis coordinate.

In this situation if the arm is oriented down, y < 1 and the volume is decreased. On the contrary, if the arm is oriented up, y > 1 and the volume is increased.

This same Y axis is also used to shift the frequency of a basic oscillator object in MAX/MSP :

f + ((y – 0.5) * 10)

Where f is the original frequency and y is the Y axis coordinate.

In this situation if the arm is oriented down, y < 0 and the frequency is decreased. On the contrary, if the arm is oriented up, y > 0 and the frequency is increased.

Pan LFO Modulation

The Z axis is interpreted in MIDI data where the maximum positive value = 1 and the minimum negative value = 1/127.

The Z axis controls the LFO rate with the following equation:

z/12


Where z is the Z axis coordinate and 12 is an arbitrary value defined by the developer. (What is an LFO ?)

%d bloggers like this: