Login
MIDI Files and Sequencers
Login

Classes and Structures

Structure: MIDI-FILE

Represents a Standard MIDI File. It has no exported accessors.

Class: MIDI-FILE-SEQUENCER (AUDIO-RENDERER)

An instance of a sequencer that can play back MIDI files.

Note that the methods associated with this class does not provide thread safety. If you want to do playback control and render a waveform in separate threads, you must ensure that the associated methods/functions will not be called simultaneously.

The available accessors are:

  • MIDI-SEQ-SPEED midi-file-sequencer -> double-float
  • (SETF MIDI-SEQ-SPEED) double-float midi-file-sequencer

Generic Function: MAKE-MIDI-FILE [source] -> midi-file

Creates a new MIDI file from the given source. The source can be either a STREAM, PATHNAME, or a STRING.

Generic Function: NEW-MIDI-FILE [source] [loop] -> midi-file

Creates a new MIDI file from the given source. The source can be either a STREAM, PATHNAME, or a STRING. LOOP specifies either a loop point (a FIXNUM), or a T/MIDI-FILE-LOOP-TYPE.

Function: MIDI-FILE-LENGTH stream -> soundfont

Returns the length of the MIDI file. More specifically, this returns the final message timestamp. The returned time value is always in INTERNAL-TIME-UNITS-PER-SECOND.

Function: PLAY midi-file-sequencer midi-file &key (:loop? boolean)

Uses the sequencer to play the specified MIDI-FILE. When LOOP? is truthy, then the MIDI file will loop automatically when it reaches the end, or if it has loop points specified.

The synthesizer associated with the sequencer is reset before playing the MIDI.

Function: STOP stream -> soundfont

Stops playing the MIDI and resets the synthesizer.

Function: MIDI-SEQ-POSITION stream -> soundfont

Returns two two values: the first value is the current message index that the sequencer is on. The second value is the total number of messages the associated MIDI file contains.

If no MIDI file is loaded into the sequencer, this always returns 0 and 0.

Function: MIDI-SEQ-CURRENT-TIME stream -> soundfont

Returns two two values: the first value is the current play time for the MIDI sequencer. The second value is the same as for MIDI-FILE-LENGTH. Time values are always in INTERNAL-TIME-UNITS-PER-SECOND.

If no MIDI file is loaded into the sequencer, this always returns 0 and 0.

Method: RENDER-AUDIO midi-file-sequencer vector vector

Renders audio to the two vectors, representing the left and right channels. This returns T if the song is not finished playing, or if the sequencer is set to loop. Otherwise this returns NIL when he song is finished.

Note that this is a lower level function than the RENDER method described in Audio Rendering. You probably want to use RENDER instead.