Tutorial 28 - MIDI I:

Note Transposition


Topics

Converting a MIDIFILE into a CHORD-SEQ after transposing its notes

 

Functions used

mf-info, mat-trans,omloop and save-as-midi.

 

 

Description

Converting a MIDIFILE into a CHORD-SEQ is immediately done by patching the first class into the <self> input of the second. Indeed, the CHORD-SEQ class will inherit from the MIDIFILE all its elements, which will be converted following special implemented methods into adequate data . For instance, standard MIDI notes from a MIDIFILE will be multiplied by 100 in order to be handled correctly by a CHORD-SEQ. However, in this example we will retrieve data from a MIDIFILE using mf-info in order to modify its contents and store the results in a CHORD-SEQ.

Patch structure

A: Drag a MIDIfile onto a patch. This will create a MIDIFILE factory. Connect its output to mf-info. mf-info will output a list of lists.

B: In order to work on a particular track, we must know the exact number of tracks in the MIDIfile. Evaluating length will return the number of tracks (here 2). Opening the optional input of mf-info (alt-click) we can choose either to have a particular track or a list of tracks informations (the first track beginning by zero).

C: In our example above, mf-info will output a list of lists related to the first track of our MIDIfile representing each midi event of this track. The format of each list is:

(<MIDI note> <onset> <duration> <velocity> <channel >)

We will use mat-trans (C) to sort each of these parameters in a list (MIDI notes list, onsets lists, durations list etc...). This will facilitate our handling of data. In our case we will only need to use transpose notes.

D: Using the lisp fonctions first, second, third, fourth and fifth we will connect respectively their outputs to a CHORD-SEQ (G) as shown above.

E: In order to convert MIDI notes to midicents, one must multiply them by 100 using om* (E).

F: Alike tutorial 2 we will use om+ (F) to transpose these notes up to a wholetone (200 midicents).The result will be be output in the CHORD-SEQ (G).

H: In order to generalize this proceedures to all tracks (voices) of the midifile, we will construct a loop using omloop (see this example in the "all voices" red patch included in the tutorial example patch).

 

Inside omloop we have reproduced the main patch as it was shown earlier adding an iterative procedure using the for loop (D) iterator.

A: The track function returns all tracks present in a MIDIFILE object.

B:Length will return the list length

C: In our exqmple above, the midifiloe contains two tracks. midi-info as in lisp, starts counting tracks from 0. Therefore om- is needed to decrement the output of length in order to have the correct numbers for miditracks contained in our MIDIFILE object.

D: The for loop returns the index of the tracks needed for our transposition and outputs it to the second input of midi-info.

E: Finally we will construct several CHORD-SEQs object that will be collected and sent to the MULTI-SEQ object.

Again, by using save-as-midi we could save the POLY object under a MIDIfile format. In order to do so, evaluate save-as-midi ( a standard dialogue box will appear ).