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

Revision 1367, 17.7 kB (checked in by ppalmers, 12 years ago)

use the python logging framework for the mixer debug messages (QT4 only)

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