from music21 import *
sBach = corpus.parse('bach/bwv7.7')
for p in sBach.parts:
print("Part: ", p.id)
for n in p.flat.notes:
print(n.pitch.midi)
Note that .notes
includes Chord
objects, which don't have a .pitch
property. So for complex scores you may need to separate out the chords from notes or iterate over p.pitches
. I think you'll want to go through the music21 User's Guide a bit more before continuing.