OS : Windows 10
PsychoPy version (e.g. 1.84.x): 2024.1.4
What I am trying to achieve?: I want my experiment to play a scream or a neutral sound 70% of the time for the fear and neutral condition. I build this in mac and it worked no problem.
Now I’m trying to run it on windows (what I will use to run this experiment) and have exhausted all possible troubleshooting steps I could think of or have seen online. The audio does not play. When I set the audio to play 100% of the time at volume =1, there is no audio.
In my excel file under sound I have the filenames:
neg_sound.aiff
pos_sound.aiff
This code works perfectly on Mac:
current_trial = trials.getCurrentTrial()
# Set the sound file based on the current trial
sound_file = current_trial['sound']
dynamicSound.setSound(sound)
# Determine the volume
if random.random() < 0.7:
volume = 1
else:
volume = 0
# Set the volume for the sound component
dynamicSound.setVolume(volume)
However even just inserting audio directly (not in the excel file, and without code components) into the experiment does not work on windows. So the problem is not the code, but something else.
What did you try to make it work?:
I followed all the suggestions from this similar post.
In addition I tried every troubleshooting step I could think of:
-
Made sure the sampling rate is 44100 hz
-
Checked the path of the audio files
-
Tried putting audio files in separate folder (then psychopy could not find the path so I put them back in the main experiment folder)
-
Checked that the volume on the computers is set up, headphones work, checked the actual audio files - they play just fine through headphones on the computer, just not on psychopy.
-
Tried converting the audio from aiff file to wav files (made no difference so I went back to aiff files).
-
Checked the psychopy device output is set to the headphones (it is). Specifically “Speakers/Headphones (Realtek Audio)”
-
Tried every audio library (only ptb and pyo run the experiment, sounddevice and pygame throw error message and will not let the experiment run) and for each library tried every latency from 0 to 4.
-
installed sounddevice and audio play back support pyo plug ins
-
added coreaudio, portaudio and sounddevice as audio drivers
-
removed “force stereo” from global audio settings (this created errors) and then added it back
-
deleted these AudioDrivers (no change so I added them back): Primary Sound, ASIO, Audigy
-
cleared the psychopy cache folder
-
Finally: I checked if it’s a problem with the 2024 version of psychopy. I tried to create a small test with the 2021 version pf psychopy to see if it would play the audio and it played the same audio files no problem.
My entire experiment as of now is built in the 2024 version. Is there a quick way to convert/ rebuild my experiment for the 2021 version? Is this a glitch with the 2024 version or is there some solution I can implement to get the audio files to play?
What specifically went wrong: There is no error message. The audio just will not play.
The experiment runs, it simply runs with no audio. The same exact experiment runs exactly as I want it to run on Mac. Also if I use the 2021 version on windows 10 it seems that version can play audio - but it won’t run my entire experiment (it gives an error message saying this experiment is built in a future version of psychopy).
On my mac all I have is coreaudio and portaudio, and the library is ptb (latency = 3). It works no problem and I didn’t need to install any plugins. However the experiment can only be run on our lab computers which are Windows 10. I really need a solution.
I am at a loss for what to do. I’ve looked throgh every psychopy forum post on this issue - and no solution seems to work. Is the only solution to rebuild the entire experiment using an older version of psychopy?