In ResPyre project context, Regis Prevot wrote a python binding for ALSA. Because I believe his work could be usefull for other developpers, here is a first version of alsamodule.

This first version supports ALSA mixer. You can get, change, mute, unmute volume on audio channels. Here is a little example:

>>> import alsa
>>> mixer = alsa.mixer("default")
>>> mixer.printInfo()
            **********************
Card Id:                        default
Mixer Card Name:                Intel 82801DB-ICH4
Mixer Device Name:              SigmaTel STAC9750/51,0x42434d64 BCM
Max Volume:                     -1
Min Volume:                     -1
Incremental value min:          -1.00
Number of Elements:             22
            **********************
>>> print mixer.channels.keys()
['Capture', 'Mic', 'Mono Output Select', 'Mix',
 'Master', 'PCM', 'Aux', 'External Amplifier',
 '3D Control - Switch', 'Phone', 'PC Speaker',
 'Line', 'Mic Select', 'CD', '3D Control - Depth',
 'Master Mono', 'Mix Mono', 'Mic Boost (+20dB)',
 'Headphone', 'Video', '3D Control - Center',
 'PCM Out Path & Mute']
>>> print "get volume for device PCM"
get volume for device PCM
>>> print mixer.getVolume("PCM")
(45, 45)
>>> print mixer.setVolume("PCM", 3, 3)
(48, 48)

The binding is written in C, and has been tested under Linux. A setup.py file should come shortly. Until then use the Makefile to build the thing.

Any feedback is welcome.


Comments

comments powered by Disqus