MidiSequence
Play MIDI music, with live control over pitch, tempo, and volume.
The MidiSequence class includes functions related to playing external MIDI files (as well as Part and Score objects) in real-time. A MIDI sequence provides playback features that are similar to the functionality for AudioSamples. Again, these functions are intended for building interactive musical instruments and installations.
Creating a MidiSequence
You can create a MidiSequence using the following functions:
MidiSequence(material)
MidiSequence(material, pitch, volume)
| Parameter | Type | Default | Description |
|---|---|---|---|
material |
str, Note, Phrase, Part, or Score |
required | The music to play, or the filename of a MIDI file (.mid). |
pitch |
int or float |
A4 |
The pitch to play at, as a MIDI pitch. Defaults to A4. |
volume |
int |
127 |
How loud to play, from 0 to 127. |
Functions
Once a MidiSequence sequence has been created, the following functions are available:
| Function | Description |
|---|---|
sequence.play() |
Play the sequence once. |
sequence.loop() |
Play the sequence over and over, forever. |
sequence.stop() |
Stop the sequence playing. |
sequence.pause() |
Pause the sequence, remembering where it is. |
sequence.resume() |
Resume the sequence from where it was paused. |
sequence.isPlaying() |
Report whether the sequence is currently playing. |
sequence.getPitch() |
Return the sequence's current playback pitch. |
sequence.setPitch(pitch) |
Set the sequence's playback pitch, transposing the music to match. |
sequence.getDefaultPitch() |
Return the pitch the sequence was created with. |
sequence.getTempo() |
Return the sequence's current playback tempo. |
sequence.setTempo(bpm) |
Set the sequence's playback tempo. |
sequence.getDefaultTempo() |
Return the tempo the sequence was created with. |