Skip to content

mxm, IT's mad science

Sections
Personal tools
You are here: Home » Products » Open Source » Python Midi Package » Using Python Midi package
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

Posted by Anonymous User at 2004-03-15 02:47 PM
Hello, Max.

I'm playing with your beatiful module. It is what I'm looking for.

I have a doubt: how I can write chords in a track?

I've tried to write three notes simultaneously:

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


but it generates some strange note durations in my sequencer: each note has a different duration.
(I've used different sequencers: AnvilStudio (win32), Jazz++, Muse and Rosegarden).

How can I solve it?
I thank your time and work.

Regards.

David

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()

Status

Posted by Anonymous User at 2004-04-08 02:42 PM
What's the status of this project? Has any more work been done on this? It looks great and I plan on using it.

Thanks! Jeremy

python midi

Posted by Anonymous User at 2004-06-09 07:09 PM
Hi Nice work !!!
can i put lyrics to each note ???

thnx

expression controller

Posted by Anonymous User at 2004-08-10 06:46 PM
Hi,

I'm new to python.

How would I add expression contoller messages to notes?

Thanks

Calvin 79