hi john and roger- i wanted to do a portable midi project with python and found pyPortMidi to be just what i needed. i got it up and running ok, i just have one problem: once i call Output.Write with a certain timestamp in the future, if i later call Output.Write again with an earlier timestamp, that message is not sent until after the first one. shouldn't portmidi process messages in the order of their timestamps, not the order in which they were sent? i've attached a small example. this behavior is necessary if you want to use a simple "set and forget" approach -- send a note-on and its future note-off to channel 0, then the same thing for another note on channel 1, intended to sound at close to the same time. but as it is, the note-off of the first blocks the note-on of the second.
i thought i'd also attach a summary of how to install everything from scratch, since i just did it. i found simplesynth, which is handy for standalone laptop work, especially when using multiple channels as my example does. is there a searchable archive of the portmidi mailing list? i can only find: http://lists.create.ucsb.edu/pipermail/media_api/ thanks for your help and beautiful work! -erik following instructions for OSX at: http://cratel.wichita.edu/cratel/cratel_pyportmidi i'm on 10.4.11/intel and python 2.6 ( http://www.python.org/ftp/python/2.6/python-2.6-macosx.dmg) i downloaded: portmidi: http://downloads.sourceforge.net/portmedia/portmidi-src-82.zip?modtime=1213390666&big_mirror=0 vmk: http://www.fredrikolofsson.com/software/vmk16osx.sit pyPortMidi: http://alumni.media.mit.edu/~harrison/images/pyPortMidi-0.0.3.zip pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.8.5.tar.gz simplesynth: http://notahat.com/downloads/SimpleSynth-1.0.zip 1) according to portmidi readme, in portmidi directory, i did: make -f pm_mac/Makefile.osx output seemed OK note pyPortMidi's readme says to use "xcodebuild -project pm_mac.pbproj" from inside pm_mac directory -- i didn't do this 2) according to pyrex INSTALL.txt, in pyrex directory, i did: python setup.py install output seemed OK i did not edit Pyrex/Mac/DarwinSystem.py. the os.environ line was at a much higher line number than 21 in this version. it read: os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.3" 3) copy the following portmidi/porttime/porttime.h -> pyPortMidi portmidi/pm_common/portmidi.h -> pyPortMidi portmidi/pm_mac/libportmidi.a -> pyPortMidi/OSX portmidi/porttime/libporttime.a -> pyPotMidi/OSX 4) changed line in pypm.pyx to: while(Pm_Poll(self.midi) != pmNoError): 5) changed line in pyPortMidi's setup.py to: libraries = ["portmidi", "porttime"], 6) deleted pyPortMidi's build directory (from previous failed build before i did steps 4-6) 7) in pyPortMidi directory: sudo python setup.py install output seemed OK 8) start simplesynth, make sure 'simple synth virtual input' is midi source 9) in pyPortMidi directory: python test.py output works 10) start vmk, make sure 'from vmk 1' is midi port 11) in pyPortMidi directory: python test.py input works note: i didn't understand how to use vmk to test portmidi independent of pyPortMidi, as suggested on john's wiki
import pypm def playChord(MidiOut,notes,chan,vel,dur,time): ChordList = [] for i in range(len(notes)): ChordList.append([[0x90 + chan,notes[i],vel], time]) MidiOut.Write(ChordList) ChordList = [] for i in range(len(notes)): ChordList.append([[0x90 + chan,notes[i],0], time+dur*1000]) MidiOut.Write(ChordList) def test(): latency=200 #latency is in ms, 0 means ignore timestamps dev = 0 MidiOut = pypm.Output(dev, latency) tempo=100 dur=60.0/tempo/2 notes=[60, 63, 67] n=0 t=pypm.Time() #current time in ms while n<10: t+=2*dur*1000 playChord(MidiOut,[notes[0]-12],1,127,dur,t) playChord(MidiOut,notes,0,60,dur,t) n+=1 while pypm.Time()<t+2*dur*1000: pass del MidiOut pypm.Initialize() test() pypm.Terminate()
_______________________________________________ media_api mailing list media_api@create.ucsb.edu http://lists.create.ucsb.edu/mailman/listinfo/media_api