Exemple #1
0
def __make_consistent_time_signature__(pattern):
    print ("Making consitent time signature")
    time_signatures = midiutil.get_events_from_pattern(pattern, "Time Signature")
    if len(time_signatures) == 0:
        raise IndexError("No time signatures in pattern")
    to_remove = time_signatures[1:]
    for track in pattern:
        midiutil.remove_events_from_track(track, to_remove)
Exemple #2
0
def __make_consistent_tempo__(pattern):
    print ("Making consitent tempo")
    tempos = midiutil.get_events_from_pattern(pattern, "Set Tempo")
    if len(tempos) == 0:
        raise IndexError("No tempos in pattern")
    to_remove = tempos[1:]
    for track in pattern:
        midiutil.remove_events_from_track(track, to_remove)
Exemple #3
0
def __name_all_tracks__(pattern):
    print ("Naming all tracks")
    
    for index, track in enumerate(pattern):
        names = midiutil.get_events_from_track(track, "Track Name")
        if len(names) == 0:
            name = "Track "+str(index)
            name_event = midi.TrackNameEvent(tick=0, text=name)
            track.insert(0, name_event)
            print "    naming track at index", index, "\""+name+"\""
        else:
            if names[0].text == '':
                names[0].text = "Track "+str(index)
            midiutil.remove_events_from_track(track, names[1:])