InDashPC.org Forum Index InDashPC.org
In Dash Car PC forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Mixer controls HOW-TO

 
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software -> PyMedia Tutorials
View previous topic :: View next topic  
Author Message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Mon May 29, 2006 5:34 pm    Post subject: Mixer controls HOW-TO Reply with quote

Pymedia come along with the MIxer control which is not documented enough as many people say.
So here is the simple tutorial.
1. Create a Mixer object
Code:
import pymedia.audio.sound as sound
mixer= sound.Mixer()

2. Get list of all playback mixer controls ( or lines ):
Code:
print [ x[ 'connection' ]+ ' - '+ x[ 'name' ] for x in filter( lambda x: x[ 'destination' ]== 'Volume Control', mixer.getControls() ) ]

Payback controls are controls that have impact during playback. Some examples are: Master Volume, PCM, Phone Jack
3. Get list of all recording mixer controls ( or lines ):
Code:
print [ x[ 'connection' ]+ ' - '+ x[ 'name' ] for x in filter( lambda x: x[ 'destination' ]== 'Recording Control', mixer.getControls() ) ]

Recording controls can be: Line in, Microphone, CD In etc.
Now you know that getControls() returns list of dictionary items. Every item has the following members:
active - whether control is active ( selected )
control - mixer control object
connection - connection of the control. Means physical lixer line which got control
destination - controls destination or direction ( playback or recording )
name - name of the control. Combined with connection makes a unique control name

Control object has the following methods:
getValue - gets the value of the control. In case of mutliple channels it will return tuple with the appropriate values for every channel
setValue - sets value for the control. If all channels have to be the same only 1 value is needed, for different values per channel, supply the tuple.
setActive - set the control in active/insative state. Doing it on recording will allow to choose which control will be receiving the input data ( microphone, line in, cd in etc )
channels - number of channels the control supports.
Back to top
View user's profile Send private message
elvelind



Joined: 10 Jul 2006
Posts: 2

PostPosted: Mon Jul 10, 2006 8:49 am    Post subject: Reply with quote

I've just tested running this on my linux box.
But for some reason it segfaults. Any ideas?
Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Mon Jul 10, 2006 8:58 am    Post subject: Reply with quote

Are you using alsa ?
Back to top
View user's profile Send private message
elvelind



Joined: 10 Jul 2006
Posts: 2

PostPosted: Mon Jul 10, 2006 9:27 am    Post subject: Reply with quote

yes. Is alsa broken?
Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Mon Jul 10, 2006 12:57 pm    Post subject: Reply with quote

Can you post the script your using and what pymedia says.
There are several requests saying about broken alsa.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software -> PyMedia Tutorials All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group