2

The code snippet is from a popular Coursera course

midi_data = converter.parse(data_fn)
# Get melody part, compress into single voice.
melody_stream = midi_data[5]     # For Metheny piece, Melody is Part #5.
melody1, melody2 = melody_stream.getElementsByClass(stream.Voice)

The error thrown is:-

ValueError: not enough values to unpack (expected 2, got 0)

and when using this:-

melody1, melody2 = melody_stream.recurse().getElementsByClass(stream.Voice)

the error thrown is:-

ValueError: too many values to unpack (expected 2)

Can you guide how to debug this?

Ahmed Ahdy
  • 21
  • 3
  • Does this answer your question? [music21 getElementsByClass not showing any output for class stream.Voice](https://stackoverflow.com/questions/70040337/music21-getelementsbyclass-not-showing-any-output-for-class-stream-voice) – Jacob Walls Dec 24 '21 at 14:43

1 Answers1

1

the newest version of music21 (7.x) has some changes about the returns of

melody_stream.getElementsByClass()

if u don't wanna examine it, try the old version to avoid this problem like:

pip install music21==6.7.0
ColinY
  • 19
  • 4