Expectation
Full module path: melody_features.feature_definitions.expectation.
Also importable via import melody_features as mf (for example mf.pitch_range).
Expectation feature definitions.
- narmour_registral_direction(pitches)[source]
Narmour registral-direction score for the final three notes.
The last three pitches define an implicative interval followed by a realized interval. This feature returns 1 when a large implicative interval (greater than a tritone) is followed by a change of direction, or when a small implicative interval (smaller than a tritone) continues in the same direction. It returns 0 otherwise.
- narmour_proximity(pitches)[source]
Narmour proximity score for the final melodic interval.
Proximity rewards small realized intervals. It is calculated as 6 - d, where d is the absolute semitone distance between the final two notes, and is clipped at 0 for intervals of a tritone or larger. Unisons therefore receive 6, whole tones receive 4, perfect fourths receive 1, and perfect fifths receive 0.
- narmour_closure(pitches)[source]
Narmour closure score for the final three-note pattern.
The last three pitches define two successive intervals. One point is awarded when the second interval changes direction relative to the first. A second point is awarded when the second interval is at least two semitones smaller than the first in absolute size. The resulting score ranges from 0 to 2.
- narmour_registral_return(pitches)[source]
Narmour registral-return score for the final three-note pattern.
Registral return measures whether the last three notes move away from a pitch and then return toward it. The contour must change direction and neither interval may be a repeated note. An exact return to the first pitch scores 3; returning within one semitone scores 2; returning within two semitones scores 1; all other patterns score 0.
- narmour_intervallic_difference(pitches)[source]
Narmour intervallic-difference score for the final three notes.
The last three pitches define an implicative interval followed by a realized interval. If the implicative interval is large (greater than a tritone), this feature returns 1 when the realized interval is sufficiently smaller: at least three semitones smaller in the same direction, or at least two semitones smaller after a direction change. If the implicative interval is small (smaller than a tritone), it returns 1 when the realized interval is similar in size, within the same margins. Otherwise it returns 0.
- melodic_embellishment(pitches, starts, ends)[source]
The proportion of melodic embellishments in the melody. Melodic embellishments are identified by notes that are surrounded on both sides by notes with durations at least 3 times longer than the central note.
- mobility(pitches)[source]
The melodic mobility for each note based on von Hippel (2000). Mobility describes why melodies change direction after large skips by observing that they would otherwise run out of the comfortable melodic range. It uses lag-one autocorrelation between successive pitch heights.
- melodic_attraction(pitches, starts, ends)[source]
Melodic attraction values following Lerdahl’s tonal-attraction model.
- mean_melodic_attraction(pitches, starts, ends)[source]
The arithmetic mean of Lerdahl melodic-attraction values.
- melodic_attraction_std(pitches, starts, ends)[source]
The population standard deviation of Lerdahl melodic-attraction values.
- melodic_accent(pitches)[source]
Melodic accent salience for each note using Thomassen’s contour model.
Thomassen’s model assigns accent strength from the melodic contour formed by three-note pitch windows. Notes at locally salient contour positions receive higher values. The implementation follows the MIDI Toolbox melaccent.m convention and returns values from 0 (no salience) to 1 (maximum salience).
- mean_melodic_accent(pitches)[source]
The arithmetic mean of Thomassen melodic-accent values.
Melodic accent values estimate local contour salience from three-note pitch windows. This feature averages those note-level salience values across the melody.
- melodic_accent_std(pitches)[source]
The sample standard deviation of Thomassen melodic-accent values.
Melodic accent values estimate local contour salience from three-note pitch windows. This feature summarizes how unevenly that salience is distributed across the melody.
- compltrans(melody)[source]
The melodic originality measure, according to Simonton (1984). Calculated based on 2nd order pitch-class distribution derived from 15,618 classical music themes. Higher values indicate higher melodic originality (less predictable transitions).
- pitch_stm_mean_information_content(melody)[source]
The average information content across all notes in a melody, calculated using IDyOM’s prediction-by-partial-matching (PPM) algorithm. Information content is perceptually related to surprise, and can be calculated for pitches or rhythms.
Citation
Pearce, M. (2005)
- pitch_ltm_mean_information_content(melody)[source]
The average information content across all notes in a melody, calculated using IDyOM’s long-term model (LTM). Information content is perceptually related to surprise, and can be calculated for pitches or rhythms.
Citation
Pearce, M. (2005)
- rhythm_stm_mean_information_content(melody)[source]
The average rhythmic information content across all notes in a melody, calculated using IDyOM’s short-term model (STM). Information content is perceptually related to surprise, and can be calculated for pitches or rhythms.
Citation
Pearce, M. (2005)
- rhythm_ltm_mean_information_content(melody)[source]
The average rhythmic information content across all notes in a melody, calculated using IDyOM’s long-term model (LTM). Information content is perceptually related to surprise, and can be calculated for pitches or rhythms.
Citation
Pearce, M. (2005)
- get_narmour_features(melody)[source]
Calculate Narmour’s implication-realization features.
- Parameters:
melody (Melody) – The melody to analyze as a Melody object
- Returns:
Dictionary containing scores for: - Registral direction (0 or 1) - Proximity (0-6) - Closure (0-2) - Registral return (0-3) - Intervallic difference (0 or 1)
- Return type:
Dict
Notes
Features represent: - Registral direction: Large intervals followed by direction change - Proximity: Closeness of consecutive pitches - Closure: Direction changes and interval size changes - Registral return: Return to previous pitch level - Intervallic difference: Relationship between consecutive intervals