Random loud crackling noise with sound stimuli

I’m experiencing a loud crackling and distorted sound presentation in my study stimuli. It only happens half the time–the other half of the time, the sound is perfect. My sound files are all .wav and super tiny in size.

Example code is below, and I’m running Mac OS 10.15.4 on a new Macbook Pro and Psychpy 2020.1.2.

for frameN in range(360):
        if frameN == 0:
            nextFlip = win.getFutureFlipTime(clock='ptb') 
            emotion_voice_object.play(when=nextFlip) 
            emotion_face_object.draw()
        elif 1 <= frameN <= 41:
            emotion_face_object.draw()
        elif 42 <= frameN <= 71:
            neutral_face_object.draw()
        elif 72 <= frameN <= 113:
            emotion_face_object.draw()
        elif 114 <= frameN <= 143:
            neutral_face_object.draw()
        elif 144 <= frameN <= 185:
            if frameN == 180: # 3000ms after onset of face-voice pair
                nextFlip = win.getFutureFlipTime(clock='ptb')
                startle_probe_object.play(when=nextFlip)
            emotion_face_object.draw()
        elif 186 <= frameN <= 215:
            neutral_face_object.draw()
        elif 216 <= frameN <= 257:
            emotion_face_object.draw()
        elif 258 <= frameN <= 287: 
            neutral_face_object.draw()
        elif 288 <= frameN <= 329:
            emotion_face_object.draw()
        elif 330 <= frameN:
            neutral_face_object.draw()
        win.flip()

Thanks in advance for any guidance!

2 Likes

I am no expert on this topic, but what you’re doing in this loop could still be resource intensive, even if your wav file is small. Are your emotion_face_object images large? Did you try whether you get the same effect on a PC with a better graphics card and/or better sound card?

What is the length of your sound? Could there be overlap between the emotion_voice_object and the startle_probe_object at some point?

As I say, I’m no expert - these things could play no role whatsoever.

Thanks LukasPsy for your suggestions! The emotion_face_object images are about 350 kb, so I don’t think their size should be an issue.

Yes, there is overlap between the emotion_voice_object and the startle_probe_object. The idea is that, while the emotion_voice_object is playing for 6000ms, the startle_probe_object is briefly presented for 50ms.

Is it a problem if sound files overlap in Psychopy?

I don’t know, but maybe you could test just that? Make it so that the audio presentations don’t overlap and try to reproduce your crackling sound.

Maybe someone else who reads this knows more about ptb? :thinking:

I hear swift crackling sound and poping sound when audio file terminated by response locally on my mac. doesn’t have issue this when running online tho.

i just heard the same kind of crackling playing sound with praat… at least in my case, it seems to be a problem with my mac not psychopy