Real time event accuracy

Dave Angel d at davea.name
Wed May 9 17:13:57 EDT 2012


On 05/09/2012 03:26 PM, Tobiah wrote:
>> I don't think you can really do this accurately enough to get good
>> sound, but the basic mechanism is time.sleep(t) which takes a floating
>> point argument.  That turns into the appropriate microsleep, I think.
> I think the time would have to come from a hardware clock.

Python has a high-res time function when run on an Intel X86 platform,
though I forget which one you should use on Windows.  The problem is
that Windows makes no assurance that you will be executing at that
particular point in time.  You can approximate it with time.sleep(),
which is what Paul Rubin was suggesting.

Windows is not a real time operating system.  Still, if the system is
lightly loaded, sleep() will probably get you within 50 milliseconds.

I don't think you should even worry about it till you see the
capabilities of whatever MIDI library you choose. I'd be surprised if it
doesn't allow you to attach timing hints to the notes, same as the file
format I discussed earlier.

-- 

DaveA




More information about the Python-list mailing list