psychopy.org | Reference | Downloads | Github

Sound Issue when in loop

OS W7 64bit:
PsychoPy version : 3.1.3
Standard Standalone? Y
Other info: HP PC Elite Desk

Hi all,

[issue similar to HERE for which no solution was proposed]

Need to present sounds. Sounds are of the same format (i.e. .wav), bitrate and sample rate.

First sound plays till the end as it should. The rest are truncated at the end about 300-500ms. This happens only when in loop. If I play indivuidual sounds either within PsychoPy (i.e. one sound at a time by entrering their filename in the sound component) or via VLC they play fine.

No matter which sound, only the first sound plays till the end when in loop. The rest at truncated.

What I have tried and didn’t work:

  • I have tried different formats e.g. ogg.
  • I inserted an 1sec ISI after the sound to give it time to “load” the next sound.
  • I played with different combinations of audio library and audio drive in PsychoPy preferences
  • Inserted a “blank” sound at the end of each sound file to “extend” the duration of the sounds

I attach a mimimal example (actually just the sound component), samples of sounds and the excel file.

Any help will be much appreciated.

P.S. @jon Would it be possible to add .ogg files in the allowed file types for attachments in discourse?

conditionsCT.xlsx (8.2 KB) CT.psyexp (4.2 KB)
Sound1

Sound2

Sound3

Sound4

Right, I think I fixed this. So for anyone who encounters the same problem and lands on this post:

[In File --> Preferences–> Hardware] I thought that altering the order of the audio backend from the default

'sounddevice', 'pyo', 'pygame',
to
'pyo', 'sounddevice', 'pygame',

in the audio library will give pyo precedence over the other two backends but apparently not…at least not in my system. By deleting all the other backends and leaving only the pyo i.e. ['pyo'] in the audio library field fixed my problem.

P.S. please also check http://www.psychopy.org/api/sound.html for potential shortcomings of the pyo backend

1 Like

I’m puzzled that setting pyo as the preferred device didn’t work. That certainly should be what it does.

For info I’m currenlty working on a Psychtoolbox backend (using the same engine, which Mario Kleiner kindly ported to Python). That will have superior timing and will hoefully superceded all the above (but only on 64bit systems running Python3)

1 Like