magenta / mt3

MT3: Multi-Task Multitrack Music Transcription
Apache License 2.0
1.41k stars 185 forks source link

Track/instrument naming #44

Closed olaviinha closed 2 years ago

olaviinha commented 2 years ago

I see there are multiple references to instrument names, particularly in preprocessors.py. However, transcribed midi file is saved with all tracks unnamed. I tried to look through the code to see if names would be easy to add (e.g. as per _SLAKH_CLASS_PROGRAMS), but unfortunately the code is largely sorcery to me without proper diving.

Any of the following solutions will solve my problem at hand: a) Only drum tracks are named drum tracks. b) All tracks are named according to instrument. c) Some other way to output information in the process which track numbers are drum tracks.

Anybody who's more familiar with the code, any tips on passing the instrument names to the resulting midi file? Is this doable?

olaviinha commented 2 years ago

Ok I have created a pull request for this in the Magenta note-seq repository.

Until then and in case PR is rejected, it is solvabe by simply post-processing the midi file as follows:

note_seq.sequence_proto_to_midi_file(est_ns, '/tmp/transcribed.mid')
pretty_mid = pretty_midi.PrettyMIDI('/tmp/transcribed.mid')
for inst in pretty_mid.instruments:
  inst.name = 'Drums' if inst.is_drum else pretty_midi.program_to_instrument_name(inst.program)
pretty_mid.write('/tmp/transcribed-with-instrument-names.mid')

Leaving this open as a feature request. Feel free to close if feature is assessed as unbeneficial in this repository.

cghawthorne commented 2 years ago

Thanks for the PR! This is now fixed by https://github.com/magenta/note-seq/pull/60