containers
These classes simply hold MIDI data in a convenient form.
- class pretty_midi.containers.Note(velocity, pitch, start, end)[source]
A note event.
- Parameters:
- velocityint
Note velocity.
- pitchint
Note pitch, as a MIDI note number.
- startfloat
Note on time, absolute, in seconds.
- endfloat
Note off time, absolute, in seconds.
- class pretty_midi.containers.PitchBend(pitch, time)[source]
A pitch bend event.
- Parameters:
- pitchint
MIDI pitch bend amount, in the range
[-8192, 8191]
.- timefloat
Time where the pitch bend occurs.
- class pretty_midi.containers.ControlChange(number, value, time)[source]
A control change event.
- Parameters:
- numberint
The control change number, in
[0, 127]
.- valueint
The value of the control change, in
[0, 127]
.- timefloat
Time where the control change occurs.
- class pretty_midi.containers.TimeSignature(numerator, denominator, time)[source]
Container for a Time Signature event, which contains the time signature numerator, denominator and the event time in seconds.
Examples
Instantiate a TimeSignature object with 6/8 time signature at 3.14 seconds:
>>> ts = TimeSignature(6, 8, 3.14) >>> print(ts) 6/8 at 3.14 seconds
- Attributes:
- numeratorint
Numerator of time signature.
- denominatorint
Denominator of time signature.
- timefloat
Time of event in seconds.
- class pretty_midi.containers.KeySignature(key_number, time)[source]
Contains the key signature and the event time in seconds. Only supports major and minor keys.
Examples
Instantiate a C# minor KeySignature object at 3.14 seconds:
>>> ks = KeySignature(13, 3.14) >>> print(ks) C# minor at 3.14 seconds
- Attributes:
- key_numberint
Key number according to
[0, 11]
Major,[12, 23]
minor. For example, 0 is C Major, 12 is C minor.- timefloat
Time of event in seconds.