Hey everyone,
I’m new to PsychoPy and try to program an experiment that needs to run online, too.
I’ve done most of the experiment in the builder already, but cannot find a solution for a task in the beginning:
The volume of a presented sound should be individually adjusted in a way that it is aversive but not painful. Therefore, I’ve planned the following:
- Play a sound at a low volume (e.g. 0.3)
- Ask the participant something like “Press right arrow, if the volume of the noise is aversive; press left if it is not aversive yet”
- After key press “left”, increase the volume by 0.1
- Start over with increased volume
As soon as the participants press the “right” key (i.e., noise is aversive) I need to save the noise with that specific volume to use it later in the experiment.
This is what I’ve tried so far:
The first Routine (PlaySound_Code) comprises a code component:
WN = sound.Sound('WhiteNoise1000-16Bit.wav')
Vol = 0.8
increase = 0.1
in the “Begin Experiment” tab;
WN.setVolume(Vol)
WN.play()
in the “Begin Routine" tab;
The feedback Routine includes (1) a text component, asking the participants to press left or right key; (2) a key response component with left and right as allowed keys; (3) another code component (at the top of the Routine) saying:
if Key_press.keys == "left":
Vol = Vol + increase
elif Key_press.keys == "right":
Vol = Vol – increase
In the “Begin Routine” Tab.
I used the “Vol = Vol-increase” line as a control to see what it does. The weird thing is that after a key press the volume is stepwise reduced, but never increased and I really don’t know why…
I was also thinking to add the volume increases as a condition to an Excel file and play it in a loop, but I couldn’t come up with a final solution.
I really would appreciate any help with this, because I couldn’t really find anything similar, expect one explanation of @Becca, were she added the “if-condition” in the “End Routine” tab of the first component, but this doesn’t do anything to the volume at all. (Generating Sound)
Thank you for any advice!
Elena