Change sampling rate for audio?

423 views
Skip to first unread message

Chris Holdgraf

unread,
Jun 21, 2013, 8:34:16 PM6/21/13
to psychop...@googlegroups.com
Hey all - I'm trying to play audio files that are sampled at 16KHz, but it seems that Psychopy is playing them at a faster rate than it should.  I can't seem to find a way to change the sampling rate in the builder, and I'm pretty new to this software so I'm unsure of how to do this with code.  Can anyone point me in the right direction?

Thanks!

Michael MacAskill

unread,
Jun 23, 2013, 9:39:51 PM6/23/13
to psychop...@googlegroups.com
Hi Chris,

This problem has arisen before. See <https://groups.google.com/forum/#!topic/psychopy-users/IX7EvWOnvJU>:

> The problem seems to be with the sample rate: your hello+world.wav clip is 16 000 Hz. After using Audacity to set it to 22050 Hz, it plays fine. So the sound library being used by PsychoPy doesn't deal well with that sample rate. The default rate is 44100 Hz but when I tried to set the optional parameter to 16 000 Hz, no sound played at all.
>
> I'll have to hand over to the sound library experts on this one, but it seems that you might be able to work around the problem in the interim by using Audacity or an equivalent program to change the sample rate of your files to, say, 22050 Hz.

But also PsychoPy now has the option to use an alternative underlying sound library, which may deal with your sound files better. So before editing the files, check PsychoPys settings and switch the order of the audio lib field from:

[u'pygame', u'pyo']

to:

[ u'pyo', u'pygame']

band see if that makes a difference.

Regards,

Michael

Chris Holdgraf

unread,
Jul 4, 2013, 3:11:33 PM7/4/13
to psychop...@googlegroups.com
Thanks for the information!  It seems that changing the audio libraries is possible with an older version of psychopy, but this option is removed on the latest release.  Is this true for you as well?

Michael MacAskill

unread,
Jul 4, 2013, 5:11:39 PM7/4/13
to psychop...@googlegroups.com

On 5 Jul, 2013, at 07:11, Chris Holdgraf <chol...@gmail.com> wrote:

> Thanks for the information! It seems that changing the audio libraries is possible with an older version of psychopy, but this option is removed on the latest release. Is this true for you as well?

That option is still there for me in the latest public release (version 1.77.00 for OS X)…

PsychoPy menu -> Preferences -> General -> audioLib

Mike

Chris Holdgraf

unread,
Sep 17, 2013, 3:40:10 PM9/17/13
to psychop...@googlegroups.com
Whoops - upon further inspection I realized that the 'pyo' library fixes the sampling rate problem, but now audio only plays out of one speaker.  Is there a way to either fix the single-speaker problem in 'pyo', or the sampling rate problem in 'pygame'?

Gary Lupyan

unread,
Oct 15, 2013, 12:45:45 AM10/15/13
to psychop...@googlegroups.com
Hi Chris, as a temporary fix, you can convert the sounds you are
trying to play to stereo by duplicating the channel. They will then
play from both speakers.

-----------------------------------------------------
Gary Lupyan - lup...@wisc.edu
Assistant Professor of Psychology
University of Wisconsin, Madison
http://sapir.psych.wisc.edu
-----------------------------------------------------
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/psychopy-users/1fca637a-2c7c-4640-8257-39d70201c44b%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages