On 06/09/2007, Veli-Pekka Tätilä <[EMAIL PROTECTED]> wrote:
> How good is the Win32::GUI timer for semi realtime applications?

Pretty much useless.  The underlying mechanism (using the WM_TIMER
message) has no guarantees on accuracy, and if the application is
processing many messages delivery of WM_TIMER messages takes the
lowest priority and will likely happen late.

> I've
> codedd a drum machine, minus some final tweaks and testing, in Perl
> using Win32::GUI as the GUI lib and Win32::MIDI for MIDI. I generate my
> own note off events (note on velocity 0) so that Win32::MIDI does not
> have to sleep. As I want the ability to operate the GUI while the thing
> plays back stuff, I use Win32::GUI::Timer as the heart beat for my step
> sequencer. I need the ability to time pretty exactly 32th notes from 50
> to 250 bpm (150 to 30 ms),

I expect you'll need a different mechanism.  Win32 provides special
multimedia timer APIs for this purpose (look up timeSetEvent and the
related time* functions in MSDN).

> since I want to be able to quantize the
> user's input to the closest 16th note (step). I'd also need a pretty
> exact sleep for generating lag for swing, at max one 32th note and
> possibly much smaller values, too. I'm using Win32::Sleep for the swing,
> at the moment.

Win32::Sleep won't accurately time less that about 50ms (IIRC),
especially on older machines.

> Timing seems surprisingly stable and even though I use large amounts of
> objects (each step is one) and hash lookups Perl's CPU usage shows 0,
> even when playing simultaneously 12 parts at 250 bpm. However, at some
> pretty normal tempo ranges like 130 to 140 BPM, changing the tempo does
> seem to have very little effect. However, if I export the data as MIDi
> at 960 PPQ, I use the MIDI Perl modules for that, the tempo does change.

Right - WM_TIMER messages get delivered when they can - at some point
they stop getting delivered any faster ...

Regards,
Rob.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to