At 4:06 AM -0500 2001/12/14, Detlef Lindenthal wrote: >### Hi David, >### better use "sprintf" in two places, which stands >### for *s*tring *print* with *f*ormat, OSTLT. >### And maybe it is better to mathematically _add_ those >### seconds and microseconds rather than _concatenating_ >### their strings. >### >### ;) My best result in quick typing was 0.008 seconds. >### >### Regards, Detlef
Thanks for the suggestions. Yes, I see that my method would have yielded 0.8 seconds instead of 0.008. That explains some inconsistent timing I had been seeing. I'm considering altering my harmonica and trumpet simulator programs (old versions are at http://www.macperl.com/macperl/depts/Code/_seay/) to be able to record what is played as accurately as possible. Your suggestion helps. I'm also thinking about adding the ability to play chords on the harmonica when multiple number keys are depressed. The program currently plays a fixed length "blow" note when a number key is pressed and a "draw" note when a shifted number key is pressed. I have come up with a procedure for handling the situations where an unshifted number key is pressed but then released unshifted (and vice versa) that utilizes an array to cross reference the unshifted number keys to their unshifted counter parts. I am currently trying to optimize the code so that the time it takes to process doesn't interfere with the timing of the key events when manually playing, and of the duration of the notes when the onscreen harmonica is playing. I wonder how accurate is that "0.008 seconds" that Detlef got. A slower processor might not be able to process the code quickly enough to time to that degree of accuracy. For my purposes tenths of a second is probably good enough. The original trumpet program required using the command (valve 1), option (valve 2), and control (valve 3) keys to manipulate the valves of the onscreen trumpet. The note is not actually sounded until the space bar is pressed (simulating blowing). Since an actual trumpet is properly fingered using the first three fingers of the right hand the original code used those modifier keys that were to the right of my older Mac's standard keyboard's space bar. My iBook only has those modifier keys to the left of the space bar so using these keys to finger the onscreen trumpet valves is backwards. I could use the modifier keys (reversing their valve playing order) on the left but then the right hand has to reach across the left hand (which is used to press the space bar). It would be more natural to use the 1, 2, and 3 keys (since they are numbered this way on an actual trumpet) instead, but when I wrote the original code I hadn't figured out how to detect multiple key presses and releases other than for the modifier keys. Any other suggestions are much appreciated. David Seay http://www.mastercall.com/g-s/