I am trying to create a midifile using mido but I didn't find a clear example of how to create a midifile using mido. what I am looking for is the equivilent of this code using midiutil:
degrees = [60, 62, 64, 65, 67, 69, 71, 72] # MIDI note number
track = 0
channel = 0
time = 0 # In beats
duration = 1 # In beats
tempo = 60 # In BPM
volume = 100 # 0-127, as per the MIDI standard
MyMIDI = MIDIFile(1) # One track, defaults to format 1 (tempo track is created
# automatically)
MyMIDI.addTempo(track, time, tempo)
MyMIDI.addTimeSignature(0, time, 4, 2, 24)
for i, pitch in enumerate(degrees):
MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)
with open("major-scale.mid", "wb") as output_file:
MyMIDI.writeFile(output_file)
I hope someone wants to explain how to(using mido):
- create midiobject
- set tempo
- set timesignature
- add note
- add keysignature
- save the file as
midifile.mid
.
Thanks in advance!