Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Python Midi Package » You need to set the time before each event
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 » Using Python Midi package

You need to set the time before each event

Posted by maxm at 2004-03-17 01:35 AM
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.update_time(0)
m.note_on(channel=1, note=0x3E)
m.update_time(0)
m.note_on(channel=1, note=0x43)

m.update_time(96)
m.note_off(channel=1, note=0x3C)
m.update_time(0)
m.note_off(channel=1, note=0x3E)
m.update_time(0)
m.note_off(channel=1, note=0x43)
m.update_time(0)
m.end_of_track()


The update_time() is allways implied. If you don't set it manually, it
will use the previous.

So in your case you will have 96 clicks between the note_off's in your
file.

To the midi file it will look like:

m.update_time(96)
m.note_off(channel=1, note=0x3C)
m.update_time(96)
m.note_off(channel=1, note=0x3E)
m.update_time(96)
m.note_off(channel=1, note=0x43)
m.update_time(96)
m.end_of_track()

That can seem as an odd behavious at first. But there is a very good
technical reason. Though it is rather long-vinded.

It has to do with using the same api for doing midi-file and realtime
processing.

For a delta time of 0 you can get away with only setting the first 0 value update_time
though.


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=0x3E)
m.note_on(channel=1, note=0x43)

m.update_time(96)
m.note_off(channel=1, note=0x3C)
m.update_time(0) ####### 0 clicks until next event.
m.note_off(channel=1, note=0x3E)
m.note_off(channel=1, note=0x43)
m.end_of_track()

My chords soudns OK now

Posted by Anonymous User at 2004-03-23 10:28 AM
Thank you for your response. I'm able to write chords, single notes and rests now.

I'm writing some wrapper code and some tests for my convenience. ¿May I send it to you, or post it here?.

Again, thank you for your time and work.

Regards.

David