Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Python Midi Package » Absolute/Relative Time issue with update_time()
Downloads
You can download mxm products here.

Due to it's technical and international nature, this section is in english.

Max M Has a blog too.

og er glad for mad

 

Comment

Above in this comment thread: Python Midi Package

Absolute/Relative Time issue with update_time()

Posted by Anonymous User at 2010-05-22 02:19 AM
Hi all,

Can anyone explain why the below doesn't work? I'm essentially doing note_on()'s out of order, but the resulting out-put .mid file doesn't seem to take notice of the out-of-order-notes.
For example, I first do: (abstracted some non-important details away)

update_time(0)
note_on(note="C4")
note_on(note="G4")

update_time(200)
note_off(note="C4")
note_off(note="G4")

The above is all fine and dandy - however, say I add the following line in:

update_time(0, relative=0) # To make it absolute-time
note_on(note="E4")

The resulting output file doesn't have the E! What am I doing wrong?

Thanks!

====== If you want, here's the whole file:

from MidiOutFile import MidiOutFile

out_file = 'midiout/newtest_type0.mid'
m = MidiOutFile(out_file)

# non optional midi framework
m.header()
m.start_of_track()

# musical events

m.start_of_track(1)
m.sequence_name('Piano')
m.instrument_name('Piano')

m.update_time(0)
m.note_on(channel=1, note=0x3C)
m.note_on(channel=1, note=0x43)


m.update_time(150)
m.note_off(channel=1, note=0x3C)
m.note_off(channel=1, note=0x40)
m.note_off(channel=1, note=0x43)

m.update_time(0,relative=0)
m.note_on(channel=1, note=0x40)


# non optional midi framework
m.update_time(0)
m.end_of_track() # not optional!

m.eof()