partitura.performance¶
This module contains a lightweight ontology to represent a performance in a
MIDI-like format. A performance is defined at the highest level by a
PerformedPart
. This object contains performed
notes as well as continuous control parameters, such as sustain pedal.
-
class
partitura.performance.
PerformedPart
(notes, id=None, part_name=None, controls=None, programs=None, sustain_pedal_threshold=64)[source]¶ Bases:
object
Represents a performed part, e.g. all notes and related controller/modifiers of one single instrument.
Performed notes are stored as a list of dictionaries, where each dictionary represents a performed note, should have at least the keys “note_on”, “note_off”, the onset and offset times of the note in seconds, respectively.
Continuous controls are also stored as a list of dictionaries, where each dictionary represents a control change. Each dictionary should have a key “type” (the name of the control, e.g. “sustain_pedal”, “soft_pedal”), “time” (in seconds), and “value” (a number).
Parameters: - notes (list) – A list of dictionaries containing performed note information.
- id (str) – The identifier of the part
- controls (list) – A list of dictionaries containing continuous control information
- part_name (str) – Name for the part
- sustain_pedal_threshold (int) – The threshold above which sustain pedal values are considered to be equivalent to on. For values below the threshold the sustain pedal is treated as off. Defaults to 64.
-
notes
¶ A list of dictionaries containing performed note information.
Type: list
-
id
¶ The identifier of the part
Type: str
-
part_name
¶ Name for the part
Type: str
-
controls
¶ A list of dictionaries containing continuous control information
Type: list
-
programs
¶ List of dictionaries containing program change information
Type: list
-
classmethod
from_note_array
(note_array, id=None, part_name=None)[source]¶ Create an instance of PerformedPart from a note_array. Note that this property does not include non-note information (i.e. controls such as sustain pedal).
-
note_array
¶ Structured array containing performance information. The fields are ‘id’, ‘pitch’, ‘onset_div’, ‘duration_div’, ‘onset_sec’, ‘duration_sec’ and ‘velocity’.
-
sustain_pedal_threshold
¶ The threshold value (number) above which sustain pedal values are considered to be equivalent to on. For values below the threshold the sustain pedal is treated as off. Defaults to 64.
Based on the control items of type “sustain_pedal”, in combination with the value of the “sustain_pedal_threshold” attribute, the note dictionaries will be extended with a key “sound_off”. This key represents the time the note will stop sounding. When the sustain pedal is off, sound_off will coincide with note_off. When the sustain pedal is on, sound_off will equal the earliest time the sustain pedal is off after note_off. The sound_off values of notes will be automatically recomputed each time the sustain_pedal_threshold is set.