psychopy.org | Reference | Downloads | Github

Feedback Sound for Incorect Responses

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 3.0.0b10
Standard Standalone? (y/n) If not then what?: honestly don’t know

What are you trying to achieve?:
For my trials, when a participant responds incorrectly or not fast enough, then a low toned beep should play.

What did you try to make it work?:
I have a sound component that plays at the end of a trial (i.e., when a participant is too slow with response therefore “force end of routine” is not activated), but have not been successful at having it beep when the participant is incorrect. The current code component I have is:

if resp.corr:

else
toneF = 330

This is set at the beginning of routine
What specifically went wrong when you tried that?:
When I try to run, it gives me the error: “Indentation error: expected an indented block”

Hi @ERocks, you have an indentation error in your Python code (see Python docs). To fix:

if resp.corr:
    #do something
else:
    toneF = 330

Hi @dvbridges, thank you for the help. Now the error is saying “resp.corr” is invalid syntax. Not sure how to proceed from here

Would ypu mind pasting the whole error msg and the code you are using?

@dvbridges Here are screenshots of the error message and code. Please note I changed the code to reflect a possible solution from the following post, but continue to get the same error:
https://groups.google.com/forum/m/#!topic/psychopy-users/GTV6d9U-NmM

Ah I see, the keyboard attribute which stores the response accuracy is corr. So, you want:

if key_train1.corr:
    # etc

Ah, thank you! I am no longer getting error messages now, however it is not doing what I want it to (i.e., beep volume = 0 when resp is correct; it is beeping for all responses)

Great. To set your volume, you will want to use one of the sound component methods. The setVolume method can be used to set the volume of your sound object. Try this:

if key_train1.corr == 1:
    low_beep_incorrect.setVolume(0)
# etc ...

@dvbridges Thank you for all your help. Unfortunately it is still beeping with every response, not just with incorrect responses. Here is the code I have set up, as well as the key_train1 and low_beep_incorrect properties in case something is wrong in there:


This may be a ordering issue. Your code component is setting the volume on every routine, and so is your sound component. However, the sound component comes after the code component, so the volume is reset to 1 on every routine regardless of what your code component is doing. Try moving the code component below the sound component in your routine.

@dvbridges Thank you for all your help! It did turn out to be a timing issue, both with where the code component was and that the actual code needed to be under “Each Frame” as opposed to “Begin Routine” in the code component. The beeps now only play with incorrect responses!