I’m doing some preliminary work for an experimental control system in
psychology. The typical experiment is to display or in the case of sound
play some sort of stimulus to the subject and then record a timed
response. What makes this tricky are the psuedo real-time requirements.
Assuming the stimulus is some sort of image, a typical trial would work
- Load the image into an offscreen buffer.
- Draw the image to the screen.
2.5 When the vertical refresh begins start a timer.
- When the subject presses a key, stop the timer and record the time.
Drawing images, playing sounds and polling the keyboard are natural
things for a game development library to do so I figure SDL might be the
right tool here.
What I’m concerned about is
whether firing an event is possible when a vertical refresh begins.
(The point being that the timer has to start when the actual drawing to
the screen begins).
Key press notification latency. The specs call for something like
100% of keypresses notified in < 5 ms with 99% < 1 ms. This may not even
be possible with a keyboard but we are trying to avoid using "custom"
hardware. What this means, I suppose, is that polling the keyboard in a
while loop should detect a keypress hopefully within less than 1 ms of
the subject actually pressing a key. As I said above this may not be
possible with keyboard hardware.
This is on Linux, and we’re hoping not to have to go with some RTLinux
variant, but we may have no choice.
Any comments appreciated and thanks for reading this slightly off-topic
Social Science Research Computing
University of Chicago