Hi,
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
here.
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.ope nmixer()
self.names, self.controls, self.stereocont rols,
self.reccontrol s = [], [], [], []
clabels = ossaudiodev.con trol_labels
for label in clabels:
control = clabels.index(l abel)
if self._mixer.con trols() & (1 << control):
# channel is available
self.names.appe nd(label.strip( ))
self.controls.a ppend(control)
# now see if it's a stereo channel
if self._mixer.ste reocontrols() & (1 << control):
self.stereocont rols.append(con trol)
# finally see if it is an input device
if self._mixer.rec controls() & (1 << control):
self.reccontrol s.append(contro l)
This works, at least on my box, however the ossaudiodev.con trol_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
Michael
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
here.
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.ope nmixer()
self.names, self.controls, self.stereocont rols,
self.reccontrol s = [], [], [], []
clabels = ossaudiodev.con trol_labels
for label in clabels:
control = clabels.index(l abel)
if self._mixer.con trols() & (1 << control):
# channel is available
self.names.appe nd(label.strip( ))
self.controls.a ppend(control)
# now see if it's a stereo channel
if self._mixer.ste reocontrols() & (1 << control):
self.stereocont rols.append(con trol)
# finally see if it is an input device
if self._mixer.rec controls() & (1 << control):
self.reccontrol s.append(contro l)
This works, at least on my box, however the ossaudiodev.con trol_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
Michael