There’s only one sure way to know when your stimulus activates; use an external device that monitors and records the onset.
With the advent of LCD and other advanced visual displays, the activation time of a pixel is difficult to predict based solely on your program’s execution. The same is true with activating auditory stimulus. While the update rate of a 60 Hz display might be acceptable for most applications, Neuroscience experiments require precise timing. With tolerances below 10 ms (0.010 seconds), it is almost impossible to rely on your computer’s timer alone to tell you the latency between when your program sent the command and the instance of activation.
There is a solution however. For visual stimulus, we use a simple photocell, which instantly detects photons, to record the exact moment when the monitor renders an image onto the screen. For auditory stimulus, we can use a microphone in a similar fashion. Then we send the voltage signal back to our system on one of the free analog input channels. This way you can record the onset (and offset) of the stimulus and synchronize this event with behavior and stimulus presentation. If the latency is constant, you can reliably control the synchronization between stimulus, behavior, and electrophysiological recordings.
For more information take a look at the following links: