I am having an unexpected error when trying to play a sound component on builder… Can anyone help? Apologies in advance if this is something very basic… Following your suggested framework, to explain my problem;
OS: to run on Win7
PsychoPy version (e.g. 1.84.x): 1.90.1
Standard Standalone? (y/n) yes
What are you trying to achieve?: I am trying o play sounds (as sound component) at certain times within a routine in builder; added code component in the same routine to send a trigger coinciding with the onset of the sound.
What did you try to make it work?:
- the sounds were playing ok in another laptop (win10);
- i needed to change to this one (win7 laptop) because it is the one we use for testing;
- in this laptop I added the code to send the triggers in this laptop and also connected with serial port cable that links with EEG system… these were the changes i made in the experiment… however apparently the error is related with sound… (please see below)
What specifically went wrong when you tried that?:
I would be very grateful if anyone could provide some insight about what may be wrong…
Your experiment contains sounds that are at two different sample rates, which portaudio doesn’t support on windows. You might find that you can fix this by changing to a different audio ‘backend’ in the application settings (specifically it’s possible that pyo supports multiple sound formats) but the much better solution is to go through your sounds and convert them all into a single sample rate. Even on systems that support multiple rates the performance is likely to be reduced.
many thanks for your response! it sorted out the problem
I’m got the same error but according to Audacity all my WAV files are 44100Hz at 32 bit so it can’t be quite as simple as that.
Some of my files are not hard-wired into the sound component but are pulled in at runtime via a variable - $response_sound_file which get initialised as
prac_sound_feedback = sound.Sound('A', secs=1.0, stereo=True, hamming=True,
According to Google PTB defaults to 48K so I think the answer is to set all your audio files to 48K OR to load a hard-wired dummy sound component early on (eg in the first routine - play it for 0.1sec with volume = 0 - this will force PTB to use the sample rate of your file (if it’s different to 48K) and then the rest seems to work fine.
This is actually a matter of what Windows does depending on the priority setting you require. It should only default to 48k in low-latency non-exclusive mode. Try setting your latency mode to be either mode 0 (latency doesn’t matter but please be flexible) or mode 2 upwards (don’t share the audio card)