partitura.musicanalysis

Tools for music analysis.

partitura.musicanalysis.estimate_voices(note_info, monophonic_voices=False)[source]
Voice estimation using the voice separation algorithm
proposed in [6].
Parameters:
  • note_info (structured array, Part or PerformedPart) – Note information as a Part or PerformedPart instances or as a structured array. If it is a structured array, it has to contain the fields generated by the note_array properties of Part or PerformedPart objects. If the array contains onset and duration information of both score and performance, (e.g., containing both onset_beat and onset_sec), the score information will be preferred.
  • monophonic_voices (bool) – If True voices are guaranteed to be monophonic. Otherwise notes with the same onset and duration are treated as a chord and assigned to the same voice. Defaults to False.
Returns:

voice – Voice for each note in the notearray. (The voices start with 1, as is the MusicXML convention).

Return type:

numpy array

References

[6]Chew, E. and Wu, Xiaodan (2004) “Separating Voices in Polyphonic Music: A Contig Mapping Approach”. In Uffe Kock, editor, “Computer Music Modeling and Retrieval”. Springer Berlin Heidelberg.
partitura.musicanalysis.estimate_key(note_info, method='krumhansl', *args, **kwargs)[source]

Estimate key of a piece by comparing the pitch statistics of the note array to key profiles [2], [3].

Parameters:
  • note_info (structured array, Part or PerformedPart) – Note information as a Part or PerformedPart instances or as a structured array. If it is a structured array, it has to contain the fields generated by the note_array properties of Part or PerformedPart objects. If the array contains onset and duration information of both score and performance, (e.g., containing both onset_beat and onset_sec), the score information will be preferred.
  • method ({'krumhansl'}) – Method for estimating the key. For now ‘krumhansl’ is the only supported method.
  • kwargs (args,) – Positional and Keyword arguments for the key estimation method
Returns:

String representing the key name (i.e., Root(alteration)(m if minor)). See partitura.utils.key_name_to_fifths_mode and partitura.utils.fifths_mode_to_key_name.

Return type:

str

References

[2]Krumhansl, Carol L. (1990) “Cognitive foundations of musical pitch”, Oxford University Press, New York.
[3]Temperley, D. (1999) “What’s key for key? The Krumhansl-Schmuckler key-finding algorithm reconsidered”. Music Perception. 17(1), pp. 65–100.
partitura.musicanalysis.estimate_spelling(note_info, method='ps13s1', **kwargs)[source]

Estimate pitch spelling using the ps13 algorithm [4], [5].

Parameters:
  • note_info (structured array, Part or PerformedPart) – Note information as a Part or PerformedPart instances or as a structured array. If it is a structured array, it has to contain the fields generated by the note_array properties of Part or PerformedPart objects. If the array contains onset and duration information of both score and performance, (e.g., containing both onset_beat and onset_sec), the score information will be preferred.
  • method ({'ps13s1'}) – Pitch spelling algorithm. More methods will be added.
  • **kwargs – Keyword arguments for the algorithm specified in method.
Returns:

spelling – Array with pitch spellings. The fields are ‘step’, ‘alter’ and ‘octave’

Return type:

structured array

References

[4]Meredith, D. (2006). “The ps13 Pitch Spelling Algorithm”. Journal of New Music Research, 35(2):121.
[5]Meredith, D. (2019). “RecurSIA-RRT: Recursive translatable point-set pattern discovery with removal of redundant translators”. 12th International Workshop on Machine Learning and Music. Würzburg, Germany.
partitura.musicanalysis.estimate_tonaltension(note_info, ws=1.0, ss='onset', scale_factor=0.09249316305671976, w=array([0.516, 0.315, 0.168]), alpha=0.75, beta=0.75)[source]

Compute tonal tension ribbons defined in [1]

Parameters:
  • note_info (structured array, Part or PerformedPart) – Note information as a Part or PerformedPart instances or as a structured array. If it is a structured array, it has to contain the fields generated by the note_array properties of Part or PerformedPart objects. If the array contains onset and duration information of both score and performance, (e.g., containing both onset_beat and onset_sec), the score information will be preferred. Furthermore, this method requires pitch spelling and key signature information. If a structured note array is provided as input, this information can be optionally provided in fields step, alter, ks_fifths and ks_mode. If these fields are not found in the input structured array, they will be estimated using the key and pitch spelling estimation methods from partitura.musicanalysis.estimate_key and and partitura.musicanalysis.estimate_spelling, respectively.
  • ws ({int, float, np.array}, optional) – Window size for computing the tonal tension. If a number, it determines the size of the window centered at each specified score position (see ss below). If a numpy array, a 2D array of shape (len(ss), 2) specifying the left and right distance from each score position in ss. Default is 1 beat.
  • ss ({float, int, np.array, 'onset'}, optional.) – Step size or score position for computing the tonal tension features. If a number, this parameter determines the size of the step (in beats) starting from the first score position. If an array, it specifies the score positions at which the tonal tension is estimated. If ‘onset’, it computes the tension at each unique score position (i.e., all notes in a chord have the same score position). Default is ‘onset’.
  • scale_factor (float) – A multiplicative scaling factor.
  • w (np.ndarray) – Weights for the chords
  • alpha (float) – Alpha.
  • beta (float) – Beta.
Returns:

tonal_tension – Array containing the tonal tension features. It contains the fields cloud_diameter, cloud_momentum, tensile_strain and onset.

Return type:

structured array

References

[1]D. Herremans and E. Chew (2016) Tension ribbons: Quantifying and visualising tonal tension. Proceedings of the Second International Conference on Technologies for Music Notation and Representation (TENOR), Cambridge, UK.