Features

This module provides methods that allows to analyze symbolic music.

Pitch

get_highest_lowest_pitches(notes)

Extracts the highest and lowest pitches from a list of notes.

get_pitch_range(notes)

Computes the difference between the highest and the lowest pitches in a list of notes.

get_note_density(notes)

Counts the total number of onsets in the Instrument.

get_pitch_classes(notes)

Counts the total number of different note classes NoteClassBase().

get_note_classes(notes)

Counts the total number of different note classes NoteClassBase().

pitch_counts(notes)

Calculates the number of different pitches or Pitch Counts (PC) of a list of Notes.

get_last_note_class(notes)

Returns the latest note name (NoteClassBase) in the sequence.

pitch_class_histogram(notes)

Computes the Pitch Class Histogram (PCH) of a list of musicaiz Note() objects.

pitch_class_transition_matrix(notes)

Computes the Pitch Class Transition Matrix (PCTM) of a list of musicaiz Note() objects.

plot_pitch_class_transition_matrix(pctm)

Plots the Pitch Class Transition Matrix (PCTM).

average_pitch_interval(notes)

Computes the Average Pitch Interval (PI) of a a list of musicaiz Note() objects.

Harmony

get_chord_type_from_note_seq(note_seq)

Gets the chord type ChordType() of a list of musicaiz Note() objects.

get_intervals_note_seq(note_seq)

Get the intervals between pairs of notes (1st note and the rest of the notes in the note seq) of a sorted note seq.

predict_chords(note_seq)

Predicts a chord in a note sequence with only note values, so no note durations atr taken into account.

predict_scales_degrees(note_seq)

This method is similar to Scales.get_scales_degrees_from_chord method but in this case applied to an input note_seq, not to a chord.

predict_possible_progressions(possible_chords)

Get all possible scales and degrees from a chords list (chord progression) We retrieve a list of degrees which items correspond to one time step each.

predict_progression(scales, scale)

Uses predict_possible_progressions to predict all the scales and progressions that belong to a note_seq but this method only returns one of them.

_all_note_seq_permutations(note_seq)

Returns a list of lists of all possible orders for a note seq.

_delete_repeated_note_names(note_seq)

Removes a repeated note in a note_seq.

_extract_note_positions(note_seq)

Extracts the note positions in the chromatic scale of the notes in a notes sequence.

_order_note_seq_by_chromatic_idx(note_seq)

Sorts a note seq (list of note objects) by the index of the notes in the chromatic scale.

get_harmonic_density(note_seq)

Computes the maximum number of notes that are overlapped in the harmonic axis.

Rhythm

This submodule contains the implementation of part of the paper:

[1] Roig, C., Tardón, L. J., Barbancho, I., & Barbancho, A. M. (2014). Automatic melody composition based on a probabilistic model of music style and harmonic rules. Knowledge-Based Systems, 71, 419-434. http://dx.doi.org/10.1016/j.knosys.2014.08.018

The implementation follows the paper method to predict rhythmic patterns. This module contains:

  1. Tempo (or bpm) estimation
    • get IOIs with get_ioi method.

    • get error ej

  2. Time signature estimation
    • get the labeled beat vector (or IOI’) from IOIs with get_labeled_beat_vector

    • get the Bar Split Vectors (BSV) for each beat (k in the paper) with get_split_bar_vector.

    k goes from 2 to 12 which are the most-common time_sig numerators. - compute the RSSM with each BSV with compute_rhythm_self_similarity_matrix. - get the time_sig numerator which will be the RSSM with the highest repeated bar instances.

  3. Rhythm extraction

  4. Pitch contour extraction

get_start_sec(notes)

Extracts the time start of the notes in a notes sequence.

get_ioi(all_note_on[, delete_overlap])

get ioi of a list of time start values

get_labeled_beat_vector(iois)

Convert IOI to the labeled beat vector (or IOI')

compute_rhythm_self_similarity_matrix(...)

This function computes the Rhythm Self-Similarity Matrix (RMSS).

plot_rmss(rmss[, k, save, filename])

compute_all_rmss(labeled_beat_vector)

This function computes all the RMSS for time_sig numerators (k) 2 to 12 and outputs the beat (k) which will be the predicted time_sig numerator.

get_symbolic_length_classes(notes)

Counts the total number of different note (NoteClassBase) classes.

note_length_histogram(notes)

Uses get_note_classes to build a 1D list vector of 12 dimensions in which each element represents the counts of each note name in the chromatic scale of 12 notes.

note_length_transition_matrix(notes)

Computes the Note Length Transition MAtrix (NLTM) of a list of Note objects.

plot_note_length_transition_matrix(nltm)

Take into account that if you generated a NLTM with triplets = False then the triplet argument in this function will also be False.

Self-Similarity Matrices

This submodule presents different implementations of self-similarity matrices.

The papers that are implemented in this sumbodule are the following:

[1] Louie, W. MusicPlot: Interactive Self-Similarity Matrix for Music Structure Visualization. https://wlouie1.github.io/MusicPlot/musicplot_paper.pdf

The process to obtain the SSM with this method is: 1. Group the notes in bars and subdivisions. 2. Extract the highest note in each subdivision. 3. Calculate m_prime = [p1-p2, d2/d1, …] with p the pitch and d the note duration. 4. Compute the SSM function.

compute_ssm(file[, ssm_type, measures, ...])

Computes the selected SSM.

self_similarity_louie(file)

Computes the SSM with Louie method: https://wlouie1.github.io/MusicPlot/musicplot_paper.pdf

self_similarity_single_measure(file, measure)

Computes the SSM with the selected measure for all the bars.

self_similarity_measures(file, measures)

Computes the SSM with the selected measure for all the bars.

plot_ssm(ssm[, segments, threshold, window, ...])

Plots a SSM.

_self_similarity(feature_vector)

Converts a feature vector with the highest notes per subdivision and bar in a Self-Similarity Matrix with the cosine distance.

binarize_self_similarity_matrix(ssm, threshold)

feature_vector(bar_highest_subdiv_notes)

Computes the m_prim vector which calculates the difference between 2 consecutive note's pitches and the division of the note's durations.

get_novelty_func(ssm[, is_normalized])

Computes the novelty function of a SSM.

get_segment_boundaries(ssm[, threshold, window])

Gets the segment boundaries of a SSM.

plot_novelty_from_ssm(ssm[, segments, ...])

Plots the novelty curve from a SSM.

Graphs

This submodule presents different implementations of self-similarity matrices.

The papers that are implemented in this sumbodule are the following:

[1] Jeong, D., Kwon, T., Kim, Y., & Nam, J. (2019) Graph neural network for music score data and modeling expressive piano performance. In International Conference on Machine Learning, 3060-3070 https://proceedings.mlr.press/v97/jeong19a.html

musa_to_graph(musa_object)

Converts a Musa object into a Graph where nodes are the notes and edges are connections between notes.

plot_graph(graph[, show])

Plots a graph with matplotlib.

Structure

This submodule segments symbolic music in its form or structure.

get_structure_boundaries_notes(musa_obj, level)

Get the note indexes where a section ends.

get_structure_boundaries_beats(musa_obj, level)

Get the beat indexes where a section ends.