cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.09k stars 397 forks source link

translateStreamToString fails if the stream contains Unpitched notes #1596

Closed fergusq closed 1 year ago

fergusq commented 1 year ago

music21 version

8.3.0

Problem summary I was trying to use RepeatFinder on a score that contains a percussion track, but it crashes when calling simplify. It tries to convert the measures to strings, and the translateStreamToString method fails due to the Unpitched notes not containing a pitch field.

Steps to reproduce

s = m21.stream.Stream()
s.append(m21.note.Unpitched("B4"))
m21.search.translateStreamToString(s)

Expected vs. actual behavior translateStreamToString returns a string representation for the unpitched note.

More information

mscuthbert commented 1 year ago

Thanks for the diagnosis. I put in a quick fix which will prevent crashing, but it treats Unpitched the same as rests for now. A more power algorithm is probably needed.