MIDI
Prev | Chapter 7. Outputs | Next

## MIDI

This requires Common Music to output MIDI data. The purpose of this backend is to allow the user to hear the results after any changes and adjustments made to the music (for example, quantizing). It should not be used as input to a score notation program, since the output data will not precisely match the input data. FOMUS attempts to accurately simulate most of FOMUS's markings (trills, dynamic markings, etc.). Users can override how marks are interpretted by using the `EVENTS-FUN` option to provide their own instructions. Output can also be tweaked using most of the options listed below.

See the `INSTR` and `PERC` structures for information on how to define MIDI data for FOMUS's instruments.

MIDI output is be routed either to a file or to Common Music's realtime scheduler, the latter being advantageous if more than 16 channels are necessary (see the `PLAY` option). Also, the `CM-ARGS` option may be used to send Common Music specific arguments to its `EVENTS` or `RTS` function, whichever is used. FOMUS uses floating point velocity (or amplitude) values (0.0 to 1.0).

### MIDI Options

`:FILENAME` | `:BREATH-DUR` | `:SLUR-ADDDUR`
`:MIDI-FILENAME` | `:INSTR-PER-CH` | `:STACCATISSIMO-MULT`
`:PLAY` | `:FERMATA-MULTS` | `:STACCATO-MULT`
`:CM-ARGS` | `:GRACE-DUR-SECS` | `:TENUTO-ADDDUR`
`:EVENTS-FUN` | `:HARMATT` | `:TRAMP`
`:DELAY` | `:MIN-AMP` | `:TRDUR-SECS`
`:NPORTS` | `:MINDUR-SECS` | `:TROVLP-ADDDUR`
`:TEMPO` | `:PBEND-WIDTH` | `:MIDI-FILENAME`
`:ARPATT` | `:PORTATO-MULT` |

### Alphabetical Listing of Options

`:ARPATT`

  A real number from `0` to `1` specifying the amount of attenuation to apply to arpeggios to make them sound more natural (a crescendo is also added). The number is subtracted from the velocities of the events.

`:BREATH-DUR`

  A real number greater than `0` specifying the duration in beats of a breath mark.

`:CM-ARGS`

  This is a list of arguments that are sent to Common Music's `EVENTS` or `RTS` function, whichever is used. FOMUS overrides the `:TEMPO` and `:PLAY` keyword arguments to these functions.

`:DELAY`

  A real number greater than or equal to `0` specifying a delay time in seconds to be inserted at the beginning of the MIDI file or output (useful if the score takes several seconds to appear on the screen).

`:EVENTS-FUN`

  This options provides a way of overriding FOMUS's default interpretation of marks into MIDI events. It is a function of the form `(lambda (`ev` `mark` `arg1` `arg2`) ...)`, where `ev` is either a single Common Music `MIDI` object or a list of such objects, `mark` is a keyword symbol specifying what modifications should occur, and `arg1` and `arg2` are input arguments specific to each mark. The function may either modify the `MIDI` event objects or create new ones using Common Music functions (or return a mixture of both). The return value is either a single `MIDI` object, a list of `MIDI` objects, `NIL` or `'(NIL)`. Returning `NIL` indicates that FOMUS should use its default function to interpret the mark. `'(NIL)` indicates that the return value actually is an empty list of events (and that the default function should not be called)--they will then be deleted from the output.

  The user should not worry about how multiple marks will affect either other. For example, a note with both `:TREMOLO` and `:ACCENT` marks will be passed to the user function first with the `:TREMOLO` keyword. Next (assuming the user returned multiple `MIDI` events) only the first note of the tremolo is passed to this function with the `:ACCENT` keyword. The user function should then only deal directly with what it is given and allow FOMUS to handle the sorting out of these details and applying them to the correct notes. Also, the dynamic markings `:PPPPPP` through `:FFFFFF` are translated before any other dynamics-related markings, so user code should set the amplitudes of `MIDI` objects to some initial value in these cases. Subsequent handling of other dynamics-related marks can then alter MIDI amplitude values in whatever ways are appropriate.

  Marks that are sent via the `mark` argument are listed here (with `arg1` and `arg2` if appropriate). Marks beginning with `:SPAN-` accompany a list of events to modify and correspond to what are called "spanner" marks in Marks.

  `:FFFFFF`
  `:FFFFF`
  `:FFFF`
  `:FFF`
  `:FF`
  `:F`
  `:MF`
  `:MP`
  `:P`
  `:PP`
  `:PPP`
  `:PPPP`
  `:PPPPP`
  `:PPPPPP`
  `:RFZ`
  `:SFZ`
  `:SPP`
  `:SP`
  `:SFF`
  `:SF`
  `:FP`
  `:STACCATO`
  `:STACCATISSIMO`
  `:PORTATO`
  `:TENUTO`
  `:MARCATO`
  `:ACCENT`
  `:SPAN-SLUR (`arg1` is the slur level)`
  `:FERMATA (`arg1` is either `:SHORT`, `:LONG` or `:VERYLONG`)`
  `:BREATH`
  `:TREMOLO` (`arg1` is the number of tremolo subdivisions, `arg2` is 1/8 for eighth-note subdivions, 1/16 for sixteenths, etc.)
  `:SPAN-TREMFIRST` (`arg1` and `arg2` are the same as with `:TREMOLO`)
  `:SPAN-TREMSECOND` (`arg1` and `arg2` are the same as with `:TREMOLO`)
  `:TRILL` (`arg1` is the additional trill pitch)
  `:LONGTRILL` (`arg1` is the additional trill pitch)
  `:PRALL` (`arg1` is the additional prall pitch)
  `:MORDENT` (`arg1` is the additional mordent pitch)
  `:SPAN-ARP` (`arg1` is either `:UP`, `:DOWN` or `NIL`, `arg2` is the offset of the previous note)
  `:SPAN-PORT`
  `:SPAN-GLISS`
  `:SPAN-WEDGE<` (`arg1` is the destination amplitude or velocity, `arg2` is the offset of the event following the last event of the wedge)
  `:SPAN-WEDGE>` (`arg1` and `arg2` are the same as with `:SPAN-WEDGE<`)
  `:HARMONIC` (`arg1` is either `:SOUNDING` or `:TOUCHED`, `arg2` is the sounding pitch in either case)
  `:ARCO`
  `:PIZZ`
  `:STOPPED`
  `:OPEN`
  `:FLAGEOLET`

