Pitch interval
Full module path: melody_features.feature_definitions.pitch_interval.
Also importable via import melody_features as mf (for example mf.pitch_range).
Pitch interval feature definitions.
- pitch_interval(pitches)[source]
The intervals (in semitones) between consecutive pitches in the melody.
- absolute_interval_range(pitches)[source]
The range between the largest and smallest absolute interval size.
- mean_absolute_interval(pitches)[source]
The arithmetic mean of the absolute intervals in the melody.
- standard_deviation_absolute_interval(pitches)[source]
The standard deviation of the absolute intervals in the melody.
- ivdist1(pitches, starts, ends, tempo=120.0, channels=None)[source]
Interval distribution weighted by duration accent.
- Parameters:
- Returns:
Map from interval in semitones (-12..12) to proportion
- Return type:
- ivdist2(pitches, starts, ends, tempo=120.0)[source]
Second-order interval transition distribution (MIDI Toolbox ivdist2.m).
Each note is assigned an interval class (incoming interval modulo octave, with 0 for the first note). Transition weights use the sum of Parncutt duration accents of the two notes. Keys are (from_interval, to_interval) in semitones (approximately -11 to 11).
- Parameters:
- Returns:
Map from interval-class transition to proportion
- Return type:
- ivdirdist1(pitches, starts, ends, tempo=120.0, channels=None)[source]
Directional interval bias for each interval size (1-12 semitones).
Derived from duration-accent-weighted ivdist1 (MIDI Toolbox ivdirdist1.m).
- ivsizedist1(pitches, starts, ends, tempo=120.0, channels=None)[source]
Interval-size distribution (0-12 semitones) from ivdist1.
Derived from duration-accent-weighted ivdist1 (MIDI Toolbox ivsizedist1.m).
- interval_direction(pitches)[source]
The sequence of interval directions in the melody, where 1 represents upward motion, 0 represents no motion, and -1 represents downward motion.
- interval_direction_mean(pitches)[source]
The mean of the direction of each interval in the melody.
- Parameters:
- Returns:
Mean of interval directions
- Return type:
Note
Unisons contribute 0 to both numerator and denominator because the mean is taken over the full direction sequence {-1, 0, 1}.
- interval_direction_std(pitches)[source]
The standard deviation of the direction of each interval in the melody.
- Parameters:
- Returns:
Population standard deviation of interval directions
- Return type:
Note
Uses population variance (divide by N)
- average_length_of_melodic_arcs(pitches)[source]
The average number of notes that separate peaks and troughs in melodic arcs.
- distance_between_most_prevalent_melodic_intervals(pitches)[source]
The absolute difference between the two most common interval sizes.
- melodic_interval_histogram(pitches)[source]
Histogram of absolute melodic interval sizes in semitones.
- Parameters:
- Returns:
Mapping from interval size (0–127 semitones) to count. Only sizes with count > 0 are included.
- Return type:
Note
We only return bins for intervals that have a count > 0. An implementation that is truer to the original jSymbolic implementation would return 128 bins (0-127) regardless of how any different intervals are present.
- variable_melodic_intervals(pitches, interval_level)[source]
The proportion of intervals >= specified size.
- melodic_perfect_fourths(pitches)[source]
The proportion of intervals that are perfect fourths (5 semitones).
- melodic_perfect_fifths(pitches)[source]
The proportion of intervals that are perfect fifths (7 semitones).
- melodic_sevenths(pitches)[source]
The proportion of intervals that are sevenths (10 or 11 semitones).
- minor_major_third_ratio(pitches)[source]
The ratio of minor thirds to major thirds.
- Parameters:
- Returns:
Ratio of minor thirds to major thirds, or NaN if no major thirds exist
- Return type:
Note
Instead of matching jSymbolic behavior (returning 0.0 when there are no major thirds), this returns NaN when there are no major thirds (including cases where minor thirds are present).
- direction_of_melodic_motion(pitches)[source]
The proportion of upward melodic motions with regards to the total number of melodic motions.
- Parameters:
- Returns:
Proportion of upward melodic motion (0.0 to 1.0), or -1.0 if no intervals
- Return type:
Note
This feature excludes unisons from its denominator and maps only to [0, 1].
- number_of_common_melodic_intervals(pitches)[source]
The number of intervals that appear in at least 9% of melodic transitions.
- prevalence_of_most_common_melodic_interval(pitches)[source]
The proportion of intervals that are the most common interval.
- relative_prevalence_of_most_common_melodic_intervals(pitches)[source]
The ratio of the frequency of the second most common interval to the frequency of the most common interval.
- amount_of_arpeggiation(pitches)[source]
The proportion of pitch intervals in the melody that constitute triadic movements.