Welcome! Log In Create A New Profile

Advanced

Auditory stimulus durations

Posted by Matty 
Auditory stimulus durations
January 08, 2024 07:40AM
Dear Jaewon

The auditory stimulus I run using the AudioSound function lasts longer than coded for by about 50ms. For instance, if coded to run for 100ms, the duration between the event marker of the auditory stimulus and that of the next scene is 150ms instead of 100ms. Is this because 100ms is a very short interval or because it takes time to load the waveform?

snd1 = AudioSound(null_);
snd1.List = 'load_waveform({''sin'', 0.1, 4000})'; % 4-kHz sine wave for 100 milliseconds
scene3 = create_scene(snd1,[1 2]);

Thanks
Matty
Re: Auditory stimulus durations
January 08, 2024 11:40AM
Neither. NIMH ML has the waveform ready for immediate play, before the scene starts. However, there is still an internal delay in Windows audio architecture that cannot be avoided. My paper about this is in review. The actual delay is dependent on many factors, but, if you are using XAudio2, it is usually about 37 ms.
https://monkeylogic.nimh.nih.gov/docs_AudioEngine.html

AudioSound ends the scene after the entire waveform is played, so the duration of the scene becomes longer than 100 ms, as explained in your previous question. Assuming that the scene ended one frame later and the frame length is about 16 ms, it explains why your scene duration was 150 ms (= 37 + 100 + 16).
https://monkeylogic.nimh.nih.gov/board/read.php?3,1294,1294#msg-1294

You can shorten the internal delay to about 1 ms by using the WASAPI exclusive mode. That does not make the scene duration close to 100 ms though, for a different reason. If your concern is the length of the stimulus, you should record the sound output, not the scene duration. The sound duration is exactly 100 ms, regardless of the scene duration.

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.