Disklavier and Google Magenta MAESTRO MIDI Conversion for Yamaha Piano

DAW's, Audio, MIDI, VST's and all other music software.

Moderators: parametric, Derek, Saul

Post Reply
User avatar
essandess
Posts: 2
Joined: Fri Jul 31, 2020 11:21 am
Location.: USA

Disklavier and Google Magenta MAESTRO MIDI Conversion for Yamaha Piano

Unread post by essandess »

I'm using Google's new Magenta project to convert piano audio recordings to MIDI.

I'd like to be able to play these MIDI files on a Yamaha digital piano, as well as the original MIDIs in the MAESTRO dataset used to train the transformer model, and play the related MIDIs in Yamaha's "Signature MIDI Collection".

The problem is that none of these MIDI files will play on the Yamaha piano, which is a Modus model, not a professional Disklavier.

I've found by replacing the original MIDI's meta sequencer specific meta messages by hacking in MIDI contents I already have that do work, the MIDI's will all play, but am uncertain about the sequencer specific messages I should be using.

Is there any guidance to interpret Yamaha's sequencer MIDI messages so that I can make an informed choice in the conversion?

Or should I simply omit all these Disklavier sequencer specific messages for generic playback?

Here's the sequencer specific messages I added for playback on a Yamaha Modus model:

Code: Select all

mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 123, 0, 88, 70, 48, 50, 0, 27),time=0),
mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 113, 0, 1, 0, 1, 0),time=0),
mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 113, 0, 0, 0, 65),time=0),
mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 123, 12, 1, 0),time=0)
Here's the MIDI conversion script:

midi_yamaha_modus_convert.py:

Code: Select all

#!/usr/bin/env python3

# Convert MIDI files if Type 0 or 1 to playable MIDIs on a Yamaha Modus

import mido, os, re, sys

midi_re = re.compile(r'\.midi?$',re.IGNORECASE)

copyright_default = '(c) 2020 Steven T. Smith, MIT License'
yamaha_sequencer_msgs = [
    mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 123, 0, 88, 70, 48, 50, 0, 27),time=0),
    mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 113, 0, 1, 0, 1, 0),time=0),
    mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 113, 0, 0, 0, 65),time=0),
    mido.midifiles.meta.MetaMessage(type='sequencer_specific',data=(67, 123, 12, 1, 0),time=0)
]

def midi_convert(midi_filepath, suffix='_modus',
                 yamaha_sequencer_msgs=yamaha_sequencer_msgs,
                 copyright=copyright_default):
    mid_orig = mido.MidiFile(midi_filepath)
    # convert from MIDI type 1 to type 0
    track_orig = mido.merge_tracks(mid_orig.tracks)
    mid_new = mido.MidiFile()
    track = mido.MidiTrack()
    mid_new.tracks.append(track_orig)
    trk = track_orig
    # track_name
    if len([m for m in trk if m.is_meta and m.type == 'track_name']) == 0:
        msg = mido.midifiles.meta.MetaMessage(type='track_name',name='.'.join(os.path.basename(mid_orig.filename).split('.')[:-1]) ,time=0),
    # meta messages, omitting sequencer_specific
    for msg in [m for m in trk if m.is_meta and m.type != 'sequencer_specific']:
        track.append(msg)
    # copyright
    if len([m for m in trk if m.is_meta and m.type == 'copyright']) == 0:
        msg = mido.midifiles.meta.MetaMessage(type='copyright',text=copyright,time=0),
    # Yamaha sequencer_specific
    for msg in yamaha_sequencer_msgs:
        track.append(msg)
    # not meta messages
    for msg in [m for m in trk if not m.is_meta]:
        track.append(msg)

    mid_new.save(midi_re.sub('',midi_filepath) + suffix + '.mid')

def midi_convert_in_names(names):
    for name in names:
        for root, directories, files in os.walk(name):
            for file in [f for f in files if bool(midi_re.findall(f))]:
                midi_convert(os.path.join(root, file))
 
if __name__=='__main__':
    if len(sys.argv) > 1: midi_convert_in_names(sys.argv[1:])


User avatar
essandess
Posts: 2
Joined: Fri Jul 31, 2020 11:21 am
Location.: USA

Re: Disklavier and Google Magenta MAESTRO MIDI Conversion for Yamaha Piano

Unread post by essandess »

Except for decoding the the sequencer_specific codes, this is all working well using Yamaha’s Modus F01 Data List from their download library.

It’s just necessary to get the correct header set_tempo, sysex, control_change, program_change, and other messages the way the Calvinova MIDI chip wants to see them, and strip out any invalid messages not in the MIDI spec.

I’d appreciate any pointers to the sequencer_specific codes—I’m not aware of any documentation on these.


Post Reply