MIDI File Controller (Lisp)
Description
Imports a Standard (Type 0) MIDI File, parses its data, and outputs a controller from a list of specified data types.
(make-controller 'midi-file ... )
Syntax and Default Values
The 'midi-file controller can be created using the following Lisp syntax:
(make-controller 'midi-file
dimension
filename
channel
data_type_list)
Parameters
The 'midi-file controller takes four arguments:
- dimension: the number of output dimensions for the controller.
- filename: pathname of MIDI file to be read. (in quotes.)
- channel: the MIDI channel you want to extract data from (1-16).
- data_type_list: a list of symbol and/or numbers defining what MIDI data will be used
The pathname of the MIDI file should be provided in quotes. The path is relative to the Modalys application, unless it begins with a slash, in which case it is an absolute path from the root directory of the hard disk. The syntax for the path follows the syntax rules of your operating system. The MIDI file itself should be a Type 0 (single track) MIDI file - multi-track (Type 1) MIDI files are not yet supported.
The channel parameter corresponds to the MIDI channel you want to extract data from. (There is currently no "omni" mode; to get this effect you'd have to make one midi controller for each channel, then write a 'foreign-call controller that merged all the data.)
The number of elements in the list given as the data_type_list should be the same as the number of dimensions in the controller. The list may be composed of MIDI data types, or numerical values, which represent MIDI continuous controller numbers. (More detailed information about this is given, below.)
Discussion
The MIDI File Controller allows you to read information from a Standard (Type 0) MIDI File and output it as a Modlays controller. A Basic example would be the following, which reads the Modulation Wheel MIDI Continuous Controller (MIDI controller 1) data from MIDI channel 1:
(make-controller 'midi 1 "/my-disk/my-folder/my-file.mid" 1 (list 1))
(setq my-midi-ctl (make-controller 'midi-file 2 "Examples/midi/wx7-staccato.mid" 1 (list 2 'lastvelocity)))
- 'pitchbend
- 'aftertouch
- 'noteon
- 'noteoff
- 'lastnote
- 'lastvelocity
Note that 'lastnote and 'lastvelocity are not standard MIDI data types, but specific to this Modalys controller. The 'lastnote type designates here the last note-on or note-off that has been activated, and 'lastvelocity is the velocity of the 'lastnote.
If you want a midi-file controller with 3 dimensions, you specify the name of the file to read from, then you specify what MIDI channel you want to read from the file; finally you specify what 3 kinds of data you want to extract from the file. You can extract a separate MIDI data stream for each dimension of this controller, for example:
(make-controller 'midi 3 "my-file.mid" 1 (list 'pitchbend 13 'aftertouch))
Obviously, you can make several independent 'midi-file controllers in Modalys by reading the same MIDI file multiple times - once for each controller. You might do this if you want to use pitch bend data in one place, and continuous controller data some other place, etc... This saves you the hassle of needing to use the 'dimension-mapping controller to extract individual dimensions from a multi-dimensional controller.
Retro-Compatibility
This controller was formerly called (make-controller 'midi ... ). Older Modalys scripts should be updated accordingly.
★