Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="prev" href="ossaudio-device-objects.html" /> | |
13 | <link rel="parent" href="module-ossaudiodev.html" /> | |
14 | <link rel="next" href="crypto.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>14.11.2 Mixer Device Objects </title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="14.11.1 Audio Device Objects" | |
24 | href="ossaudio-device-objects.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="14.11 ossaudiodev " | |
27 | href="module-ossaudiodev.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="15. Cryptographic Services" | |
30 | href="crypto.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Library Reference</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
37 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="ossaudio-device-objects.html">14.11.1 Audio Device Objects</A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="module-ossaudiodev.html">14.11 ossaudiodev </A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="crypto.html">15. Cryptographic Services</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H2><A NAME="SECTION00161120000000000000000"></A><A NAME="mixer-device-objects"></A> | |
55 | <BR> | |
56 | 14.11.2 Mixer Device Objects | |
57 | </H2> | |
58 | ||
59 | <P> | |
60 | The mixer object provides two file-like methods: | |
61 | ||
62 | <P> | |
63 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
64 | <td><nobr><b><tt id='l2h-4792' xml:id='l2h-4792' class="method">close</tt></b>(</nobr></td> | |
65 | <td><var></var>)</td></tr></table></dt> | |
66 | <dd> | |
67 | This method closes the open mixer device file. Any further attempts to | |
68 | use the mixer after this file is closed will raise an IOError. | |
69 | </dl> | |
70 | ||
71 | <P> | |
72 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
73 | <td><nobr><b><tt id='l2h-4793' xml:id='l2h-4793' class="method">fileno</tt></b>(</nobr></td> | |
74 | <td><var></var>)</td></tr></table></dt> | |
75 | <dd> | |
76 | Returns the file handle number of the open mixer device file. | |
77 | </dl> | |
78 | ||
79 | <P> | |
80 | The remaining methods are specific to audio mixing: | |
81 | ||
82 | <P> | |
83 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
84 | <td><nobr><b><tt id='l2h-4794' xml:id='l2h-4794' class="method">controls</tt></b>(</nobr></td> | |
85 | <td><var></var>)</td></tr></table></dt> | |
86 | <dd> | |
87 | This method returns a bitmask specifying the available mixer controls | |
88 | (``Control'' being a specific mixable ``channel'', such as | |
89 | <tt class="constant">SOUND_MIXER_PCM</tt> or <tt class="constant">SOUND_MIXER_SYNTH</tt>). This | |
90 | bitmask indicates a subset of all available mixer controls--the | |
91 | <tt class="constant">SOUND_MIXER_*</tt> constants defined at module level. To determine if, | |
92 | for example, the current mixer object supports a PCM mixer, use the | |
93 | following Python code: | |
94 | ||
95 | <P> | |
96 | <div class="verbatim"><pre> | |
97 | mixer=ossaudiodev.openmixer() | |
98 | if mixer.controls() & (1 << ossaudiodev.SOUND_MIXER_PCM): | |
99 | # PCM is supported | |
100 | ... code ... | |
101 | </pre></div> | |
102 | ||
103 | <P> | |
104 | For most purposes, the <tt class="constant">SOUND_MIXER_VOLUME</tt> (master volume) and | |
105 | <tt class="constant">SOUND_MIXER_PCM</tt> controls should suffice--but code that uses the | |
106 | mixer should be flexible when it comes to choosing mixer controls. On | |
107 | the Gravis Ultrasound, for example, <tt class="constant">SOUND_MIXER_VOLUME</tt> does not | |
108 | exist. | |
109 | </dl> | |
110 | ||
111 | <P> | |
112 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
113 | <td><nobr><b><tt id='l2h-4795' xml:id='l2h-4795' class="method">stereocontrols</tt></b>(</nobr></td> | |
114 | <td><var></var>)</td></tr></table></dt> | |
115 | <dd> | |
116 | Returns a bitmask indicating stereo mixer controls. If a bit is set, | |
117 | the corresponding control is stereo; if it is unset, the control is | |
118 | either monophonic or not supported by the mixer (use in combination with | |
119 | <tt class="method">controls()</tt> to determine which). | |
120 | ||
121 | <P> | |
122 | See the code example for the <tt class="method">controls()</tt> function for an example | |
123 | of getting data from a bitmask. | |
124 | </dl> | |
125 | ||
126 | <P> | |
127 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
128 | <td><nobr><b><tt id='l2h-4796' xml:id='l2h-4796' class="method">reccontrols</tt></b>(</nobr></td> | |
129 | <td><var></var>)</td></tr></table></dt> | |
130 | <dd> | |
131 | Returns a bitmask specifying the mixer controls that may be used to | |
132 | record. See the code example for <tt class="method">controls()</tt> for an example of | |
133 | reading from a bitmask. | |
134 | </dl> | |
135 | ||
136 | <P> | |
137 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
138 | <td><nobr><b><tt id='l2h-4797' xml:id='l2h-4797' class="method">get</tt></b>(</nobr></td> | |
139 | <td><var>control</var>)</td></tr></table></dt> | |
140 | <dd> | |
141 | Returns the volume of a given mixer control. The returned volume is a | |
142 | 2-tuple <code>(left_volume,right_volume)</code>. Volumes are specified as | |
143 | numbers from 0 (silent) to 100 (full volume). If the control is | |
144 | monophonic, a 2-tuple is still returned, but both volumes are | |
145 | the same. | |
146 | ||
147 | <P> | |
148 | Raises <tt class="exception">OSSAudioError</tt> if an invalid control was is specified, | |
149 | or <tt class="exception">IOError</tt> if an unsupported control is specified. | |
150 | </dl> | |
151 | ||
152 | <P> | |
153 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
154 | <td><nobr><b><tt id='l2h-4798' xml:id='l2h-4798' class="method">set</tt></b>(</nobr></td> | |
155 | <td><var>control, (left, right)</var>)</td></tr></table></dt> | |
156 | <dd> | |
157 | Sets the volume for a given mixer control to <code>(left,right)</code>. | |
158 | <code>left</code> and <code>right</code> must be ints and between 0 (silent) and 100 | |
159 | (full volume). On success, the new volume is returned as a 2-tuple. | |
160 | Note that this may not be exactly the same as the volume specified, | |
161 | because of the limited resolution of some soundcard's mixers. | |
162 | ||
163 | <P> | |
164 | Raises <tt class="exception">OSSAudioError</tt> if an invalid mixer control was | |
165 | specified, or if the specified volumes were out-of-range. | |
166 | </dl> | |
167 | ||
168 | <P> | |
169 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
170 | <td><nobr><b><tt id='l2h-4799' xml:id='l2h-4799' class="method">get_recsrc</tt></b>(</nobr></td> | |
171 | <td><var></var>)</td></tr></table></dt> | |
172 | <dd> | |
173 | This method returns a bitmask indicating which control(s) are | |
174 | currently being used as a recording source. | |
175 | </dl> | |
176 | ||
177 | <P> | |
178 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
179 | <td><nobr><b><tt id='l2h-4800' xml:id='l2h-4800' class="method">set_recsrc</tt></b>(</nobr></td> | |
180 | <td><var>bitmask</var>)</td></tr></table></dt> | |
181 | <dd> | |
182 | Call this function to specify a recording source. Returns a bitmask | |
183 | indicating the new recording source (or sources) if successful; raises | |
184 | <tt class="exception">IOError</tt> if an invalid source was specified. To set the current | |
185 | recording source to the microphone input: | |
186 | ||
187 | <P> | |
188 | <div class="verbatim"><pre> | |
189 | mixer.setrecsrc (1 << ossaudiodev.SOUND_MIXER_MIC) | |
190 | </pre></div> | |
191 | </dl> | |
192 | ||
193 | <P> | |
194 | ||
195 | <P> | |
196 | ||
197 | <DIV CLASS="navigation"> | |
198 | <div class='online-navigation'> | |
199 | <p></p><hr /> | |
200 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
201 | <tr> | |
202 | <td class='online-navigation'><a rel="prev" title="14.11.1 Audio Device Objects" | |
203 | href="ossaudio-device-objects.html"><img src='../icons/previous.png' | |
204 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
205 | <td class='online-navigation'><a rel="parent" title="14.11 ossaudiodev " | |
206 | href="module-ossaudiodev.html"><img src='../icons/up.png' | |
207 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
208 | <td class='online-navigation'><a rel="next" title="15. Cryptographic Services" | |
209 | href="crypto.html"><img src='../icons/next.png' | |
210 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
211 | <td align="center" width="100%">Python Library Reference</td> | |
212 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
213 | href="contents.html"><img src='../icons/contents.png' | |
214 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
215 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
216 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
217 | <td class='online-navigation'><a rel="index" title="Index" | |
218 | href="genindex.html"><img src='../icons/index.png' | |
219 | border='0' height='32' alt='Index' width='32' /></A></td> | |
220 | </tr></table> | |
221 | <div class='online-navigation'> | |
222 | <b class="navlabel">Previous:</b> | |
223 | <a class="sectref" rel="prev" href="ossaudio-device-objects.html">14.11.1 Audio Device Objects</A> | |
224 | <b class="navlabel">Up:</b> | |
225 | <a class="sectref" rel="parent" href="module-ossaudiodev.html">14.11 ossaudiodev </A> | |
226 | <b class="navlabel">Next:</b> | |
227 | <a class="sectref" rel="next" href="crypto.html">15. Cryptographic Services</A> | |
228 | </div> | |
229 | </div> | |
230 | <hr /> | |
231 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
232 | </DIV> | |
233 | <!--End of Navigation Panel--> | |
234 | <ADDRESS> | |
235 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
236 | </ADDRESS> | |
237 | </BODY> | |
238 | </HTML> |