OS (Windows 10):
PsychoPy version (2022.2.4):
What are you trying to achieve?:
I’m trying to create an initial segment for an experiment where participants adjust the volume of the sound files, then their adjusted values are carried forwards for future trials where these sound files are used. I can get the adjustments to work, but I’m struggling to get the volume level to carry forward.
What did you try to make it work?:
I have a routine where a sound file plays, and the volume can be adjusted up and down with buttons. I have a variable ‘fivehundredVol’ initially set (Before Experiment) to 0.6. The buttons end the routine and adjust the value of fivehundredVol up or down by +/- 0.01 with each routine. I use the following code component to do this:
maxVol = 1
minVol = 0
stepSize = 0.01
if mouse.clicked_name[0]=='VolUp1':
if fivehundredVol + stepSize >= maxVol:
fivehundredVol = maxVol
else:
fivehundredVol += stepSize
elif mouse.clicked_name[0]=='VolDown1':
if fivehundredVol - stepSize <= minVol:
fivehundredVol = minVol
else:
fivehundredVol -= stepSize
elif mouse.clicked_name[0]=='Back1':
VolRepeats.finished = True # end this loop
elif mouse.clicked_name[0]=='Next2':
FiveHundredAdjust.finished = True # end this loop
VolRepeats.finished = True
This code is in the ‘Begin Routine’ window. ‘VolUp1’ and ‘VolDown1’ refer to the button components, and VolRepeats is the name of the loop (set to N=9999 to allow many adjustments). Participants then click ‘Next2’ to end the loop.
What I then want to do is carry forward the value that participants set ‘fivehundredVol’ to. So next I have a routine where a sound file plays, and I have the volume of my sound component as a variable called ‘CustomVol’. ‘CustomVol’ is initially set (Before Experiment) to an arbitrary value of 0.2, and I then try to set the value of ‘CustomVol’ as equivalent to fivehundredVol with a code component:
if SoundFilePoint == 'FiveHundred'
CustomVol = fivehundredVol
This code is in the ‘Begin Routine’ window. Here ‘SoundFilePoint’ is a column within my conditions file, and the first row contains the text ‘FiveHundred’.
What specifically went wrong when you tried that?:
The variable ‘CustomVol’ is not being set as equivalent to ‘fivehundredVol’. I have a text component on the second routine with ‘$CustomVol’ on screen, and the value it shows is 0.2 which suggests the second code component I’ve mentioned does not work. Any help with a better way to do this would be much appreciated!
PerceptualMatching.psyexp (40.3 KB)
ProcedureCalib.xlsx (8.3 KB)