Edit on GitHub

Transforming MIDI-Mathematical operations

Considering the numerical nature of MIDI events, it can be tempting to apply mathematical transformations to our MIDI regions by using mathematical operations. Ardour makes it very easy and powerful with the Transform tool.

MIDI transformation
MIDI transformation

Accessing the Transform tool is done by right clicking the MIDI region >name_of_the_region > MIDI > Transform…

To act on a property, it must be selected in the Set field, then the target value must be changed using the two following fields. To add more operands the "+" sign should be clicked to create new lines. These can be removed using the "-" sign on the right of the newly created lines.

In the picture above, the Transform tool has been used to add a bit of humanization, by slightly changing the velocity of each note of the region, by a random number between -19 and +19 from its original velocity. So three operations are applied:

  • Set velocity to this note's velocity
  • + a random number from 1 to 20
  • - a random number from 1 to 20

Each note will trigger a calculation of its own, so its velocity will be increased by a random number between 1 and 20, then decreased by a random number between 1 and 20.

The properties that can be computed are:

  • note number (eg C2 is note number 24, C#2 is 25 and so on)
  • velocity (the global intensity of the note, between 0 and 127)
  • start time (in beats)
  • length (in beats)
  • channel

and the calculation may be based on the following properties:

  • this note's
  • the previous note's
  • this note's index (number of the note, i.e. the first one is 0, the second is 1, etc.)
  • exactly (for a constant value, between 1 and 127)
  • a random number from lower to higher (lower and higher beeing constant values between 1 and 127)
  • equal steps from lower to higher (lower and higher beeing constant values between 1 and 127).

The mathematical operators can be:

  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (euclidian division)
  • mod (remainder of the euclidian division).

All these operations can be very handy, as long as there is a mathematical way to achieve the targeted goal. Beware though of odd "border cases": division by zero (which does nothing), using the note's index and forgetting it starts at 0 and not 1, etc.

Very interesting results can nevertheless be created, like humanizing (randomizing the velocity, start time and duration of all the notes), creating arpeggios, automating tedious tasks, transposing, etc.