Effacer les filtres
Effacer les filtres

sound delivered at randome interval

1 vue (au cours des 30 derniers jours)
Salvatore Lacava
Salvatore Lacava le 4 Juin 2018
Commenté : Walter Roberson le 5 Juin 2018
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)?

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Juin 2018
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.
  2 commentaires
Salvatore Lacava
Salvatore Lacava le 5 Juin 2018
Thanks for your answer! Can you please give me an example on how to deliver sounds at random intervals using PsychToolbox?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by