sound delivered at randome interval
1 次查看(过去 30 天)
显示 更早的评论
Hi I would like to deliver a sound after a pause of 10-20 seconds. This is the code for the sound I created in matlab:
amp=100
fs=20500 % sampling frequency
duration=0.04
freq=16000
values=0:1/fs:duration;
startle_sound=amp*sin(2*pi* freq*values)
sound(startle_sound)
Is it possible to do it without using a specific toolbox (like PsychToolBox)?
0 个评论
采纳的回答
Walter Roberson
2018-6-4
You can always pause() before doing the sound(), or set up a timer. If you only have a few different sounds you can create audioplayer objects for each of them, and play() the appropriate object when it comes time.
However, you mention PsychToolbox, and tagged with "Neuroscience". That hints that you might want to have fine-grained control over exactly when the sound starts being audible, and that you might want to be wanting to measure reaction time.
For fine-grained control over exactly when sound starts becoming audible, you would probably be better to use the Audio System Toolbox to stream audio, instead of using the variable-time java-based sound() and audioplayer(). Audio System Toolbox can use PortAudio drivers to deliver sounds with low latency. I am not sure you can reliably get better than 10 ms latency though.
Recording response time accurately is not easy without dedicated hardware.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!