At 7:24 PM -0000 2002/02/01, [EMAIL PROTECTED] wrote:
>> How often are you calling "WaitNextEvent"?
>
>That raises a good point. I was calling it more or less continuously,
>i.e. within the (very small) main loop. But if my woes are caused by it
>sucking up too many resources, it would be trivial to call it only at the
>beginning of each new beat pattern. Judging from the behavior of your
>sample script: if I press and release a key, the keyDown will be queued up
>and caught by the next call to WaitNextEvent, even if it occurs a few
>seconds later. Correct?
Yes. The following code demonstrates...
#!perl
use Mac::Events;
use Mac::Events qw(@Event $CurrentEvent);
use Mac::LowMem;
$Event[keyDown] = \&keyDown_Handler;
print "Press keys 1, 2, 3, 4 in quick succession...\n\n";
while ($count != 1) { WaitNextEvent } # Don't start until a key is pressed
WaitNextEvent
sleep(2);
WaitNextEvent
print "DONE!\n\n";
exit;
sub keyDown_Handler {
my($ev) = @_;
$key = chr($ev->character);
print "$key\n\n";
$count++;
}
__END__
Here is the output after following the instructions...
Press keys 1, 2, 3, 4 in quick succession...
1
2
DONE!
3
------------
Surely there is a limit to number of characters that are held in the buffer.
Is this prerecorded music you're working with?
David Seay
http://www.mastercall.com/g-s/