[Tutor] accessing the mixer

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Nov 19 18:41:31 EST 2003



On Tue, 18 Nov 2003, Larry wrote:

> I am trying to access the mixer in order to build a simple volume
> control, for now.  (:
>
> Anyway I have found very little on google about doing anything at all
> with the mixer, though I have found ossaudiodev in the 'python library
> reference', so I'm trying to work from that.
>
> But now I find that my library reference in /usr/doc/python/html has no
> ossaudiodev listing in it.

Hi Larry,


Hmmm... That's odd.  Here's a link to the official documenation on the
'ossaudiodev' module:

    http://www.python.org/doc/lib/module-ossaudiodev.html

but it only works for Unix systems.  I wonder why it's missing from your
local documentation?



If you're on a system that supports the ossaudiodev module, then the
following example might work:

###
import ossaudiodev
mixer = ossaudiodev.openmixer()
mixer.set(ossaudiodev.SOUND_MIXER_VOLUME, (50, 50))
###

This should set the left and right channels of the master volume to 50%
loudness.



But that example probably won't work on Windows.  I'm not exactly sure if
there's a nice platform-independent way to access the global volume
control; does anyone else know about it?

The 'pygame' module does provide a mixer so that you can control the
volume of your own application:

    http://pygame.org/
    http://pygame.org/docs/ref/pygame_mixer.html
    http://pygame.org/docs/ref/pygame_mixer_music.html

so perhaps you might be able to do something with it.



Good luck to you!




More information about the Tutor mailing list