Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

midifile.py classifies most tracks as undefined #26

Open
FelixDeMan opened this issue May 19, 2021 · 1 comment
Open

midifile.py classifies most tracks as undefined #26

FelixDeMan opened this issue May 19, 2021 · 1 comment

Comments

@FelixDeMan
Copy link

FelixDeMan commented May 19, 2021

When trying to preprocess my midi files (using the DataPreProcessing notebook), it keeps on returning None when

try: 
      # if duet_only and num_piano_tracks(input_path) not in [1, 2]: return None
       input_file = compress_midi_file(input_path, min_variation=min_variation, cutoff=cutoff) # remove non note tracks and standardize instruments

in the transform_midi function.

This leads to no conversion to npy's of my midi files

@FlowkoHinti
Copy link

FlowkoHinti commented Jul 1, 2022

Hope this is still relevant, there is a small bug in the utils/midifile.py. During preprocessing this script validates the midifiles and extracts only the relevant Miditracks. However during this track selection step the get_track_instrument function looks for PROGRAM_CHANGED messages by comparing the music21 MidiEvent type to the string 'PROGRAM_CHANGED', whereas the event type is a enum of type ChannelVoiceMessages.

In summary change following line in the utils/midifile.py line 98:

def get_track_instrument(t):
   for idx,e in enumerate(t.events):
       #if e.type == 'PROGRAM_CHANGE': return e.data <-- issue here
       if e.type == ChannelVoiceMessages.PROGRAM_CHANGE:return e.data # <-- my fix
   return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants