OS (e.g. Win10): Mac PsychoPy version (e.g. 1.84.x): 3.2.4 Standard Standalone? (y/n) If not then what?: y
I would like a particular sound (a wave file) to start playing at 1.0 second on every trial of my experiment. This is what the sound component looks like currently:
The trials run through the visual stimuli with no problems coming up in the shell. However, the sound plays only on some trials - for the majority of the trials, the sound simply doesn’t play at all. Each trial is longer than 1 second, so that should not be the issue.
Thanks for this suggestion. I tried changing it to PTB, and the sound did not sound how it’s supposed to (super static-y). I’m wondering if there’s a better way to go about using sound in my experiment. It requires precise timing of this sound, so from what I’ve read online, PTB should be ideal to use, but it seems that I would need to add a code component to use it properly. However, translating that code into Javascript will become an issue. Any suggestions/insight?
Apologies, I’m very much a novice at coding. So you can’t create a basic sound component using Python code (because PTB would be able to work well with that I assume)? Then maybe you could try defining the onset and duration of your sound in terms of frames (this would be a start frame of 60 if you have a 60 Hz monitor)? I honestly have very little idea I’m afraid.
You’re wanting a sound that will play for only 50 ms. If there is any latency in starting it, it might get stopped before it is has actually started to play. Bear in mind that the code to check on things like onset and offset of stimuli runs only once per screen refresh, which is once every 16.666 ms on a 60 Hz screen. So controlling such a short duration of audio in software can get tricky. Although the ptb sound library has improved things markedly, we don’t get the kind of hardware feedback that we do for visual stimuli to be as confident of timing.
So since the sound file is a constant, can’t you just edit it in something like Audacity to make it exactly 50 ms in duration? Then the only source of variability left is the onset of the sound.
Thanks Michael and Don. I have now edited the sound to be 50ms and put this new sound into the exact same spots the other sound was. Now, however, Psychopy won’t even run my program - after the initial dialogue box, it crashes. When I use the old sound file, it runs. What could be going on? They are both .wav files. There is no error message.
HI, I know this is a bit of an old threat. I am having the same issue. PsychoPy ensures that the PTB library is the best when it comes to latency. However, every time I try to use the PTB library my 50ms tone won’t play in some of the trials. In my opinion, simply setting the audio library to ‘sounddevice’ is not a solution. Doing so, you are actually not relying on the PTB library and are exposed to higher latencies.
Hi! I am having the very same problem. Using PTB or Sounddevice did not solve the problem. Neither did setting the frames instead of the timing. The program does not play some sound stimuli just randomly. Does anyone have any other suggestions? Btw, I am using PsychoPy 2023.2.2, which is the latest version on the website.
Hello !
Hi! I am having the very same problem, some audio files are not playing randomly during trials, and I don’t know what’s the issue , I was trying PsychoPy 2023, and now im trying PsychoPy 2024.1.4, but still the same issue , I tried to change to PTB and sound device but it didn’t work, so any suggestions please
hi @Emma_Portugal
I tried several suggested solutions mentioned, but none of them worked for me . The only thing that worked was separating the audio. For example, in a given routine, I wanted a sound to play at the beginning and another sound to play from seconds 15 to 20. So, I created another routine with this sound and created a loop. This way, I didn’t have any issues.
Thanks for your reply. This did not work for me, but I was finally able to resolve the problem by “prescheduling” the sounds using a code component (rather than sound components).