I'm processing a bulk of midi files that are made for existing pop songs using music21.
While channel 10 is reserved for percussions, melodic tracks are all over different channels, so I was wondering if there is an efficient way to pick out the main melody (vocal) track.
I'm guessing one way to do it is to pick a track that consists of single notes rather than overlapping harmonics (chords), and the one that plays throughout the song, but is there any other efficient way?
Depending on how your particular files are encoded, you could try filtering based on each part's name. That would look something like this:
import music21
from music21 import *
piece = converter.parse("full_path_to_piece.midi")
for part in piece.parts:
print(part[0].bestName()) # replace this print statement with a relevant if statement