Feature Groups

Feature aggregation helpers by domain and source. Prefer melody_features.get_all_features() for typical analysis jobs.

This module contains functions to compute features from melodies. Features are the product of an input list and at least one algorithm.

get_pitch_features(melody)[source]

Dynamically collect all pitch features for a melody.

Collects features decorated with @pitch domain and @absolute type.

Parameters:

melody (Melody) – The melody to analyze

Returns:

Dictionary of pitch feature values

Return type:

Dict

get_pitch_class_features(melody)[source]

Dynamically collect all pitch class features for a melody.

Collects features decorated with @pitch domain and @pitch_class type.

Parameters:

melody (Melody) – The melody to analyze

Returns:

Dictionary of pitch class feature values

Return type:

Dict

temperley_likelihood(pitches)[source]

The likelihood of a melody using Bayesian reasoning, according to David Temperley’s model (http://davidtemperley.com/wp-content/uploads/2015/11/temperley-cs08.pdf).

Parameters:

pitches (list[int]) – List of MIDI pitch values

Returns:

Likelihood of the melody using Bayesian reasoning

Return type:

float

get_complexity_features(melody, phrase_gap=1.5, max_ngram_order=5)[source]

Dynamically collect all complexity features for a melody.

Parameters:
Return type:

Dict

get_complexity_feature_bundle(melody, phrase_gap=1.5, max_ngram_order=5)[source]

Return complexity and lexical-diversity features for export.

Parameters:
Return type:

Dict

get_interval_features(melody)[source]

Dynamically collect all interval features for a melody. Collects features decorated with @pitch domain and @interval type.

Parameters:

melody (Melody) – The melody to analyze

Returns:

Dictionary of interval feature values

Return type:

Dict

get_timing_features(melody)[source]

Collect @rhythm-domain features decorated with @timing.

Parameters:

melody (Melody)

Return type:

Dict

get_inter_onset_interval_features(melody)[source]

Collect @rhythm-domain features decorated with @interval (IOI family).

Parameters:

melody (Melody)

Return type:

Dict

get_rhythm_features(melody)[source]

Dynamically collect all rhythm features for a melody.

Combines timing and inter-onset interval features for backward-compatible rhythm_features export. metric_hierarchy and meter_accent are excluded here since they are already reported under metre_features (via get_metre_features); including them in both would duplicate the same values under two column prefixes (timing.* and metre.*).

Parameters:

melody (Melody)

Return type:

Dict

collect_rhythm_for_pipeline(melody)[source]

Collect rhythm features and per-subcategory timings for pipeline workers.

timing and inter_onset_interval are timed separately so pipeline statistics keep them as discrete taxonomy categories. metric_hierarchy and meter_accent are intentionally omitted here; they are collected once, under metre_features, to avoid duplicating them under both timing.* and metre.* column prefixes.

Parameters:

melody (Melody)

Return type:

tuple[Dict[str, Any], Dict[str, float]]

get_expectation_features(melody)[source]

Dynamically collect all expectation features for a melody.

Parameters:

melody (Melody)

Return type:

Dict

get_metre_features(melody)[source]

Dynamically collect all metre features for a melody.

Parameters:

melody (Melody)

Return type:

Dict

get_fantastic_features(melody, corpus_stats=None, phrase_gap=1.5, max_ngram_order=5)[source]

Get all FANTASTIC features for a melody.

Parameters:
  • melody (Melody) – The melody to analyze

  • corpus_stats (Optional[dict], optional) – Corpus statistics for distributional features (default: None)

  • phrase_gap (float, optional) – Gap threshold for phrase segmentation (default: 1.5)

  • max_ngram_order (int, optional) – Maximum inclusive n-gram length (default: 5)

Returns:

Dictionary containing all FANTASTIC features

Return type:

Dict

get_jsymbolic_features(melody)[source]

Get all jSymbolic features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all jSymbolic features

Return type:

Dict

get_must_features(melody)[source]

Get all MUST features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all MUST features

Return type:

Dict

get_midi_toolbox_features(melody)[source]

Get all MIDI Toolbox features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all MIDI Toolbox features

Return type:

Dict

get_idyom_features(melody)[source]

Get all IDyOM features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all IDyOM features

Return type:

Dict

get_simile_features(melody)[source]

Get all SIMILE features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all SIMILE features

Return type:

Dict

get_novel_features(melody)[source]

Get all novel/custom features for a melody.

Parameters:

melody (Melody) – The melody to extract features from

Returns:

Dictionary containing all novel features

Return type:

Dict