MarkCWirt / MIDIUtil

A pure Python library for creating multi-track MIDI files
Other
247 stars 49 forks source link

Problem with changeNoteTuning #22

Open ghost opened 6 years ago

ghost commented 6 years ago

I am trying to split microtones and normal semitones between two tracks and writing them to the corresponding track like this:

from midiutil.MidiFile import MIDIFile

degrees  = [60, 61, 60, 62, 60, 63, 60, 64, 60, 65]
duration = 1   # In beats
tempo    = 60  # In BPM
volume   = 100 # 0-127, as per the MIDI standard

track   = 0
channel = 0
tuning  = [(60, 200.243), (61,100.987)]
program = 0
bank    = 0
time    = 0
tracks = 2

MyMIDI = MIDIFile(tracks) # One track, defaults to format 1 (tempo track
                 # automatically created)

MyMIDI.addTempo(track,time, tempo)

MyMIDI.changeNoteTuning(1, tuning, tuningProgam=0)

for pitch in degrees:
    if pitch in (60,):
        MyMIDI.addNote(1, 0, pitch, time, duration, volume)
    else:
        print pitch
        MyMIDI.addNote(0, 0, pitch, time, duration, volume)
    time = time + .5

with open("/tmp/major-scale.mid", "wb") as output_file:
    MyMIDI.writeFile(output_file)

But i still hear the 61 as a microtone, although it has been writen to the non-micorotnal track. Can you help?