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

Revision 1370, 19.1 kB (checked in by ppalmers, 12 years ago)

fix up saffire mixers (closes #147)

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         if self.samplerate <= 96000:
104             self.large.polledUpdate()
105         else:
106             self.small.polledUpdate()
107
108 class SaffireProMixerLarge(QWidget, Ui_SaffireProMixerLargeUI, SaffireMixerBase):
109     def __init__(self,parent = None):
110         self.my_parent = parent
111         QWidget.__init__(self,parent)
112         SaffireMixerBase.__init__(self)
113         self.setupUi(self)
114         self.have_adat = False
115         log.debug("Init large Saffire Pro mixer window")
116
117         self.VolumeControls={
118             self.sldIMixAnalog1L: ['/Mixer/InputMix', 0, 0],
119             self.sldIMixAnalog1R: ['/Mixer/InputMix', 0, 1],
120             self.sldIMixAnalog2L: ['/Mixer/InputMix', 1, 0],
121             self.sldIMixAnalog2R: ['/Mixer/InputMix', 1, 1],
122             self.sldIMixAnalog3L: ['/Mixer/InputMix', 2, 0],
123             self.sldIMixAnalog3R: ['/Mixer/InputMix', 2, 1],
124             self.sldIMixAnalog4L: ['/Mixer/InputMix', 3, 0],
125             self.sldIMixAnalog4R: ['/Mixer/InputMix', 3, 1],
126             self.sldIMixAnalog5L: ['/Mixer/InputMix', 4, 0],
127             self.sldIMixAnalog5R: ['/Mixer/InputMix', 4, 1],
128             self.sldIMixAnalog6L: ['/Mixer/InputMix', 5, 0],
129             self.sldIMixAnalog6R: ['/Mixer/InputMix', 5, 1],
130             self.sldIMixAnalog7L: ['/Mixer/InputMix', 6, 0],
131             self.sldIMixAnalog7R: ['/Mixer/InputMix', 6, 1],
132             self.sldIMixAnalog8L: ['/Mixer/InputMix', 7, 0],
133             self.sldIMixAnalog8R: ['/Mixer/InputMix', 7, 1],
134             self.sldIMixAnalog9L: ['/Mixer/InputMix', 8, 0],
135             self.sldIMixAnalog9R: ['/Mixer/InputMix', 8, 1],
136             self.sldIMixAnalog10L: ['/Mixer/InputMix', 9, 0],
137             self.sldIMixAnalog10R: ['/Mixer/InputMix', 9, 1],
138             self.sldIMixADAT11L: ['/Mixer/InputMix', 10, 0],
139             self.sldIMixADAT11R: ['/Mixer/InputMix', 10, 1],
140             self.sldIMixADAT12L: ['/Mixer/InputMix', 11, 0],
141             self.sldIMixADAT12R: ['/Mixer/InputMix', 11, 1],
142             self.sldIMixADAT13L: ['/Mixer/InputMix', 12, 0],
143             self.sldIMixADAT13R: ['/Mixer/InputMix', 12, 1],
144             self.sldIMixADAT14L: ['/Mixer/InputMix', 13, 0],
145             self.sldIMixADAT14R: ['/Mixer/InputMix', 13, 1],
146             self.sldIMixADAT15L: ['/Mixer/InputMix', 14, 0],
147             self.sldIMixADAT15R: ['/Mixer/InputMix', 14, 1],
148             self.sldIMixADAT16L: ['/Mixer/InputMix', 15, 0],
149             self.sldIMixADAT16R: ['/Mixer/InputMix', 15, 1],
150             self.sldIMixADAT17L: ['/Mixer/InputMix', 16, 0],
151             self.sldIMixADAT17R: ['/Mixer/InputMix', 16, 1],
152             self.sldIMixADAT18L: ['/Mixer/InputMix', 17, 0],
153             self.sldIMixADAT18R: ['/Mixer/InputMix', 17, 1],
154             self.sldIMixADAT21L: ['/Mixer/InputMix', 18, 0],
155             self.sldIMixADAT21R: ['/Mixer/InputMix', 18, 1],
156             self.sldIMixADAT22L: ['/Mixer/InputMix', 19, 0],
157             self.sldIMixADAT22R: ['/Mixer/InputMix', 19, 1],
158             self.sldIMixADAT23L: ['/Mixer/InputMix', 20, 0],
159             self.sldIMixADAT23R: ['/Mixer/InputMix', 20, 1],
160             self.sldIMixADAT24L: ['/Mixer/InputMix', 21, 0],
161             self.sldIMixADAT24R: ['/Mixer/InputMix', 21, 1],
162             self.sldIMixADAT25L: ['/Mixer/InputMix', 22, 0],
163             self.sldIMixADAT25R: ['/Mixer/InputMix', 22, 1],
164             self.sldIMixADAT26L: ['/Mixer/InputMix', 23, 0],
165             self.sldIMixADAT26R: ['/Mixer/InputMix', 23, 1],
166             self.sldIMixADAT27L: ['/Mixer/InputMix', 24, 0],
167             self.sldIMixADAT27R: ['/Mixer/InputMix', 24, 1],
168             self.sldIMixADAT28L: ['/Mixer/InputMix', 25, 0],
169             self.sldIMixADAT28R: ['/Mixer/InputMix', 25, 1],
170            
171             self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
172             self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
173             self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
174             self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
175             self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
176             self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
177             self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
178             self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
179             self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
180             self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
181            
182             self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
183             self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
184             self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
185             self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
186             self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
187             self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
188             self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
189             self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
190            
191             self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
192             self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
193             self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
194             self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
195             self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
196             self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
197             self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
198             self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
199             self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
200             self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
201             }
202
203
204         self.SelectorControls={
205             # control elements
206             self.chkInsert1: ['/Control/Insert1'],
207             self.chkInsert2: ['/Control/Insert2'],
208             self.chkPhantom14: ['/Control/Phantom_1to4'],
209             self.chkPhantom58: ['/Control/Phantom_5to8'],
210             self.chkAC3: ['/Control/AC3pass'],
211             self.chkMidiThru: ['/Control/MidiTru'],
212             self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
213             #self.chkEnableADAT1: ['/Control/EnableAdat1'],
214             #self.chkEnableADAT2: ['/Control/EnableAdat2'],
215             #self.chkEnableSPDIF1: ['/Control/EnableSPDIF1'],
216             self.chkMidiEnable: ['/Control/MIDIEnable'],
217             self.chkAdatDisable: ['/Control/ADATDisable'],
218             # Mixer switches
219             self.chkMute12: ['/Mixer/Out12Mute', [self.chkHwCtrl12]],
220             self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
221             self.chkPad12: ['/Mixer/Out12Pad'],
222             self.chkDim12: ['/Mixer/Out12Dim'],
223             self.chkMute34: ['/Mixer/Out34Mute', [self.chkHwCtrl34]],
224             self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
225             self.chkPad34: ['/Mixer/Out34Pad'],
226             self.chkDim34: ['/Mixer/Out34Dim'],
227             self.chkMute56: ['/Mixer/Out56Mute', [self.chkHwCtrl56]],
228             self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
229             self.chkPad56: ['/Mixer/Out56Pad'],
230             self.chkDim56: ['/Mixer/Out56Dim'],
231             self.chkMute78: ['/Mixer/Out78Mute', [self.chkHwCtrl78]],
232             self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
233             self.chkPad78: ['/Mixer/Out78Pad'],
234             self.chkDim78: ['/Mixer/Out78Dim'],
235             # direct monitoring
236             self.chkMonitor1: ['/Mixer/DirectMonitorCH1'],
237             self.chkMonitor2: ['/Mixer/DirectMonitorCH2'],
238             self.chkMonitor3: ['/Mixer/DirectMonitorCH3'],
239             self.chkMonitor4: ['/Mixer/DirectMonitorCH4'],
240             self.chkMonitor5: ['/Mixer/DirectMonitorCH5'],
241             self.chkMonitor6: ['/Mixer/DirectMonitorCH6'],
242             self.chkMonitor7: ['/Mixer/DirectMonitorCH7'],
243             self.chkMonitor8: ['/Mixer/DirectMonitorCH8'],
244         }
245
246         self.VolumeControlsLowRes={
247             self.sldOut12Level:      ['/Mixer/Out12Level'],
248             self.sldOut34Level:      ['/Mixer/Out34Level'],
249             self.sldOut56Level:      ['/Mixer/Out56Level'],
250             self.sldOut78Level:      ['/Mixer/Out78Level'],
251         }
252
253         self.TriggerButtonControls={
254             self.btnReboot:        ['/Control/Reboot'],
255             self.btnIdentify:      ['/Control/FlashLed'],
256             self.btnSaveSettings:  ['/Control/SaveSettings'],
257         }
258
259         self.TextControls={
260         }
261
262         self.saveTextControls={
263         }
264
265         self.ComboControls={
266             self.comboStandalone:        ['/Control/StandaloneConfig'],
267         }
268
269     def updateMatrixVolume(self,a0):
270         SaffireMixerBase.updateMatrixVolume(self,a0)
271     def updateLowResVolume(self,a0):
272         SaffireMixerBase.updateLowResVolume(self,a0)
273     def updateSelector(self,a0):
274         SaffireMixerBase.updateSelector(self,a0)
275     def triggerButton(self):
276         SaffireMixerBase.triggerButton(self)
277     def saveText(self):
278         SaffireMixerBase.saveText(self)
279     def initCombo(self, combo):
280         SaffireMixerBase.initCombo(self,combo)
281     def selectCombo(self, mode):
282         SaffireMixerBase.selectCombo(self,mode)
283
284     def updateValues(self):
285         for i in range(self.tabInputMix.count()):
286             self.tabInputMix.setTabEnabled(i, True)
287
288         if not self.my_parent.have_adat:
289             for i in range(self.tabInputMix.count()):
290                 page = self.tabInputMix.widget(i)
291                 name = page.objectName()
292                 if name[0:4] == "adat":
293                     self.tabInputMix.setTabEnabled(i, False)
294                 else:
295                     self.tabInputMix.setTabEnabled(i, True)
296
297         self.tabInputMix.setCurrentWidget(self.tabInputMix.widget(0))
298         SaffireMixerBase.updateValues(self)
299
300     def polledUpdate(self):
301         #log.debug("polled update (large)")
302         self.polledUpdateHwCtrl(self.chkHwCtrl12, self.sldOut12Level)
303         self.polledUpdateHwCtrl(self.chkHwCtrl34, self.sldOut34Level)
304         self.polledUpdateHwCtrl(self.chkHwCtrl56, self.sldOut56Level)
305         self.polledUpdateHwCtrl(self.chkHwCtrl78, self.sldOut78Level)
306
307     def polledUpdateHwCtrl(self, selector, volctrl):
308         state = selector.isChecked()
309         if state:
310             self.polledUpdateVolumeLowRes('/Mixer/MonitorDial', volctrl, 2)
311             volctrl.setEnabled(False)
312         else:
313             volctrl.setEnabled(True)
314
315 class SaffireProMixerSmall(QWidget, Ui_SaffireProMixerSmallUI, SaffireMixerBase):
316     def __init__(self,parent = None):
317         self.my_parent = parent
318         QWidget.__init__(self,parent)
319         SaffireMixerBase.__init__(self)
320         self.setupUi(self)
321         log.debug("Init small Saffire Pro mixer window")
322
323         self.VolumeControls={
324
325             self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
326             self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
327             self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
328             self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
329             self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
330             self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
331             self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
332             self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
333             self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
334             self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
335            
336             self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
337             self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
338             self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
339             self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
340             self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
341             self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
342             self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
343             self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
344            
345             self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
346             self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
347             self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
348             self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
349             self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
350             self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
351             self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
352             self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
353             self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
354             self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
355             }
356
357
358         self.SelectorControls={
359             # control elements
360             self.chkInsert1: ['/Control/Insert1'],
361             self.chkInsert2: ['/Control/Insert2'],
362             self.chkPhantom14: ['/Control/Phantom_1to4'],
363             self.chkPhantom58: ['/Control/Phantom_5to8'],
364             self.chkAC3: ['/Control/AC3pass'],
365             self.chkMidiThru: ['/Control/MidiTru'],
366             self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
367             #self.chkEnableADAT1: ['/Control/EnableAdat1'],
368             #self.chkEnableADAT2: ['/Control/EnableAdat2'],
369             #self.chkEnableSPDIF1: ['/Control/EnableSPDIF1'],
370             self.chkMidiEnable: ['/Control/MIDIEnable'],
371             self.chkAdatDisable: ['/Control/ADATDisable'],
372             # Mixer switches
373             self.chkMute12: ['/Mixer/Out12Mute'],
374             self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
375             self.chkPad12: ['/Mixer/Out12Pad'],
376             self.chkDim12: ['/Mixer/Out12Dim'],
377             self.chkMute34: ['/Mixer/Out34Mute'],
378             self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
379             self.chkPad34: ['/Mixer/Out34Pad'],
380             self.chkDim34: ['/Mixer/Out34Dim'],
381             self.chkMute56: ['/Mixer/Out56Mute'],
382             self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
383             self.chkPad56: ['/Mixer/Out56Pad'],
384             self.chkDim56: ['/Mixer/Out56Dim'],
385             self.chkMute78: ['/Mixer/Out78Mute'],
386             self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
387             self.chkPad78: ['/Mixer/Out78Pad'],
388             self.chkDim78: ['/Mixer/Out78Dim'],
389             # direct monitoring
390             self.chkMonitor1: ['/Mixer/DirectMonitorCH1'],
391             self.chkMonitor2: ['/Mixer/DirectMonitorCH2'],
392             self.chkMonitor3: ['/Mixer/DirectMonitorCH3'],
393             self.chkMonitor4: ['/Mixer/DirectMonitorCH4'],
394             self.chkMonitor5: ['/Mixer/DirectMonitorCH5'],
395             self.chkMonitor6: ['/Mixer/DirectMonitorCH6'],
396             self.chkMonitor7: ['/Mixer/DirectMonitorCH7'],
397             self.chkMonitor8: ['/Mixer/DirectMonitorCH8'],
398         }
399
400         self.VolumeControlsLowRes={
401             self.sldOut12Level:      ['/Mixer/Out12Level'],
402             self.sldOut34Level:      ['/Mixer/Out34Level'],
403             self.sldOut56Level:      ['/Mixer/Out56Level'],
404             self.sldOut78Level:      ['/Mixer/Out78Level'],
405         }
406
407         self.TriggerButtonControls={
408             self.btnReboot:        ['/Control/Reboot'],
409             self.btnIdentify:      ['/Control/FlashLed'],
410             self.btnSaveSettings:  ['/Control/SaveSettings'],
411         }
412
413         self.TextControls={
414         }
415
416         self.saveTextControls={
417         }
418
419         self.ComboControls={
420             self.comboStandalone:        ['/Control/StandaloneConfig'],
421         }
422
423     def updateMatrixVolume(self,a0):
424         SaffireMixerBase.updateMatrixVolume(self,a0)
425     def updateLowResVolume(self,a0):
426         SaffireMixerBase.updateLowResVolume(self,a0)
427     def updateSelector(self,a0):
428         SaffireMixerBase.updateSelector(self,a0)
429     def triggerButton(self):
430         SaffireMixerBase.triggerButton(self)
431     def saveText(self):
432         SaffireMixerBase.saveText(self)
433     def initCombo(self, combo):
434         SaffireMixerBase.initCombo(self,combo)
435     def selectCombo(self, mode):
436         SaffireMixerBase.selectCombo(self,mode)
437
438     def updateValues(self):
439         SaffireMixerBase.updateValues(self)
440
441     def polledUpdate(self):
442         #log.debug("polled update (small)")
443         self.polledUpdateHwCtrl(self.chkHwCtrl12, self.sldOut12Level)
444         self.polledUpdateHwCtrl(self.chkHwCtrl34, self.sldOut34Level)
445         self.polledUpdateHwCtrl(self.chkHwCtrl56, self.sldOut56Level)
446         self.polledUpdateHwCtrl(self.chkHwCtrl78, self.sldOut78Level)
447
448     def polledUpdateHwCtrl(self, selector, volctrl):
449         state = selector.isChecked()
450         if state:
451             self.polledUpdateVolumeLowRes('/Mixer/MonitorDial', volctrl, 2)
452             volctrl.setEnabled(False)
453         else:
454             volctrl.setEnabled(True)
Note: See TracBrowser for help on using the browser.