[solved] How to use a sound sample during a reaction time task
Hi everybody,
We have just made a reaction time task but we want to add a sound sample to the task. Our experiment looks as followed:
We want the sound to start at "experimentloop_1" and it must continu troughout the experiment. We're not sure how to do this because we've added several loops. The reason for adding all those loops is that we have added breaks to the experiment but we want the sound sample to continu during the breaks and also during the task.
Our sound sample is a .wav format and the duration is 6 minutes, our experiment lasts for about 20 minutes and the sample must sound fluently troughout the experiment..
Please help
For the Dutch moderators:
Hoi,
Wij hebben een reactietijd taak gemaakt en zouden hier graag een geluidsbestand (.wav, 6 minuten) aan toe willen voegen. Zoals je in het plaatje kan zien, is er voorafgaand aan het echte experiment nog een vragenlijst, oefenblok, baseline meting etc. Wij willen dat het geluid pas vanaf "experimentloop_1" begint te spelen en dat hij pas aan het eind van het experiment uit gaat. Omdat een reactietijd taak van 20 minuten nogal lang is voor een participant hebben we pauzes ingelast van ongeveer 3 minuten, maar we willen dat het geluid ook tijdens de pauzes te horen is. Voor de pauzes en reactietijdtaken hebben we verschillende loops aangemaakt dus we weten niet zo goed of we in iedere loop een geluidsbestand moeten zetten of niet, want het geluid moet wel onafgebroken te horen zijn. Hopelijk is dit verhaal een beetje duidelijk en kan iemand ons helpen
Comments
Hi guys,
The solution is actually very simple, if you employ a bit of inline scripting. Add the following code to the Run phase of an
inline_script
item directly before "experimentloop1".EDIT 24 March 2014, 17:19 GMT: corrected a silly mistake in the code.
If you want the sound to pause at some point, insert the following code into an
inline_script
item at the point where you want it to pause:And add the following to an
inline_script
item at the point where you want the sound to resume playing after a pause:If you want the sound to stop completely, insert the following code into an
inline_script
item at the point where you want it to stop:As a general note: make sure that your sound is either in WAVE (.wav) or OGG (.ogg) format. If you have a different format, you can convert the sound to either WAVE or OGG via a converter (you can search for one online, there are tons).
Good luck!
Hi Edwin,
I've entered the code in the Run phase of the inline script. However, I get this error:
Error: Inline script error
In: inline_script (run phase)
Line: 7
Python traceback:
AttributeError: 'module' object has no attribute 'get_init'
Full traceback in debug window
I have no idea what I'm doing wrong. I've literally copied and pasted your code, ive also added the file to the filepool and inserted the file name in your code. Help
Btw, this is the code as it is in our experiment right now:
Hi guys,
Terribly sorry, that's my mistake! The code below should work:
Simply forgot to add the
.mixer
in the initialization bit. I've updated my previous post as well, for future reference.Good luck!
Hi Edwin,
IT WORKS! Thank you so much!
No problem, glad that it works! Marking this as solved.