Package midi
[hide private]
[frames] | no frames]

Package midi

source code

Midi file I/O and manipulation library.

Python MIDI

This package contains data structures and utilities for reading, manipulating and writing MIDI data.

Submodules [hide private]

Classes [hide private]
  Event
Base class for all MIDI events.
  MetaEvent
MetaEvent is a special subclass of Event that is not meant to be used as a concrete class.
  EventFactory
EventFactory is a factory for getting MIDI events out of a data stream.
  NoteEvent
Abstract base class for NoteOnEvent and NoteOffEvent.
  NoteOnEvent
Note-on event.
  NoteOffEvent
Note-off event.
  AfterTouchEvent
Changes the pressure of aftertouch on a note.
  ControlChangeEvent
Sets the value of one of the 128 controllers available to a device.
  ProgramChangeEvent
Changes the patch (voice) number of the instrument.
  ChannelAfterTouchEvent
Channel pressure (after-touch).
  PitchWheelEvent
Change the pitch-bend wheel value.
  SysExEvent
System exclusive MIDI event.
  SequenceNumberEvent
Defines the pattern number of a Type 2 MIDI file or the number of a sequence in a Type 0 or Type 1 MIDI file.
  TextEvent
Defines some text which can be used for any reason including track notes, comments.
  CopyrightEvent
Defines copyright information including the copyright symbol (0xA9), year and author.
  TrackNameEvent
Defines the name of a sequence when in a Type 0 or Type 2 MIDI file or in the first track of a Type 1 MIDI file.
  InstrumentNameEvent
Defines the name of an instrument being used in the current track chunk.
  LyricsEvent
Defines the lyrics in a song and usually used to define a syllable or group of works per quarter note.
  MarkerEvent
Marks a significant point in time for the sequence.
  CuePointEvent
Marks the start of some type of new sound or action.
  UnknownEvent
  ChannelPrefixEvent
Associates a MIDI channel with following meta events.
  PortEvent
Specifies which MIDI port should be used to output all subsequent events.
  TrackLoopEvent
  EndOfTrackEvent
Appears and the end of each track to mark the end.
  SetTempoEvent
Change the tempo of events played after this point.
  SmpteOffsetEvent
Designates the SMPTE start time (hours, minutes, secs, frames, subframes) of the track.
  TimeSignatureEvent
Expressed as 4 numbers: <numerator> <denominator> <metronome> <thirtyseconds>.
  KeySignatureEvent
Sets the key signature, made up of a number of sharps/flats and either major or minor.
  BeatMarkerEvent
  SequencerSpecificEvent
Specifies information specific to a hardware or software sequencer.
  TempoMap
  EventStreamIterator
  EventStream
Class used to describe a collection of MIDI events, organized into tracks.
  EventStreamWriter
Takes care of writing MIDI data from an EventStream to an output stream, such as a file.
  EventStreamReader
Reads MIDI data in from an input stream, probably a file, and produces an EventStream to represent it internally.
  MidiReadError
Usually raised on encountering invalid MIDI data while parsing.
  MidiWriteError
Functions [hide private]
 
all_notes_off_event(channel)
Creates an All Notes Off event.
source code
 
single_note_tuning_event(note_changes, device_number=None, tuning_program=None)
Returns a SysExEvent which will encode single note tuning changes according to the MIDI tuning messages standard.
source code
 
check_midi(mid)
Midi debugger.
source code
 
new_stream(tempo=120, resolution=480, format=1) source code
Variables [hide private]
  __package__ = 'midi'
Function Details [hide private]

all_notes_off_event(channel)

source code 

Creates an All Notes Off event. This is really a specialized control change event and uses one of the reserved controller numbers.

single_note_tuning_event(note_changes, device_number=None, tuning_program=None)

source code 

Returns a SysExEvent which will encode single note tuning changes according to the MIDI tuning messages standard.

note_changes should be a list of note changes, specified as triples:

  • (<note number>, <semitone>, <cents>)

where:

  • <key number> is a note number (0-127) to retune,
  • <semitone> is the nearest equal-temperament semitone below the desired frequency (also a note number, 0-127), and
  • <cents> is a float >= 0 and < 100 representing the number of cents above the semitone's pitch to retune it to.

check_midi(mid)

source code 

Midi debugger. Checks through a midi event stream for things that might be wrong with it.

Parameters:
Returns:
list of tuples, consisting of a string problems identifier, a descriptive message and a tuple of midi events that generated the problem.

To Do: add more possible problems to the checks.