Python Midi Package: writing events non-chronologically

Max M maxm at mxm.dk
Thu Nov 24 14:51:24 CET 2005


tim wrote:
> Someone using Python Midi Package from 
> http://www.mxm.dk/products/public/ lately?
> 
> I want to do the following :
> write some note events in a midi file
> then after doing that, put some controllers at the beginning of the 
> midifile
> (because I want to be able to make those dependant on what notes were 
> just written)
> 
> def midctrls():
>    global roffset, melchan, roffset, gmt, timedisplay, out_file, midi, 
> usednotes, n
>    midi.reset_time()      #seems to do nothing
>    for cha in range(16):
>        if cha==1:
>            midi.abs_time=0   #seems to do nothing
>            midi._relative_time = 0   #seems to do nothing, but I can 
> imagine why
>            midi._absolute_time = 0   #seems to do nothing
>            midi.update_time(new_time=0, relative=0)  #although I give 
> the variable relative=0 it seems to be relative ?
>            midi.continuous_controller(cha, 0, 122)
> (snip)
> 
> With this code I want a controller number 0 with value 122 to be written 
> at the beginning of my midifile.
> It is written at the end, how I move the writing position to the beginning?
> 


You should make a wrapper around the library that handles the midi 
events in a data structure.

When your musical structure is then is complete, you use the midi 
library to write it to disk.

I have attached a simple example here.

-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Notes2midi.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20051124/46921ce1/attachment.ksh>


More information about the Python-list mailing list