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

Revision 1107, 12.8 kB (checked in by ppalmers, 14 years ago)

attempt to implement direct monitoring control and digital channel enable for saffire pro

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_saffireproui import *
25
26 class SaffireProMixer(SaffireProMixerUI):
27     def __init__(self,parent = None,name = None,fl = 0):
28         SaffireProMixerUI.__init__(self,parent,name,fl)
29
30     def updateMatrixVolume(self,a0):
31         sender = self.sender()
32         vol = 0x7FFF-a0
33         print "set %s %d %d to %d" % (
34                     self.VolumeControls[sender][0],
35                     self.VolumeControls[sender][1],
36                     self.VolumeControls[sender][2],
37                     vol)
38         self.hw.setMatrixMixerValue(self.VolumeControls[sender][0],
39                                     self.VolumeControls[sender][1],
40                                     self.VolumeControls[sender][2],
41                                     vol)
42     def updateLowResVolume(self,a0):
43         sender = self.sender()
44         vol = a0
45         print "set %s to %d" % (
46                     self.VolumeControlsLowRes[sender][0],
47                     vol)
48         self.hw.setDiscrete(self.VolumeControlsLowRes[sender][0], vol)
49
50     def updateSelector(self,a0):
51         sender = self.sender()
52         if a0:
53             state = 1
54         else:
55             state = 0
56         print "set %s to %d" % (
57                     self.SelectorControls[sender][0],
58                     state)
59         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
60
61     def triggerButton(self):
62         sender = self.sender()
63         print "trigger %s" % (
64                     self.TriggerButtonControls[sender][0])
65         self.hw.setDiscrete(self.TriggerButtonControls[sender][0], 1)
66
67     def saveText(self):
68         sender = self.sender()
69         textbox = self.saveTextControls[sender][0]
70         print "save %s" % (
71                     textbox.text().ascii())
72         self.hw.setText(self.TextControls[textbox][0], textbox.text().ascii())
73
74     def init(self):
75             print "Init Saffire Pro mixer window"
76
77             self.VolumeControls={
78                 self.sldIMixAnalog1L: ['/Mixer/InputMix', 0, 0],
79                 self.sldIMixAnalog1R: ['/Mixer/InputMix', 0, 1],
80                 self.sldIMixAnalog2L: ['/Mixer/InputMix', 1, 0],
81                 self.sldIMixAnalog2R: ['/Mixer/InputMix', 1, 1],
82                 self.sldIMixAnalog3L: ['/Mixer/InputMix', 2, 0],
83                 self.sldIMixAnalog3R: ['/Mixer/InputMix', 2, 1],
84                 self.sldIMixAnalog4L: ['/Mixer/InputMix', 3, 0],
85                 self.sldIMixAnalog4R: ['/Mixer/InputMix', 3, 1],
86                 self.sldIMixAnalog5L: ['/Mixer/InputMix', 4, 0],
87                 self.sldIMixAnalog5R: ['/Mixer/InputMix', 4, 1],
88                 self.sldIMixAnalog6L: ['/Mixer/InputMix', 5, 0],
89                 self.sldIMixAnalog6R: ['/Mixer/InputMix', 5, 1],
90                 self.sldIMixAnalog7L: ['/Mixer/InputMix', 6, 0],
91                 self.sldIMixAnalog7R: ['/Mixer/InputMix', 6, 1],
92                 self.sldIMixAnalog8L: ['/Mixer/InputMix', 7, 0],
93                 self.sldIMixAnalog8R: ['/Mixer/InputMix', 7, 1],
94                 self.sldIMixAnalog9L: ['/Mixer/InputMix', 8, 0],
95                 self.sldIMixAnalog9R: ['/Mixer/InputMix', 8, 1],
96                 self.sldIMixAnalog10L: ['/Mixer/InputMix', 9, 0],
97                 self.sldIMixAnalog10R: ['/Mixer/InputMix', 9, 1],
98                 self.sldIMixADAT11L: ['/Mixer/InputMix', 10, 0],
99                 self.sldIMixADAT11R: ['/Mixer/InputMix', 10, 1],
100                 self.sldIMixADAT12L: ['/Mixer/InputMix', 11, 0],
101                 self.sldIMixADAT12R: ['/Mixer/InputMix', 11, 1],
102                 self.sldIMixADAT13L: ['/Mixer/InputMix', 12, 0],
103                 self.sldIMixADAT13R: ['/Mixer/InputMix', 12, 1],
104                 self.sldIMixADAT14L: ['/Mixer/InputMix', 13, 0],
105                 self.sldIMixADAT14R: ['/Mixer/InputMix', 13, 1],
106                 self.sldIMixADAT15L: ['/Mixer/InputMix', 14, 0],
107                 self.sldIMixADAT15R: ['/Mixer/InputMix', 14, 1],
108                 self.sldIMixADAT16L: ['/Mixer/InputMix', 15, 0],
109                 self.sldIMixADAT16R: ['/Mixer/InputMix', 15, 1],
110                 self.sldIMixADAT17L: ['/Mixer/InputMix', 16, 0],
111                 self.sldIMixADAT17R: ['/Mixer/InputMix', 16, 1],
112                 self.sldIMixADAT18L: ['/Mixer/InputMix', 17, 0],
113                 self.sldIMixADAT18R: ['/Mixer/InputMix', 17, 1],
114                 self.sldIMixADAT21L: ['/Mixer/InputMix', 18, 0],
115                 self.sldIMixADAT21R: ['/Mixer/InputMix', 18, 1],
116                 self.sldIMixADAT22L: ['/Mixer/InputMix', 19, 0],
117                 self.sldIMixADAT22R: ['/Mixer/InputMix', 19, 1],
118                 self.sldIMixADAT23L: ['/Mixer/InputMix', 20, 0],
119                 self.sldIMixADAT23R: ['/Mixer/InputMix', 20, 1],
120                 self.sldIMixADAT24L: ['/Mixer/InputMix', 21, 0],
121                 self.sldIMixADAT24R: ['/Mixer/InputMix', 21, 1],
122                 self.sldIMixADAT25L: ['/Mixer/InputMix', 22, 0],
123                 self.sldIMixADAT25R: ['/Mixer/InputMix', 22, 1],
124                 self.sldIMixADAT26L: ['/Mixer/InputMix', 23, 0],
125                 self.sldIMixADAT26R: ['/Mixer/InputMix', 23, 1],
126                 self.sldIMixADAT27L: ['/Mixer/InputMix', 24, 0],
127                 self.sldIMixADAT27R: ['/Mixer/InputMix', 24, 1],
128                 self.sldIMixADAT28L: ['/Mixer/InputMix', 25, 0],
129                 self.sldIMixADAT28R: ['/Mixer/InputMix', 25, 1],
130                
131                 self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
132                 self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
133                 self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
134                 self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
135                 self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
136                 self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
137                 self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
138                 self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
139                 self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
140                 self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
141                
142                 self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
143                 self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
144                 self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
145                 self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
146                 self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
147                 self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
148                 self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
149                 self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
150                
151                 self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
152                 self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
153                 self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
154                 self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
155                 self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
156                 self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
157                 self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
158                 self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
159                 self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
160                 self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
161                 }
162
163
164             self.SelectorControls={
165                 # control elements
166                 self.chkInsert1: ['/Control/Insert1'],
167                 self.chkInsert2: ['/Control/Insert2'],
168                 self.chkPhantom14: ['/Control/Phantom_1to4'],
169                 self.chkPhantom58: ['/Control/Phantom_5to8'],
170                 self.chkAC3: ['/Control/AC3pass'],
171                 self.chkMidiThru: ['/Control/MidiTru'],
172                 self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
173                 self.chkEnableADAT1: ['/Control/EnableAdat1'],
174                 self.chkEnableADAT2: ['/Control/EnableAdat2'],
175                 self.chkEnableSPDIF1: ['/Control/EnableSPDIF1'],
176                 # Mixer switches
177                 self.chkMute12: ['/Mixer/Out12Mute'],
178                 self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
179                 self.chkPad12: ['/Mixer/Out12Pad'],
180                 self.chkDim12: ['/Mixer/Out12Dim'],
181                 self.chkMute34: ['/Mixer/Out34Mute'],
182                 self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
183                 self.chkPad34: ['/Mixer/Out34Pad'],
184                 self.chkDim34: ['/Mixer/Out34Dim'],
185                 self.chkMute56: ['/Mixer/Out56Mute'],
186                 self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
187                 self.chkPad56: ['/Mixer/Out56Pad'],
188                 self.chkDim56: ['/Mixer/Out56Dim'],
189                 self.chkMute78: ['/Mixer/Out78Mute'],
190                 self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
191                 self.chkPad78: ['/Mixer/Out78Pad'],
192                 self.chkDim78: ['/Mixer/Out78Dim'],
193                 # direct monitoring
194                 self.chkMonitor1: ['/Mixer/DirectMonitorCH1'],
195                 self.chkMonitor2: ['/Mixer/DirectMonitorCH2'],
196                 self.chkMonitor3: ['/Mixer/DirectMonitorCH3'],
197                 self.chkMonitor4: ['/Mixer/DirectMonitorCH4'],
198                 self.chkMonitor5: ['/Mixer/DirectMonitorCH5'],
199                 self.chkMonitor6: ['/Mixer/DirectMonitorCH6'],
200                 self.chkMonitor7: ['/Mixer/DirectMonitorCH7'],
201                 self.chkMonitor8: ['/Mixer/DirectMonitorCH8'],
202             }
203
204             self.VolumeControlsLowRes={
205                 self.sldOut12Level:      ['/Mixer/Out12Level'],
206                 self.sldOut34Level:      ['/Mixer/Out34Level'],
207                 self.sldOut56Level:      ['/Mixer/Out56Level'],
208                 self.sldOut78Level:      ['/Mixer/Out78Level'],
209             }
210
211             self.TriggerButtonControls={
212                 self.btnReboot:        ['/Control/Reboot'],
213                 self.btnIdentify:      ['/Control/FlashLed'],
214                 self.btnSaveSettings:  ['/Control/SaveSettings'],
215             }
216
217             self.TextControls={
218             }
219             self.saveTextControls={
220             }
221
222     def updateValues(self):
223         for ctrl, info in self.VolumeControls.iteritems():
224             vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
225                                                 self.VolumeControls[ctrl][1],
226                                                 self.VolumeControls[ctrl][2])
227
228             print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
229             ctrl.setValue(0x7FFF-vol)
230
231         for ctrl, info in self.VolumeControlsLowRes.iteritems():
232             vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
233
234             print "%s volume is %d" % (ctrl.name() , vol)
235             ctrl.setValue(vol)
236
237         for ctrl, info in self.SelectorControls.iteritems():
238             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
239             print "%s state is %d" % (ctrl.name() , state)
240             if state:
241                 ctrl.setChecked(True)
242             else:
243                 ctrl.setChecked(False)
244
245         for ctrl, info in self.TriggerButtonControls.iteritems():
246             pass
247
248         for ctrl, info in self.TextControls.iteritems():
249             text = self.hw.getText(self.TextControls[ctrl][0])
250             print "%s text is %s" % (ctrl.name() , text)
251             ctrl.setText(text)
252
253     def initValues(self):
254         self.updateValues()
255         for ctrl, info in self.VolumeControls.iteritems():
256             # connect the UI element
257             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
258
259         for ctrl, info in self.VolumeControlsLowRes.iteritems():
260             # connect the UI element
261             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
262
263         for ctrl, info in self.SelectorControls.iteritems():
264             # connect the UI element
265             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
266
267         for ctrl, info in self.TriggerButtonControls.iteritems():
268             # connect the UI element
269             QObject.connect(ctrl,SIGNAL('clicked()'),self.triggerButton)
270
271         for ctrl, info in self.saveTextControls.iteritems():
272             # connect the UI element
273             QObject.connect(ctrl,SIGNAL('clicked()'), self.saveText)
Note: See TracBrowser for help on using the browser.