root/trunk/libffado/support/mixer/mixer_saffire.py

Revision 1336, 16.7 kB (checked in by ppalmers, 14 years ago)

Bring trunk up to date with branches/libffado-2.0:

"""
svn merge -r 1254:1299 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1301:1320 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1322:1323 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1329:HEAD svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
"""

Add getSupportedSamplingFrequencies() to DICE, RME and Metric Halo AvDevices?

Line 
1 #
2 # Copyright (C) 2005-2008 by Pieter Palmers
3 #
4 # This file is part of FFADO
5 # FFADO = Free Firewire (pro-)audio drivers for linux
6 #
7 # FFADO is based upon FreeBoB.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 2 of the License, or
12 # (at your option) version 3 of the License.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 from qt import *
24 from mixer_saffire_base import SaffireMixerBase
25 from mixer_saffire_stereoui import SaffireMixerStereoUI
26 from mixer_saffire_monoui import SaffireMixerMonoUI
27
28 #MIXER LAYOUT:
29 #
30 #   |-- Out9/10--| |-- Out1/2 --| |-- Out3/4 --| |-- Out5/6 --| |-- Out7/8 --|
31 #P5  0:    0/    0  1:  110/  110  2:    0/    0  3:    0/    0  4:    0/    0
32 #P1  5:    0/    0  6:32767/32767  7:    0/    0  8:    0/    0  9:    0/    0
33 #P2 10:    0/    0 11:    0/    0 12:32767/32767 13:    0/    0 14:    0/    0
34 #P3 15:    0/    0 16:    0/    0 17:    0/    0 18:32767/32767 19:    0/    0
35 #P4 20:    0/    0 21:    0/    0 22:    0/    0 23:    0/    0 24:32767/32767
36 #R1 25:    0/    0 26:    0/    0 27:    0/    0 28:    0/    0 29:    0/    0
37 #R2 30:    0/    0 31:    0/    0 32:    0/    0 33:    0/    0 34:    0/    0
38 #Fx 35:    0/    0 36:    0/    0 37:    0/    0 38:    0/    0 39:    0/    0
39 #
40 #P5: DAW ch 9/10
41 #P1: DAW ch 1/2
42 #P2: DAW ch 3/4
43 #P3: DAW ch 5/6
44 #P4: DAW ch 7/8
45 #R1: HW INPUT ch 1/2
46 #R2: HW INPUT ch 3/4
47 #Fx: reverb/fx return
48
49 class SaffireMixer(QWidget):
50     def __init__(self,parent = None,name = None,fl = 0):
51         QWidget.__init__(self, parent, name, fl)
52
53         self.mono_mode = False
54
55         # create the child widgets
56         self.mono = SaffireMixerMono(self)
57         self.stereo = SaffireMixerStereo(self)
58
59         # make a layout and add the child widgets
60         self.layout = QGridLayout(self,1,2,0,0,"SaffireMixerLayout")
61         self.layout.addItem(QWidgetItem(self.mono))
62         self.layout.addItem(QWidgetItem(self.stereo))
63
64     def show(self):
65         self.selectCorrectMode()
66         QWidget.show(self)
67
68     def getMonoMode(self):
69         return self.hw.getDiscrete('/Mixer/MonoMode')
70     def setMonoMode(self, mode):
71         if mode:
72             self.hw.setDiscrete('/Mixer/MonoMode', 1)
73         else:
74             self.hw.setDiscrete('/Mixer/MonoMode', 0)
75
76     def selectCorrectMode(self):
77         self.mono_mode = self.getMonoMode()
78         if self.mono_mode:
79             self.stereo.hide()
80             self.mono.initValues()
81             self.mono.show()
82         else:
83             self.mono.hide()
84             self.stereo.initValues()
85             self.stereo.show()
86
87     def initValues(self):
88         self.mono_mode = self.getMonoMode()
89
90         self.mono.hw = self.hw
91         self.mono.configrom = self.configrom
92         self.mono.clockselect = self.clockselect
93
94         self.stereo.hw = self.hw
95         self.stereo.configrom = self.configrom
96         self.stereo.clockselect = self.clockselect
97
98         self.selectCorrectMode()
99
100     def polledUpdate(self):
101         if self.mono_mode:
102             self.mono.polledUpdate()
103         else:
104             self.stereo.polledUpdate()
105
106 class SaffireMixerStereo(SaffireMixerStereoUI, SaffireMixerBase):
107     def __init__(self,parent = None,name = None,fl = 0):
108         self.my_parent = parent
109         SaffireMixerStereoUI.__init__(self,parent,name,fl)
110         SaffireMixerBase.__init__(self)
111         QObject.connect(self.btnRefresh, SIGNAL('clicked()'), self.updateValues)
112         QObject.connect(self.btnSwitchStereoMode, SIGNAL('clicked()'), self.switchStereoMode)
113
114     def init(self):
115         print "Init stereo Saffire mixer window"
116
117         self.VolumeControls={
118                 self.sldPC910Out910: ['/Mixer/MatrixMixerStereo', 0, 0],
119                 self.sldPC910Out12: ['/Mixer/MatrixMixerStereo', 0, 1],
120                 self.sldPC910Out34: ['/Mixer/MatrixMixerStereo', 0, 2],
121                 self.sldPC910Out56: ['/Mixer/MatrixMixerStereo', 0, 3],
122                 self.sldPC910Out78: ['/Mixer/MatrixMixerStereo', 0, 4],
123                 self.sldPC12Out910: ['/Mixer/MatrixMixerStereo', 1, 0],
124                 self.sldPC12Out12: ['/Mixer/MatrixMixerStereo', 1, 1],
125                 self.sldPC12Out34: ['/Mixer/MatrixMixerStereo', 1, 2],
126                 self.sldPC12Out56: ['/Mixer/MatrixMixerStereo', 1, 3],
127                 self.sldPC12Out78: ['/Mixer/MatrixMixerStereo', 1, 4],
128                 self.sldPC34Out910: ['/Mixer/MatrixMixerStereo', 2, 0],
129                 self.sldPC34Out12: ['/Mixer/MatrixMixerStereo', 2, 1],
130                 self.sldPC34Out34: ['/Mixer/MatrixMixerStereo', 2, 2],
131                 self.sldPC34Out56: ['/Mixer/MatrixMixerStereo', 2, 3],
132                 self.sldPC34Out78: ['/Mixer/MatrixMixerStereo', 2, 4],
133                 self.sldPC56Out910: ['/Mixer/MatrixMixerStereo', 3, 0],
134                 self.sldPC56Out12: ['/Mixer/MatrixMixerStereo', 3, 1],
135                 self.sldPC56Out34: ['/Mixer/MatrixMixerStereo', 3, 2],
136                 self.sldPC56Out56: ['/Mixer/MatrixMixerStereo', 3, 3],
137                 self.sldPC56Out78: ['/Mixer/MatrixMixerStereo', 3, 4],
138                 self.sldPC78Out910: ['/Mixer/MatrixMixerStereo', 4, 0],
139                 self.sldPC78Out12: ['/Mixer/MatrixMixerStereo', 4, 1],
140                 self.sldPC78Out34: ['/Mixer/MatrixMixerStereo', 4, 2],
141                 self.sldPC78Out56: ['/Mixer/MatrixMixerStereo', 4, 3],
142                 self.sldPC78Out78: ['/Mixer/MatrixMixerStereo', 4, 4],
143
144                 self.sldIN12Out910: ['/Mixer/MatrixMixerStereo', 5, 0],
145                 self.sldIN12Out12: ['/Mixer/MatrixMixerStereo', 5, 1],
146                 self.sldIN12Out34: ['/Mixer/MatrixMixerStereo', 5, 2],
147                 self.sldIN12Out56: ['/Mixer/MatrixMixerStereo', 5, 3],
148                 self.sldIN12Out78: ['/Mixer/MatrixMixerStereo', 5, 4],
149                 self.sldIN34Out910: ['/Mixer/MatrixMixerStereo', 6, 0],
150                 self.sldIN34Out12: ['/Mixer/MatrixMixerStereo', 6, 1],
151                 self.sldIN34Out34: ['/Mixer/MatrixMixerStereo', 6, 2],
152                 self.sldIN34Out56: ['/Mixer/MatrixMixerStereo', 6, 3],
153                 self.sldIN34Out78: ['/Mixer/MatrixMixerStereo', 6, 4],
154
155                 self.sldFXOut910: ['/Mixer/MatrixMixerStereo', 7, 0],
156                 self.sldFXOut12: ['/Mixer/MatrixMixerStereo', 7, 1],
157                 self.sldFXOut34: ['/Mixer/MatrixMixerStereo', 7, 2],
158                 self.sldFXOut56: ['/Mixer/MatrixMixerStereo', 7, 3],
159                 self.sldFXOut78: ['/Mixer/MatrixMixerStereo', 7, 4],
160                 }
161
162
163         # First column is the DBUS subpath of the control.
164         # Second column is a list of linked controls that should
165         # be rewritten whenever this control is updated
166         self.SelectorControls={
167                 self.chkSpdifSwitch:    ['/Mixer/SpdifSwitch'],
168                 self.chkOut12Mute:      ['/Mixer/Out12Mute', [self.chkOut12HwCtrl]],
169                 self.chkOut12HwCtrl:    ['/Mixer/Out12HwCtrl'],
170                 self.chkOut12Dim:       ['/Mixer/Out12Dim'],
171                 self.chkOut34Mute:      ['/Mixer/Out34Mute', [self.chkOut34HwCtrl]],
172                 self.chkOut34HwCtrl:    ['/Mixer/Out34HwCtrl'],
173                 self.chkOut56Mute:      ['/Mixer/Out56Mute', [self.chkOut56HwCtrl]],
174                 self.chkOut56HwCtrl:    ['/Mixer/Out56HwCtrl'],
175                 self.chkOut78Mute:      ['/Mixer/Out78Mute', [self.chkOut78HwCtrl]],
176                 self.chkOut78HwCtrl:    ['/Mixer/Out78HwCtrl'],
177                 self.chkOut910Mute:     ['/Mixer/Out910Mute'],
178                 }
179
180         self.VolumeControlsLowRes={
181                 self.sldOut12Level:      ['/Mixer/Out12Level'],
182                 self.sldOut34Level:      ['/Mixer/Out34Level'],
183                 self.sldOut56Level:      ['/Mixer/Out56Level'],
184                 self.sldOut78Level:      ['/Mixer/Out78Level'],
185                 }
186
187         self.TriggerButtonControls={
188                 self.btnSaveSettings:      ['/Mixer/SaveSettings'],
189         }
190
191         self.TextControls={
192         }
193
194         self.saveTextControls={
195         }
196
197         self.ComboControls={
198         }
199
200     def polledUpdate(self):
201         self.polledUpdateHwCtrl(self.chkOut12HwCtrl, self.sldOut12Level)
202         self.polledUpdateHwCtrl(self.chkOut34HwCtrl, self.sldOut34Level)
203         self.polledUpdateHwCtrl(self.chkOut56HwCtrl, self.sldOut56Level)
204         self.polledUpdateHwCtrl(self.chkOut78HwCtrl, self.sldOut78Level)
205
206     def polledUpdateHwCtrl(self, selector, volctrl):
207         state = selector.state()
208         if state:
209             self.polledUpdateVolumeLowRes('/Mixer/MonitorDial', volctrl)
210             volctrl.setEnabled(False)
211         else:
212             volctrl.setEnabled(True)
213
214     def updateMatrixVolume(self,a0):
215         SaffireMixerBase.updateMatrixVolume(self,a0)
216     def updateLowResVolume(self,a0):
217         SaffireMixerBase.updateLowResVolume(self,a0)
218     def updateSelector(self,a0):
219         SaffireMixerBase.updateSelector(self,a0)
220     def triggerButton(self):
221         SaffireMixerBase.triggerButton(self)
222     def saveText(self):
223         SaffireMixerBase.saveText(self)
224     def initCombo(self, combo):
225         SaffireMixerBase.initCombo(self,combo)
226     def selectCombo(self, mode):
227         SaffireMixerBase.selectCombo(self,mode)
228
229     def updateValues(self):
230         SaffireMixerBase.updateValues(self)
231     def switchStereoMode(self):
232         print "should switch to mono mode"
233         self.my_parent.setMonoMode(1)
234         self.my_parent.selectCorrectMode()
235
236 class SaffireMixerMono(SaffireMixerMonoUI, SaffireMixerBase):
237     def __init__(self,parent = None,name = None,fl = 0):
238         self.my_parent = parent
239         SaffireMixerMonoUI.__init__(self,parent,name,fl)
240         SaffireMixerBase.__init__(self)
241         QObject.connect(self.btnRefresh, SIGNAL('clicked()'), self.updateValues)
242         QObject.connect(self.btnSwitchStereoMode, SIGNAL('clicked()'), self.switchStereoMode)
243
244     def init(self):
245         print "Init mono Saffire mixer window"
246
247         self.VolumeControls={
248                 self.sldIN1Out910: ['/Mixer/MatrixMixerMono', 0, 0],
249                 self.sldIN1Out12: ['/Mixer/MatrixMixerMono', 0, 1],
250                 self.sldIN1Out34: ['/Mixer/MatrixMixerMono', 0, 2],
251                 self.sldIN1Out56: ['/Mixer/MatrixMixerMono', 0, 3],
252                 self.sldIN1Out78: ['/Mixer/MatrixMixerMono', 0, 4],
253                 self.sldIN3Out910: ['/Mixer/MatrixMixerMono', 1, 0],
254                 self.sldIN3Out12: ['/Mixer/MatrixMixerMono', 1, 1],
255                 self.sldIN3Out34: ['/Mixer/MatrixMixerMono', 1, 2],
256                 self.sldIN3Out56: ['/Mixer/MatrixMixerMono', 1, 3],
257                 self.sldIN3Out78: ['/Mixer/MatrixMixerMono', 1, 4],
258                 self.sldFX1Out910: ['/Mixer/MatrixMixerMono', 2, 0],
259                 self.sldFX1Out12: ['/Mixer/MatrixMixerMono', 2, 1],
260                 self.sldFX1Out34: ['/Mixer/MatrixMixerMono', 2, 2],
261                 self.sldFX1Out56: ['/Mixer/MatrixMixerMono', 2, 3],
262                 self.sldFX1Out78: ['/Mixer/MatrixMixerMono', 2, 4],
263                 self.sldIN2Out910: ['/Mixer/MatrixMixerMono', 3, 0],
264                 self.sldIN2Out12: ['/Mixer/MatrixMixerMono', 3, 1],
265                 self.sldIN2Out34: ['/Mixer/MatrixMixerMono', 3, 2],
266                 self.sldIN2Out56: ['/Mixer/MatrixMixerMono', 3, 3],
267                 self.sldIN2Out78: ['/Mixer/MatrixMixerMono', 3, 4],
268                 self.sldIN4Out910: ['/Mixer/MatrixMixerMono', 4, 0],
269                 self.sldIN4Out12: ['/Mixer/MatrixMixerMono', 4, 1],
270                 self.sldIN4Out34: ['/Mixer/MatrixMixerMono', 4, 2],
271                 self.sldIN4Out56: ['/Mixer/MatrixMixerMono', 4, 3],
272                 self.sldIN4Out78: ['/Mixer/MatrixMixerMono', 4, 4],
273                 self.sldFX2Out910: ['/Mixer/MatrixMixerMono', 5, 0],
274                 self.sldFX2Out12: ['/Mixer/MatrixMixerMono', 5, 1],
275                 self.sldFX2Out34: ['/Mixer/MatrixMixerMono', 5, 2],
276                 self.sldFX2Out56: ['/Mixer/MatrixMixerMono', 5, 3],
277                 self.sldFX2Out78: ['/Mixer/MatrixMixerMono', 5, 4],
278
279                 self.sldPC910Out910: ['/Mixer/MatrixMixerMono', 6, 0],
280                 self.sldPC910Out12: ['/Mixer/MatrixMixerMono', 6, 1],
281                 self.sldPC910Out34: ['/Mixer/MatrixMixerMono', 6, 2],
282                 self.sldPC910Out56: ['/Mixer/MatrixMixerMono', 6, 3],
283                 self.sldPC910Out78: ['/Mixer/MatrixMixerMono', 6, 4],
284                 self.sldPC12Out910: ['/Mixer/MatrixMixerMono', 7, 0],
285                 self.sldPC12Out12: ['/Mixer/MatrixMixerMono', 7, 1],
286                 self.sldPC12Out34: ['/Mixer/MatrixMixerMono', 7, 2],
287                 self.sldPC12Out56: ['/Mixer/MatrixMixerMono', 7, 3],
288                 self.sldPC12Out78: ['/Mixer/MatrixMixerMono', 7, 4],
289                 self.sldPC34Out910: ['/Mixer/MatrixMixerMono', 8, 0],
290                 self.sldPC34Out12: ['/Mixer/MatrixMixerMono', 8, 1],
291                 self.sldPC34Out34: ['/Mixer/MatrixMixerMono', 8, 2],
292                 self.sldPC34Out56: ['/Mixer/MatrixMixerMono', 8, 3],
293                 self.sldPC34Out78: ['/Mixer/MatrixMixerMono', 8, 4],
294                 self.sldPC56Out910: ['/Mixer/MatrixMixerMono', 9, 0],
295                 self.sldPC56Out12: ['/Mixer/MatrixMixerMono', 9, 1],
296                 self.sldPC56Out34: ['/Mixer/MatrixMixerMono', 9, 2],
297                 self.sldPC56Out56: ['/Mixer/MatrixMixerMono', 9, 3],
298                 self.sldPC56Out78: ['/Mixer/MatrixMixerMono', 9, 4],
299                 self.sldPC78Out910: ['/Mixer/MatrixMixerMono', 10, 0],
300                 self.sldPC78Out12: ['/Mixer/MatrixMixerMono', 10, 1],
301                 self.sldPC78Out34: ['/Mixer/MatrixMixerMono', 10, 2],
302                 self.sldPC78Out56: ['/Mixer/MatrixMixerMono', 10, 3],
303                 self.sldPC78Out78: ['/Mixer/MatrixMixerMono', 10, 4],
304
305
306                 }
307
308
309         # First column is the DBUS subpath of the control.
310         # Second column is a list of linked controls that should
311         # be rewritten whenever this control is updated
312         self.SelectorControls={
313                 self.chkSpdifSwitch:    ['/Mixer/SpdifSwitch'],
314                 self.chkOut12Mute:      ['/Mixer/Out12Mute', [self.chkOut12HwCtrl]],
315                 self.chkOut12HwCtrl:    ['/Mixer/Out12HwCtrl'],
316                 self.chkOut12Dim:       ['/Mixer/Out12Dim'],
317                 self.chkOut34Mute:      ['/Mixer/Out34Mute', [self.chkOut34HwCtrl]],
318                 self.chkOut34HwCtrl:    ['/Mixer/Out34HwCtrl'],
319                 self.chkOut56Mute:      ['/Mixer/Out56Mute', [self.chkOut56HwCtrl]],
320                 self.chkOut56HwCtrl:    ['/Mixer/Out56HwCtrl'],
321                 self.chkOut78Mute:      ['/Mixer/Out78Mute', [self.chkOut78HwCtrl]],
322                 self.chkOut78HwCtrl:    ['/Mixer/Out78HwCtrl'],
323                 self.chkOut910Mute:     ['/Mixer/Out910Mute'],
324                 }
325
326         self.VolumeControlsLowRes={
327                 self.sldOut12Level:      ['/Mixer/Out12Level'],
328                 self.sldOut34Level:      ['/Mixer/Out34Level'],
329                 self.sldOut56Level:      ['/Mixer/Out56Level'],
330                 self.sldOut78Level:      ['/Mixer/Out78Level'],
331                 }
332
333         self.TriggerButtonControls={
334                 self.btnSaveSettings:      ['/Mixer/SaveSettings'],
335         }
336
337         self.TextControls={
338         }
339
340         self.saveTextControls={
341         }
342
343         self.ComboControls={
344         }
345
346     def polledUpdate(self):
347         self.polledUpdateHwCtrl(self.chkOut12HwCtrl, self.sldOut12Level)
348         self.polledUpdateHwCtrl(self.chkOut34HwCtrl, self.sldOut34Level)
349         self.polledUpdateHwCtrl(self.chkOut56HwCtrl, self.sldOut56Level)
350         self.polledUpdateHwCtrl(self.chkOut78HwCtrl, self.sldOut78Level)
351
352     def polledUpdateHwCtrl(self, selector, volctrl):
353         state = selector.state()
354         if state:
355             self.polledUpdateVolumeLowRes('/Mixer/MonitorDial', volctrl)
356             volctrl.setEnabled(False)
357         else:
358             volctrl.setEnabled(True)
359
360     def updateMatrixVolume(self,a0):
361         SaffireMixerBase.updateMatrixVolume(self,a0)
362     def updateLowResVolume(self,a0):
363         SaffireMixerBase.updateLowResVolume(self,a0)
364     def updateSelector(self,a0):
365         SaffireMixerBase.updateSelector(self,a0)
366     def triggerButton(self):
367         SaffireMixerBase.triggerButton(self)
368     def saveText(self):
369         SaffireMixerBase.saveText(self)
370     def initCombo(self, combo):
371         SaffireMixerBase.initCombo(self,combo)
372     def selectCombo(self, mode):
373         SaffireMixerBase.selectCombo(self,mode)
374
375     def updateValues(self):
376         SaffireMixerBase.updateValues(self)
377
378     def switchStereoMode(self):
379         print "should switch to stero mode"
380         self.my_parent.setMonoMode(0)
381         self.my_parent.selectCorrectMode()
Note: See TracBrowser for help on using the browser.