oss mixer usage

klappnase at web.de klappnase at web.de
Sun Jan 15 19:45:05 EST 2006


I am trying to write a mixer program using the ossaudiodev module.
I could hardly find any documentation or example code, so I try and ask
There are two things that seem to work already, however I am not sure
if the solutions I found are the way it is supposed to be.

First, when on initialization of my MixerController class I query the
properties of the mixer device in use, I tried the following:

        self._mixer = ossaudiodev.openmixer()
        self.names, self.controls, self.stereocontrols,
self.reccontrols = [], [], [], []
        clabels = ossaudiodev.control_labels
        for label in clabels:
            control = clabels.index(label)
            if self._mixer.controls() & (1 << control):
                # channel is available
                # now see if it's a stereo channel
                if self._mixer.stereocontrols() & (1 << control):
                # finally see if it is an input device
                if self._mixer.reccontrols()  & (1 << control):

This works, at least on my box, however the ossaudiodev.control_label
attribute is not mentioned in the library reference, so I am  not sure
if this is the "canonical" way  that will always work.

Second, when I want to change the currently used recording source, I am
not sure if I have to  provide different code for sound cards that
support multiple active recording source channels and sound cards that
support only one active recording source channel; the code I wrote
works with my card (which allows multiple channels being active), but I
don't have a card that supports only one active recording channel at
hand so I cannot test if the same code will work.
Finally, if it *is* neccessary to provide different code, how can I
find out which type of card is currently in use?

Any pointers are much appreciated.

Thanks in advance


More information about the Python-list mailing list