Tools for music analysis.

partitura.musicanalysis.estimate_voices(notearray, monophonic_voices=False)[source]

Voice estimation using the voice separation algorithm proposed in [1].

  • notearray (numpy structured array) – Structured array containing score information. Required fields are pitch (MIDI pitch), onset (starting time of the notes) and duration (duration of the notes). Additionally, It might be useful to have an id field containing the ID’s of the notes. If this field is not contained in the array, ID’s will be created for the notes.
  • 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.

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

Return type:

numpy array


[1]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_array, method='krumhansl', *args, **kwargs)[source]

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

  • note_array (structured array) – Array containing the score
  • method ({'krumhansl', 'temperley'}) – Method for estimating the key. Default is ‘krumhansl’.
  • kwargs (args,) – Positional and Keyword arguments for the key estimation method

  • root (str) – Root of the key (key name)
  • mode (str) – Mode of the key (‘major’ or ‘minor’)
  • fifths (int) – Position in the circle of fifths


[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_array, method='ps13s1', *args, **kwargs)[source]

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

  • note_array (structured array) – Array with score information
  • method (str (default 'ps13s1')) – Pitch spelling algorithm. More methods will be added.
  • *args – positional arguments for the algorithm specified in method.
  • **kwargs – Keyword arguments for the algorithm specified in method.

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

Return type:

structured array


[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.