root/branches/libffado-2.0/support/mixer-qt4/mixer_saffirepro.py

Revision 1298, 17.6 kB (checked in by ppalmers, 13 years ago)

add Qt4 port of the mixer (only for audiofire and saffire ATM). needed since PyQt?3 doesn't support DBUS signals.

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 PyQt4.QtGui import QWidget, QHBoxLayout
24 from mixer_saffire_base import SaffireMixerBase
25 from mixer_saffirepro_largeui import Ui_SaffireProMixerLargeUI
26 from mixer_saffirepro_smallui import Ui_SaffireProMixerSmallUI
27
28 class SaffireProMixer(QWidget):
29     def __init__(self,parent = None):
30         QWidget.__init__(self, parent)
31
32         self.have_adat = False
33         self.samplerate = None
34         self.is_pro10 = None
35
36         # make a layout
37         self.layout = QHBoxLayout()
38         self.setLayout(self.layout)
39
40     def show(self):
41         self.selectCorrectMode()
42         QWidget.show(self)
43
44     def getDisplayTitle(self):
45         try:
46             return self.nickname.text()
47         except:
48             if self.is_pro10:
49                 return "SaffirePRO10"
50             else:
51                 return "SaffirePRO26"
52
53     def selectCorrectMode(self):
54         if self.samplerate <= 96000:
55             print "large"
56             self.small.hide()
57             self.large.initValues()
58             self.large.show()
59         else:
60             print "small"
61             self.large.hide()
62             self.small.initValues()
63             self.small.show()
64
65     def initValues(self):
66         selected = self.samplerateselect.selected()
67         self.samplerate = int(self.samplerateselect.getEnumLabel( selected ))
68         print "detected samplerate %d" % self.samplerate
69
70         # adat on PRO26 makes a difference
71         modelId = self.configrom.getModelId()
72         if modelId == 0x00000003: # PRO26
73             self.is_pro10 = False
74             state = self.hw.getDiscrete('/Control/ADATDisable')
75             if state:
76                 self.have_adat = False
77                 print "detected PRO26, ADAT disabled"
78             else:
79                 self.have_adat = True
80                 print "detected PRO26, ADAT enabled"
81         elif modelId == 0x00000006: # PRO10
82             self.is_pro10 = True
83             self.have_adat = False
84
85         # create the child widgets
86         self.small = SaffireProMixerSmall(self)
87         self.layout.addWidget(self.small)
88         self.large = SaffireProMixerLarge(self)
89         self.layout.addWidget(self.large)
90
91         self.small.hw = self.hw
92         self.small.configrom = self.configrom
93
94         self.large.hw = self.hw
95         self.large.configrom = self.configrom
96
97         self.selectCorrectMode()
98
99     def polledUpdate(self):
100         # fixme: todo
101         pass
102
103 class SaffireProMixerLarge(QWidget, Ui_SaffireProMixerLargeUI, SaffireMixerBase):
104     def __init__(self,parent = None):
105         self.my_parent = parent
106         QWidget.__init__(self,parent)
107         SaffireMixerBase.__init__(self)
108         self.setupUi(self)
109         self.have_adat = False
110         print "Init large Saffire Pro mixer window"
111
112         self.VolumeControls={
113             self.sldIMixAnalog1L: ['/Mixer/InputMix', 0, 0],
114             self.sldIMixAnalog1R: ['/Mixer/InputMix', 0, 1],
115             self.sldIMixAnalog2L: ['/Mixer/InputMix', 1, 0],
116             self.sldIMixAnalog2R: ['/Mixer/InputMix', 1, 1],
117             self.sldIMixAnalog3L: ['/Mixer/InputMix', 2, 0],
118             self.sldIMixAnalog3R: ['/Mixer/InputMix', 2, 1],
119             self.sldIMixAnalog4L: ['/Mixer/InputMix', 3, 0],
120             self.sldIMixAnalog4R: ['/Mixer/InputMix', 3, 1],
121             self.sldIMixAnalog5L: ['/Mixer/InputMix', 4, 0],
122             self.sldIMixAnalog5R: ['/Mixer/InputMix', 4, 1],
123             self.sldIMixAnalog6L: ['/Mixer/InputMix', 5, 0],
124             self.sldIMixAnalog6R: ['/Mixer/InputMix', 5, 1],
125             self.sldIMixAnalog7L: ['/Mixer/InputMix', 6, 0],
126             self.sldIMixAnalog7R: ['/Mixer/InputMix', 6, 1],
127             self.sldIMixAnalog8L: ['/Mixer/InputMix', 7, 0],
128             self.sldIMixAnalog8R: ['/Mixer/InputMix', 7, 1],
129             self.sldIMixAnalog9L: ['/Mixer/InputMix', 8, 0],
130             self.sldIMixAnalog9R: ['/Mixer/InputMix', 8, 1],
131             self.sldIMixAnalog10L: ['/Mixer/InputMix', 9, 0],
132             self.sldIMixAnalog10R: ['/Mixer/InputMix', 9, 1],
133             self.sldIMixADAT11L: ['/Mixer/InputMix', 10, 0],
134             self.sldIMixADAT11R: ['/Mixer/InputMix', 10, 1],
135             self.sldIMixADAT12L: ['/Mixer/InputMix', 11, 0],
136             self.sldIMixADAT12R: ['/Mixer/InputMix', 11, 1],
137             self.sldIMixADAT13L: ['/Mixer/InputMix', 12, 0],
138             self.sldIMixADAT13R: ['/Mixer/InputMix', 12, 1],
139             self.sldIMixADAT14L: ['/Mixer/InputMix', 13, 0],
140             self.sldIMixADAT14R: ['/Mixer/InputMix', 13, 1],
141             self.sldIMixADAT15L: ['/Mixer/InputMix', 14, 0],
142             self.sldIMixADAT15R: ['/Mixer/InputMix', 14, 1],
143             self.sldIMixADAT16L: ['/Mixer/InputMix', 15, 0],
144             self.sldIMixADAT16R: ['/Mixer/InputMix', 15, 1],
145             self.sldIMixADAT17L: ['/Mixer/InputMix', 16, 0],
146             self.sldIMixADAT17R: ['/Mixer/InputMix', 16, 1],
147             self.sldIMixADAT18L: ['/Mixer/InputMix', 17, 0],
148             self.sldIMixADAT18R: ['/Mixer/InputMix', 17, 1],
149             self.sldIMixADAT21L: ['/Mixer/InputMix', 18, 0],
150             self.sldIMixADAT21R: ['/Mixer/InputMix', 18, 1],
151             self.sldIMixADAT22L: ['/Mixer/InputMix', 19, 0],
152             self.sldIMixADAT22R: ['/Mixer/InputMix', 19, 1],
153             self.sldIMixADAT23L: ['/Mixer/InputMix', 20, 0],
154             self.sldIMixADAT23R: ['/Mixer/InputMix', 20, 1],
155             self.sldIMixADAT24L: ['/Mixer/InputMix', 21, 0],
156             self.sldIMixADAT24R: ['/Mixer/InputMix', 21, 1],
157             self.sldIMixADAT25L: ['/Mixer/InputMix', 22, 0],
158             self.sldIMixADAT25R: ['/Mixer/InputMix', 22, 1],
159             self.sldIMixADAT26L: ['/Mixer/InputMix', 23, 0],
160             self.sldIMixADAT26R: ['/Mixer/InputMix', 23, 1],
161             self.sldIMixADAT27L: ['/Mixer/InputMix', 24, 0],
162             self.sldIMixADAT27R: ['/Mixer/InputMix', 24, 1],
163             self.sldIMixADAT28L: ['/Mixer/InputMix', 25, 0],
164             self.sldIMixADAT28R: ['/Mixer/InputMix', 25, 1],
165            
166             self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
167             self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
168             self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
169             self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
170             self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
171             self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
172             self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
173             self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
174             self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
175             self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
176            
177             self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
178             self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
179             self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
180             self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
181             self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
182             self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
183             self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
184             self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
185            
186             self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
187             self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
188             self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
189             self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
190             self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
191             self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
192             self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
193             self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
194             self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
195             self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
196             }
197
198
199         self.SelectorControls={
200             # control elements
201             self.chkInsert1: ['/Control/Insert1'],
202             self.chkInsert2: ['/Control/Insert2'],
203             self.chkPhantom14: ['/Control/Phantom_1to4'],
204             self.chkPhantom58: ['/Control/Phantom_5to8'],
205             self.chkAC3: ['/Control/AC3pass'],
206             self.chkMidiThru: ['/Control/MidiTru'],
207             self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
208             #self.chkEnableADAT1: ['/Control/EnableAdat1'],
209             #self.chkEnableADAT2: ['/Control/EnableAdat2'],
210             #self.chkEnableSPDIF1: ['/Control/EnableSPDIF1'],
211             self.chkMidiEnable: ['/Control/MIDIEnable'],
212             self.chkAdatDisable: ['/Control/ADATDisable'],
213             # Mixer switches
214             self.chkMute12: ['/Mixer/Out12Mute'],
215             self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
216             self.chkPad12: ['/Mixer/Out12Pad'],
217             self.chkDim12: ['/Mixer/Out12Dim'],
218             self.chkMute34: ['/Mixer/Out34Mute'],
219             self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
220             self.chkPad34: ['/Mixer/Out34Pad'],
221             self.chkDim34: ['/Mixer/Out34Dim'],
222             self.chkMute56: ['/Mixer/Out56Mute'],
223             self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
224             self.chkPad56: ['/Mixer/Out56Pad'],
225             self.chkDim56: ['/Mixer/Out56Dim'],
226             self.chkMute78: ['/Mixer/Out78Mute'],
227             self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
228             self.chkPad78: ['/Mixer/Out78Pad'],
229             self.chkDim78: ['/Mixer/Out78Dim'],
230             # direct monitoring
231             self.chkMonitor1: ['/Mixer/DirectMonitorCH1'],
232             self.chkMonitor2: ['/Mixer/DirectMonitorCH2'],
233             self.chkMonitor3: ['/Mixer/DirectMonitorCH3'],
234             self.chkMonitor4: ['/Mixer/DirectMonitorCH4'],
235             self.chkMonitor5: ['/Mixer/DirectMonitorCH5'],
236             self.chkMonitor6: ['/Mixer/DirectMonitorCH6'],
237             self.chkMonitor7: ['/Mixer/DirectMonitorCH7'],
238             self.chkMonitor8: ['/Mixer/DirectMonitorCH8'],
239         }
240
241         self.VolumeControlsLowRes={
242             self.sldOut12Level:      ['/Mixer/Out12Level'],
243             self.sldOut34Level:      ['/Mixer/Out34Level'],
244             self.sldOut56Level:      ['/Mixer/Out56Level'],
245             self.sldOut78Level:      ['/Mixer/Out78Level'],
246         }
247
248         self.TriggerButtonControls={
249             self.btnReboot:        ['/Control/Reboot'],
250             self.btnIdentify:      ['/Control/FlashLed'],
251             self.btnSaveSettings:  ['/Control/SaveSettings'],
252         }
253
254         self.TextControls={
255         }
256
257         self.saveTextControls={
258         }
259
260         self.ComboControls={
261             self.comboStandalone:        ['/Control/StandaloneConfig'],
262         }
263
264     def updateMatrixVolume(self,a0):
265         SaffireMixerBase.updateMatrixVolume(self,a0)
266     def updateLowResVolume(self,a0):
267         SaffireMixerBase.updateLowResVolume(self,a0)
268     def updateSelector(self,a0):
269         SaffireMixerBase.updateSelector(self,a0)
270     def triggerButton(self):
271         SaffireMixerBase.triggerButton(self)
272     def saveText(self):
273         SaffireMixerBase.saveText(self)
274     def initCombo(self, combo):
275         SaffireMixerBase.initCombo(self,combo)
276     def selectCombo(self, mode):
277         SaffireMixerBase.selectCombo(self,mode)
278
279     def updateValues(self):
280         for i in range(self.tabInputMix.count()):
281             self.tabInputMix.setTabEnabled(i, True)
282
283         if not self.my_parent.have_adat:
284             for i in range(self.tabInputMix.count()):
285                 page = self.tabInputMix.widget(i)
286                 name = page.objectName()
287                 if name[0:4] == "adat":
288                     self.tabInputMix.setTabEnabled(i, False)
289                 else:
290                     self.tabInputMix.setTabEnabled(i, True)
291
292         self.tabInputMix.setCurrentWidget(self.tabInputMix.widget(0))
293         SaffireMixerBase.updateValues(self)
294
295 class SaffireProMixerSmall(QWidget, Ui_SaffireProMixerSmallUI, SaffireMixerBase):
296     def __init__(self,parent = None):
297         self.my_parent = parent
298         QWidget.__init__(self,parent)
299         SaffireMixerBase.__init__(self)
300         self.setupUi(self)
301         print "Init small Saffire Pro mixer window"
302
303         self.VolumeControls={
304
305             self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
306             self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
307             self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
308             self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
309             self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
310             self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
311             self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
312             self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
313             self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
314             self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
315            
316             self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
317             self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
318             self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
319             self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
320             self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
321             self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
322             self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
323             self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
324            
325             self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
326             self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
327             self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
328             self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
329             self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
330             self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
331             self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
332             self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
333             self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
334             self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
335             }
336
337
338         self.SelectorControls={
339             # control elements
340             self.chkInsert1: ['/Control/Insert1'],
341             self.chkInsert2: ['/Control/Insert2'],
342             self.chkPhantom14: ['/Control/Phantom_1to4'],
343             self.chkPhantom58: ['/Control/Phantom_5to8'],
344             self.chkAC3: ['/Control/AC3pass'],
345             self.chkMidiThru: ['/Control/MidiTru'],
346             self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
347             #self.chkEnableADAT1: ['/Control/EnableAdat1'],
348             #self.chkEnableADAT2: ['/Control/EnableAdat2'],
349             #self.chkEnableSPDIF1: ['/Control/EnableSPDIF1'],
350             self.chkMidiEnable: ['/Control/MIDIEnable'],
351             self.chkAdatDisable: ['/Control/ADATDisable'],
352             # Mixer switches
353             self.chkMute12: ['/Mixer/Out12Mute'],
354             self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
355             self.chkPad12: ['/Mixer/Out12Pad'],
356             self.chkDim12: ['/Mixer/Out12Dim'],
357             self.chkMute34: ['/Mixer/Out34Mute'],
358             self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
359             self.chkPad34: ['/Mixer/Out34Pad'],
360             self.chkDim34: ['/Mixer/Out34Dim'],
361             self.chkMute56: ['/Mixer/Out56Mute'],
362             self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
363             self.chkPad56: ['/Mixer/Out56Pad'],
364             self.chkDim56: ['/Mixer/Out56Dim'],
365             self.chkMute78: ['/Mixer/Out78Mute'],
366             self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
367             self.chkPad78: ['/Mixer/Out78Pad'],
368             self.chkDim78: ['/Mixer/Out78Dim'],
369             # direct monitoring
370             self.chkMonitor1: ['/Mixer/DirectMonitorCH1'],
371             self.chkMonitor2: ['/Mixer/DirectMonitorCH2'],
372             self.chkMonitor3: ['/Mixer/DirectMonitorCH3'],
373             self.chkMonitor4: ['/Mixer/DirectMonitorCH4'],
374             self.chkMonitor5: ['/Mixer/DirectMonitorCH5'],
375             self.chkMonitor6: ['/Mixer/DirectMonitorCH6'],
376             self.chkMonitor7: ['/Mixer/DirectMonitorCH7'],
377             self.chkMonitor8: ['/Mixer/DirectMonitorCH8'],
378         }
379
380         self.VolumeControlsLowRes={
381             self.sldOut12Level:      ['/Mixer/Out12Level'],
382             self.sldOut34Level:      ['/Mixer/Out34Level'],
383             self.sldOut56Level:      ['/Mixer/Out56Level'],
384             self.sldOut78Level:      ['/Mixer/Out78Level'],
385         }
386
387         self.TriggerButtonControls={
388             self.btnReboot:        ['/Control/Reboot'],
389             self.btnIdentify:      ['/Control/FlashLed'],
390             self.btnSaveSettings:  ['/Control/SaveSettings'],
391         }
392
393         self.TextControls={
394         }
395
396         self.saveTextControls={
397         }
398
399         self.ComboControls={
400             self.comboStandalone:        ['/Control/StandaloneConfig'],
401         }
402
403     def updateMatrixVolume(self,a0):
404         SaffireMixerBase.updateMatrixVolume(self,a0)
405     def updateLowResVolume(self,a0):
406         SaffireMixerBase.updateLowResVolume(self,a0)
407     def updateSelector(self,a0):
408         SaffireMixerBase.updateSelector(self,a0)
409     def triggerButton(self):
410         SaffireMixerBase.triggerButton(self)
411     def saveText(self):
412         SaffireMixerBase.saveText(self)
413     def initCombo(self, combo):
414         SaffireMixerBase.initCombo(self,combo)
415     def selectCombo(self, mode):
416         SaffireMixerBase.selectCombo(self,mode)
417
418     def updateValues(self):
419         SaffireMixerBase.updateValues(self)
Note: See TracBrowser for help on using the browser.