Metre
Full module path: melody_features.feature_definitions.metre.
Also importable via import melody_features as mf (for example mf.pitch_range).
Metre feature definitions.
- metric_hierarchy(melody)[source]
Metric hierarchy values for each note, indicating the strength of each note position within the known or estimated meter. Higher values indicate stronger metric positions (e.g., downbeat = 5, beat = 4, half-beat = 3, etc.).
Implementation based on MIDI toolbox metrichierarchy.m.
- meter_accent(melody)[source]
Phenomenal accent synchrony measure, calculated as the negative mean of the product of metric hierarchy, melodic accent, and durational accent for each note. Higher values indicate stronger accent synchrony.
Implementation based on MIDI toolbox meteraccent.m.
- meter_numerator(melody)[source]
The numerator of the melody’s active time signature.
For a time signature written as numerator/denominator, the numerator is the number of beats in each notated bar. If a melody contains meter changes, this returns the meter stored on the melody object as its primary meter.
- meter_denominator(melody)[source]
The denominator of the melody’s active time signature.
For a time signature written as numerator/denominator, the denominator gives the note value that represents one beat: for example, 4 means a quarter-note beat and 8 means an eighth-note beat.
- proportion_of_time_in_first_meter(melody)[source]
The proportion of the melody’s duration spent in its first time signature.
The numerator and denominator of the first encountered time signature define the initial meter. This feature reports the fraction of total melody duration before any subsequent meter change. Melodies with no meter change therefore return 1.0.
- number_of_unique_time_signatures(melody)[source]
The number of unique time signatures in the melody.
- Parameters:
melody (Melody) – The melody to analyze
- Returns:
The number of unique time signatures in the melody.
- Return type:
Note
This feature is named Metrical Diversity in jSymbolic.
- syncopation(melody)[source]
Calculate the mean syncopation value based on the Longuet-Higgins and Lee (1984) model. This syncopation model assigns metrical weights to each note position based on its position in the metric hierarchy. Syncopation occurs when a rest or tied note is preceded by a sounded note of lower metrical weight. The syncopation value is the difference between the rest weight and the preceding note weight.
- syncopicity(melody)[source]
Calculates the sum syncopicity of a melody across metric levels. Syncopicity measures the degree to which notes occur off the main metrical grid but are long enough to span across metric boundaries. This calculates syncopations at four metric levels: 1) Half bar level 2) Beat level 3) First subdivision (half-beat) 4) Second subdivision (quarter-beat)
An event is considered syncopated at a given level if: 1) It does not fall on a grid point of this level 2) It falls on a grid point of the next lower level 3) Its IOI extends beyond the lower level time unit (or it’s the last note)
- Parameters:
melody (Melody) – The melody to analyze
- Returns:
Sum of per-level syncopation proportions across tested levels (half-bar, beat, and first subdivision). Each level contributes syncopation_count / number_of_notes, so this is not a raw event count.
- Return type:
Note
Grid durations are derived from the melody’s initial meter and tempo and therefore assume constant meter/tempo over the analyzed passage.