Playing a sound during keypress in sequence
Hello,
This is my first thread in the forum. I am working on a time perception experiment. I want the subject group to be able to reproduce an alarm like sound pattern, consisting of 900 ms. long sound samples and intervals between them by pressing and releasing a key. Also i need to keep record of the keypress durations. I figured out that using an uninterrupted sound sample that is a little longer than the duration of the whole pattern and activating it only by pressing and holding a key can work. I have overviewed related threads, but since I don't have experience with python nor OS I couldn't find a way to implement my experiment. Any comment is appreciated.
Çağdaş
Comments
Hi,
Using a long sound sample is a good idea. I think you will need to make a while-loop in an inline_script run-phase that looks something like this:
Hope this helps.
Cheers,
Josh
Thank you very much for the quick reply. When I run the script it tells me your_sound item is not defined. I tried to wirte the name of ogg file in qutation marks, this time i get the error 'str' object has no attribute 'play'. How can I define the item to be played?
Hi Çağdaş,
Yes, the sound item is something you'll have to define yourself beforehand - typically in the prepare-phase of your inline_script. Have a look here: http://osdoc.cogsci.nl/python/sampler/
Beware that I just gave an example; it'll probably have to be tuned to your specific needs. In the current state, for example, one can only press the button once, and the loop will end upon release.
Cheers,
Josh