Borrar filtros
Borrar filtros

How can I play a movie and a set of sounds AT THE SAME TIME?

5 visualizaciones (últimos 30 días)
Hello,
I am trying to code the following cognitive task: 4 tones (300ms duration) played 100 times each, in random order, WHILE playing a movie. For the tones, everything works fine: I created a loop that, for each trial, picks randomly a tone and an intentrial interval, and plays it with the 'soundsc' function. I want now to add a silent movie so the participant can be watching it while listening to the sounds but I don't know how to do it.
I tried to do it using Psychtoolbox and the video demos they provide. However, I only manage to play the movie and, ONCE THE MOVIE ENDS, keep running the code and so, play the sounds. I also tried to generate an array with the 400 together, and then play it using 'soundsc'. Once the sounds are playing, I can play the movie so the two stimuli run in parallel. However, I am afraid that by doing this I won't be able to send a marker to the EEG recording for every trial (i.e. tone).
Any idea would be highly appreciate!
Laura

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Dic. de 2020
You appear to be doing a psychophysical experiment.
Unless you use Psychtoolbox, you are unlikely to be able to do what you want to the precision that is normally required for those kinds of tasks.
I see what you said about Psychtoolbox, and it looks to me as if you did not use the right parts of it. For example you would not use a Mathworks video player for it: you would queue a number of frames and use the screen swap facilities that the toolbox offers.
But to answer your question within MATLAB:
You can use audioplayer, and configure the TimerFcn callback in it. Each time the callback fires, set the CData property of an image() object to the content of the next video frame.
There are also approaches using videoplayer and using audio system toolbox audio output facilities and system objects.
  1 comentario
Laura Colomar
Laura Colomar el 13 de Dic. de 2020
Thank you very much, Walter. I finally managed to do it using Psychtoolbox, queuing, and using the screen swap facilities, as you suggested.
In case anyone is in the same situation and needs more details, this is the schema I followed:
Start the movie
If X
play sound 1
while sound1_duration
keep showing new frames
If Y
play sound 2
while sound2_duration
keep showing new frames

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by