Problem with the offset of a sound component

Hi @Dawid_Czech, there appears to be a bug in the Sound code that attempts to convert a ‘None’ string to float when no duration is provided. This is why you are seeing the ValueError. I will put this as an issue in the repository on Github, but you can make the following additions to the psychopy code to fix this error. In “psychopy\experiment\components\sound_init_.py” replace line 65 with:

if inits['stopVal'].val in ['', None, 'None']:
    inits['stopVal'].val = -1
elif float(inits['stopVal'].val) > 2:
    inits['stopVal'].val = -1

and line 85 and 86 (which were lines 83 and 84 prior to above change) with:

if not self.params['stopVal'].val in ['', None, -1, 'None']:
    if not float(self.params['stopVal'].val) < 2: # Reduce spectral splatter but not stopping short sounds

If you do this, you will no longer have the error. However your sound duration will be -1, and so you will not hear a sound unless you change the duration, but this can only be done when you instantiate the sound object.

The problem is, however, that when I set the same fixed duration time for all of the files I’m unable to reliably measure response time, since the onset of the key response component is set to trigger after the sound file has been played (I want to measure how quickly the participants press a key after they’ve heard the sound).

This should not be a problem. In Builder you can set your keyboard response to start at the onset of the sound, so your RTs will be relative to the sound onset. Would that be better?

2 Likes