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

Revision 1106, 13.1 kB (checked in by arnonym, 14 years ago)

Not my day. Remove the modal parameter from the arguments.

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                 # Mixer switches
174                 self.chkMute12: ['/Mixer/Out12Mute'],
175                 self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
176                 self.chkPad12: ['/Mixer/Out12Pad'],
177                 self.chkDim12: ['/Mixer/Out12Dim'],
178                 self.chkMute34: ['/Mixer/Out34Mute'],
179                 self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
180                 self.chkPad34: ['/Mixer/Out34Pad'],
181                 self.chkDim34: ['/Mixer/Out34Dim'],
182                 self.chkMute56: ['/Mixer/Out56Mute'],
183                 self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
184                 self.chkPad56: ['/Mixer/Out56Pad'],
185                 self.chkDim56: ['/Mixer/Out56Dim'],
186                 self.chkMute78: ['/Mixer/Out78Mute'],
187                 self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
188                 self.chkPad78: ['/Mixer/Out78Pad'],
189                 self.chkDim78: ['/Mixer/Out78Dim'],
190             }
191
192             self.VolumeControlsLowRes={
193                 self.sldOut12Level:      ['/Mixer/Out12Level'],
194                 self.sldOut34Level:      ['/Mixer/Out34Level'],
195                 self.sldOut56Level:      ['/Mixer/Out56Level'],
196                 self.sldOut78Level:      ['/Mixer/Out78Level'],
197             }
198
199             self.TriggerButtonControls={
200                 self.btnReboot:        ['/Control/Reboot'],
201                 self.btnIdentify:      ['/Control/FlashLed'],
202                 self.btnSaveSettings:  ['/Control/SaveSettings'],
203             }
204
205             self.TextControls={
206                 self.txtDeviceName:        ['/Control/DeviceName'],
207             }
208             self.saveTextControls={
209                 self.btnSaveName:        [self.txtDeviceName],
210             }
211
212     def updateValues(self):
213         for ctrl, info in self.VolumeControls.iteritems():
214             vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
215                                                 self.VolumeControls[ctrl][1],
216                                                 self.VolumeControls[ctrl][2])
217
218             print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
219             ctrl.setValue(0x7FFF-vol)
220
221         for ctrl, info in self.VolumeControlsLowRes.iteritems():
222             vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
223
224             print "%s volume is %d" % (ctrl.name() , vol)
225             ctrl.setValue(vol)
226
227         for ctrl, info in self.SelectorControls.iteritems():
228             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
229             print "%s state is %d" % (ctrl.name() , state)
230             if state:
231                 ctrl.setChecked(True)
232             else:
233                 ctrl.setChecked(False)
234
235         for ctrl, info in self.TriggerButtonControls.iteritems():
236             pass
237
238         for ctrl, info in self.TextControls.iteritems():
239             text = self.hw.getText(self.TextControls[ctrl][0])
240             print "%s text is %s" % (ctrl.name() , text)
241             ctrl.setText(text)
242
243         self.initClockSelector()
244
245     def updateClockSelection(self,a0):
246         #disable the combobox
247         self.comboClockSelect.setEnabled(False)
248         #change the clock source
249         self.clockselect.select(a0)
250         #refresh the clock source selection box
251         self.initClockSelector()
252         #make the box available again
253         self.comboClockSelect.setEnabled(True)
254
255     def initClockSelector(self):
256         self.comboClockSelect.clear()
257         nbsources = self.clockselect.count()
258         for idx in range(nbsources):
259             desc = self.clockselect.getEnumLabel(idx)
260             self.comboClockSelect.insertItem(desc)
261         active_idx = self.clockselect.selected();
262         if active_idx >= 0:
263             self.comboClockSelect.setCurrentItem(active_idx)
264
265     def initValues(self):
266         self.updateValues()
267         for ctrl, info in self.VolumeControls.iteritems():
268             # connect the UI element
269             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
270
271         for ctrl, info in self.VolumeControlsLowRes.iteritems():
272             # connect the UI element
273             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
274
275         for ctrl, info in self.SelectorControls.iteritems():
276             # connect the UI element
277             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
278
279         for ctrl, info in self.TriggerButtonControls.iteritems():
280             # connect the UI element
281             QObject.connect(ctrl,SIGNAL('clicked()'),self.triggerButton)
282
283         for ctrl, info in self.saveTextControls.iteritems():
284             # connect the UI element
285             QObject.connect(ctrl,SIGNAL('clicked()'), self.saveText)
286
287         self.initClockSelector()
288         # connect the clock selector UI element
289         QObject.connect(self.comboClockSelect, SIGNAL('activated(int)'), self.updateClockSelection)
Note: See TracBrowser for help on using the browser.