Audio with reduced sampling rate could not play

Hi everyone,

I wanted to include audio files with different sampling rates into PsychoPy, but those that with reduced sampling rates were played a lot faster than they should be. Playback speed is very important in our project. I wondered if anyone has encountered a similar situation before and it there is any way we could get around this?

Thank you so much!

Hi There,

Yes, in general all audio files should have a the same sampling rate otherwise an error occurs (do you get an error or just odd sounding playback?) can you change the speed but ensure sampling rates are matched across files on the export?


Hi Becca!

Thank you so much for the prompt reply! I really appreciate it.

I did not receive any error message. There was just odd audio playback (so distorted that I could barely recognize the audio).

Since sampling rate is really what we are manipulating here, I wondered if there is any way we could make them compatible with PsychoPy? (e.g. changing the audio file type)

Thank you,

Just to kindly follow up, we would like to present audios of different sampling rates in an interleaved and pseudorandom fashion within the same block if possible

I wonder how you altered the sampling rate of your files when they suddenly sped up. Did you resample them using something like Audacity/ffmpeg or did you just ask them to play at a different speed?

Also, could I ask why you want different sampling rates? Depending on the platform you’re using, and the quality of timing you require, it’s either “necessary” or “a really good idea” to use the same rate throughout your study.

Hi Jon!

We used -ffmpeg to alter the sampling rates.

We hope to randomly present the subjects with audio of different sampling rates, or different “auditory resolution,” to see their responses. We will present either original audio file or the version with 20% reduced sampling rates.

The sampling rate of the audio is the major parameter that we are manipulating here.

Thank you for your help!

OK, the solution you need is to leave the actual sampling rate at the highest one you need and change the values within the sounds to have the apparent sampling rate of the lower options.
If you want a 22050 Hz sound as well as 44100 sounds then you need to take every sample in your 22050 sound and dupicate it. That will have the same effect as altering the sampling frequency. You could do that

  1. using a python or matlab script to create the new array
  2. use ffmpg to down-sample to 22050 to have the effect you want on degrading the information, and then upsample back to 44100 so it will play in the same stream

The second option might be easier for you if you’re alreayd familiar with ffmpeg but the 1st option has the advantage that you’re in complete control of the resampling method - when upsampling I thin you want to duplicate the samples once to get the exact same thing as a lower sampling rate, but ffmpeg might interpolate (smooth) instead. I can’t tell you exactly what it does

Thank you so much!!

I really appreciate your help!