`:FERMATA-MULTS`

  This is a list of three real numbers greater than `0`, specifying how much to increase (by multiplying) the durations of notes that have fermatas over them. The three values each correspond to short, long and very long fermatas.

`:FILENAME`

  This is a string representing the output filename. It overrides the `FILENAME` setting if used.

`:GRACE-DUR-SECS`

  A real number greater than `0` specifying the default MIDI grace note duration in seconds.

`:HARMATT`

  A real number from `0` to `1` specifying the amount of attenuation to apply to harmonics to make them sound closer to what is expected. The number is subtracted from the velocities of the events.

`:INSTR-PER-CH`

  When set to an integer value greater than or equal to `1`, specifies how many parts with similar instruments (ie. with equivalent MIDI program change values) are stuffed into one MIDI channel or track. A value of `NIL` indicates that all parts with the same program change indicated in their `INSTR` objects are to be put into a single channel.

`:MIDI-FILENAME`

  This is a part option (see the `PART` class). It is a string representing a filename for a separate output file--FOMUS fills this with MIDI data only for the part that it is specified in. These strings are "merged" with `FILENAME` using Lisp's `MERGE-PATHNAMES` function so that if a full path isn't specified it appears in the same directory as FILENAME. Parts with the same `MIDI-FILENAME` are grouped together so that all of their output is written to one file.

`:MIN-AMP`

  A real number from `0` to `1` specifying a minimum velocity value for all midi events.

`:MINDUR-SECS`

  This real number specifies an absolute minimum duration in seconds for all midi events.

`:NPORTS`

  If realtime playback is specified using the `PLAY` option, this integer value specifies the number of ports to use. The default is `1`. If output is to a MIDI file, then this value will be `1` regardless of what is specified.

`:PBEND-WIDTH`

  This is equivalent to the `:PITCH-BEND-WIDTH` option used when opening MIDI streams in Common Music. It is a real number greater than `0`, specifying the maximum pitch bend range in semitones used to calculate pitch bend values for quartertone playback. The default is `2`.

`:PLAY`

  If set to `NIL` or `T`, specifies that output is to a MIDI file. `T` indicates that the output should be played automatically (equivalent to sending `:PLAY T` to Common Music's `EVENTS` function). If set to a Common Music MIDI stream, indicates that the `RTS` function should be used and the MIDI events scheduled for realtime playback.

`:PORTATO-MULT`

  A real number greater than `0` indicating the amount to increase (by multiplying) the duration of MIDI events with portato markings.

`:SLUR-ADDDUR`

  A real number greater than or equal to `0` indicating the amount of beats to add to the duration of slurred events (causing them to overlap slightly).

`:STACCATISSIMO-MULT`

  A real number greater than `0` indicating the amount to increase (by multiplying) the duration of MIDI events with staccatissimo markings.

`:STACCATO-MULT`

  A real number greater than `0` indicating the amount to increase (by multiplying) the duration of MIDI events with staccato markings.

`:TEMPO`

  A real number greater than or equal to `0` specifying the MIDI playback tempo.

`:TENUTO-ADDDUR`

  A real number greater than or equal to `0` indicating the amount of beats to add to the duration of MIDI events with tenuto markings.

`:TRAMP`

  A real number from `0` to `1` specifying the amount of amplification to apply to MIDI events that are a part of a trill or tremolo. The number is added to the velocities of the events.

`:TRDUR-SECS`

  A real number greater than `0` indicating the duration in seconds of an individual MIDI event in a trill or tremolo. (For tremolos it is the minimum duration of an individual MIDI event.)

`:TROVLP-ADDDUR`

  A real number greater than or equal to `0` indicating the amount of beats to add to the duration of MIDI events that are a part of a trill or tremolo.

Prev | Up | Next
Common Music Notation | Home | CHUNK