On Sun, 14 Dec 2008, Bad Mutha Hubbard wrote: > John O'Hagan wrote: > > On Wed, 10 Dec 2008, badmuthahubbard wrote: [...] > > from time import time, sleep > > > > start = time() > > for event in music: > > duration=len(event) #Really, the length of the event > > play(event) > > while 1: > > timer = time() > > remaining = start + duration - timer > > if remaining < 0.001: > > break > > else: > > sleep(remaining / 2) > > stop(event) > > start += duration > >
> Very interesting approach, halving the remaining duration. Right now > I'm not working with note-offs, Csound takes care of the duration. I > just need to be able to call the notes at the right times. [...] I'm also using the above code without the "stop(event)" line for playing non-midi stuff (fixed-length samples for example), which from the sound of it also applies to your requirement - IOW, you _can_ use it just to start notes at the right time, because the note-playing loop sleeps till then. [...] > I also like and respect Fluidsynth, but I'm working on a pretty > microtonal system, and MIDI doesn't have enough microtonal support. > [...] I'm certainly not trying to convert you to Fluidsynth - I'm more likely to convert to Csound - but just for the record, you can do microtonal stuff fairly easily using Fluidsynth's "settuning" command. In my program I can use any equal-tempered division of the octave by preceding each set of events which require it with this: mesg = [ "select " + channel + " " + font + " " + bank+ " " + program + " \ntuning name 0 " + program + "\n"] for key in xrange(128): pitch = str((((key - 60) * 12.0 / divisor) + 60) * 100) mesg.append( "tune " + bank + " " + program + " " + str(key) + " " + pitch + "\n") mesg.append("settuning " + channel + " " + bank " " + program + "\n") mesg = ''.join(mesg) fluidsynth_socket.send(mesg) where "divisor" is the number you want to divide the octave by (the other names are self-descriptive). The reason for the "60"s in there is just to keep middle C where it is. For more complex/non-linear pitch-warping, the rest of the "pitch = " line could be replaced with any pitch-altering function taking "key" as an argument; but I haven't tried that yet. I'd be interested to hear about the microtonal system(s) you're using. Regards, John -- http://mail.python.org/mailman/listinfo/python-list