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

Revision 1184, 13.5 kB (checked in by ppalmers, 13 years ago)

add some extra saffire pro control elements

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