Strange error message for sound.Sound.Pygame()

63 views
Skip to first unread message

Marc Buehner

unread,
Oct 9, 2013, 9:09:38 AM10/9/13
to psychop...@googlegroups.com
Hello,

I am looking through some code from a student and the program line

tone = sound.SoundPygame(value='C', secs = 0.1, octave=5, sampleRate=44100, bits=16)

gives the following error message

########## Running: /Volumes/EURESIS/Experiment 2/Exp2 - BareBones.py ##########
Traceback (most recent call last):
  File "/Volumes/EURESIS/Experiment 2/Exp2 - BareBones.py", line 155, in <module>
    tone = sound.SoundPygame()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/sound.py", line 255, in __init__
    if not mixer.get_init():
NameError: global name 'mixer' is not defined

If the tone is defined with paramaters such as

tone2 = sound.SoundPygame(value="E", secs = 0.1, octave=4, sampleRate=44100, bits=16)

I get the same problem.
And I also get the same problem when I run that code from the shell.



I don't understand what to do with that.

Different code that defines sounds from a waveform array works fine, though.

Does anyone have any pointers?
Thanks,
marc

Jeremy Gray

unread,
Oct 9, 2013, 9:27:54 AM10/9/13
to psychop...@googlegroups.com
Hi Marc,

In general unless you have a good reason, just do:
    tone =  sound.Sound(...)
and not
    tone =  sound.SoundPygame(...)
The first way will automatically do the right thing, which means: will initialize and use SoundPygame or SoundPyo depends on your audioLib preferences.

I am guessing that the student either does not have pygame installed, or has audioLib pref set to pyo but is then trying to use SoundPygame() directly, but it has not been initialized / imported.

Suggested things to try: 1) make sure prefs have u'pyo' earlier in the list (ahead of u'pygame'), and 2) use sound.Sound()

--Jeremy


--
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/915d23ab-42ec-4086-afc0-82cdf7484fb3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Marc Bühner

unread,
Oct 9, 2013, 9:36:13 AM10/9/13
to psychop...@googlegroups.com
Hi Jeremy,

thank you for the quick and simple response.
Indeed, changing to sound.Sound(...) solved the problem.

Thanks very much,
Marc
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/aHVuAs3jXmM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.

To post to this group, send email to psychop...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages