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

Revision 864, 11.3 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

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,modal = 0,fl = 0):
28         SaffireProMixerUI.__init__(self,parent,name,modal,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 init(self):
68             print "Init Saffire Pro mixer window"
69
70             self.VolumeControls={
71                 self.sldIMixAnalog1L: ['/Mixer/InputMix', 0, 0],
72                 self.sldIMixAnalog1R: ['/Mixer/InputMix', 0, 1],
73                 self.sldIMixAnalog2L: ['/Mixer/InputMix', 1, 0],
74                 self.sldIMixAnalog2R: ['/Mixer/InputMix', 1, 1],
75                 self.sldIMixAnalog3L: ['/Mixer/InputMix', 2, 0],
76                 self.sldIMixAnalog3R: ['/Mixer/InputMix', 2, 1],
77                 self.sldIMixAnalog4L: ['/Mixer/InputMix', 3, 0],
78                 self.sldIMixAnalog4R: ['/Mixer/InputMix', 3, 1],
79                 self.sldIMixAnalog5L: ['/Mixer/InputMix', 4, 0],
80                 self.sldIMixAnalog5R: ['/Mixer/InputMix', 4, 1],
81                 self.sldIMixAnalog6L: ['/Mixer/InputMix', 5, 0],
82                 self.sldIMixAnalog6R: ['/Mixer/InputMix', 5, 1],
83                 self.sldIMixAnalog7L: ['/Mixer/InputMix', 6, 0],
84                 self.sldIMixAnalog7R: ['/Mixer/InputMix', 6, 1],
85                 self.sldIMixAnalog8L: ['/Mixer/InputMix', 7, 0],
86                 self.sldIMixAnalog8R: ['/Mixer/InputMix', 7, 1],
87                 self.sldIMixAnalog9L: ['/Mixer/InputMix', 8, 0],
88                 self.sldIMixAnalog9R: ['/Mixer/InputMix', 8, 1],
89                 self.sldIMixAnalog10L: ['/Mixer/InputMix', 9, 0],
90                 self.sldIMixAnalog10R: ['/Mixer/InputMix', 9, 1],
91                 self.sldIMixADAT11L: ['/Mixer/InputMix', 10, 0],
92                 self.sldIMixADAT11R: ['/Mixer/InputMix', 10, 1],
93                 self.sldIMixADAT12L: ['/Mixer/InputMix', 11, 0],
94                 self.sldIMixADAT12R: ['/Mixer/InputMix', 11, 1],
95                 self.sldIMixADAT13L: ['/Mixer/InputMix', 12, 0],
96                 self.sldIMixADAT13R: ['/Mixer/InputMix', 12, 1],
97                 self.sldIMixADAT14L: ['/Mixer/InputMix', 13, 0],
98                 self.sldIMixADAT14R: ['/Mixer/InputMix', 13, 1],
99                 self.sldIMixADAT15L: ['/Mixer/InputMix', 14, 0],
100                 self.sldIMixADAT15R: ['/Mixer/InputMix', 14, 1],
101                 self.sldIMixADAT16L: ['/Mixer/InputMix', 15, 0],
102                 self.sldIMixADAT16R: ['/Mixer/InputMix', 15, 1],
103                 self.sldIMixADAT17L: ['/Mixer/InputMix', 16, 0],
104                 self.sldIMixADAT17R: ['/Mixer/InputMix', 16, 1],
105                 self.sldIMixADAT18L: ['/Mixer/InputMix', 17, 0],
106                 self.sldIMixADAT18R: ['/Mixer/InputMix', 17, 1],
107                 self.sldIMixADAT21L: ['/Mixer/InputMix', 18, 0],
108                 self.sldIMixADAT21R: ['/Mixer/InputMix', 18, 1],
109                 self.sldIMixADAT22L: ['/Mixer/InputMix', 19, 0],
110                 self.sldIMixADAT22R: ['/Mixer/InputMix', 19, 1],
111                 self.sldIMixADAT23L: ['/Mixer/InputMix', 20, 0],
112                 self.sldIMixADAT23R: ['/Mixer/InputMix', 20, 1],
113                 self.sldIMixADAT24L: ['/Mixer/InputMix', 21, 0],
114                 self.sldIMixADAT24R: ['/Mixer/InputMix', 21, 1],
115                 self.sldIMixADAT25L: ['/Mixer/InputMix', 22, 0],
116                 self.sldIMixADAT25R: ['/Mixer/InputMix', 22, 1],
117                 self.sldIMixADAT26L: ['/Mixer/InputMix', 23, 0],
118                 self.sldIMixADAT26R: ['/Mixer/InputMix', 23, 1],
119                 self.sldIMixADAT27L: ['/Mixer/InputMix', 24, 0],
120                 self.sldIMixADAT27R: ['/Mixer/InputMix', 24, 1],
121                 self.sldIMixADAT28L: ['/Mixer/InputMix', 25, 0],
122                 self.sldIMixADAT28R: ['/Mixer/InputMix', 25, 1],
123                
124                 self.sldOMixPC1O1: ['/Mixer/OutputMix', 0, 0],
125                 self.sldOMixPC2O2: ['/Mixer/OutputMix', 1, 1],
126                 self.sldOMixPC3O3: ['/Mixer/OutputMix', 2, 2],
127                 self.sldOMixPC4O4: ['/Mixer/OutputMix', 3, 3],
128                 self.sldOMixPC5O5: ['/Mixer/OutputMix', 4, 4],
129                 self.sldOMixPC6O6: ['/Mixer/OutputMix', 5, 5],
130                 self.sldOMixPC7O7: ['/Mixer/OutputMix', 6, 6],
131                 self.sldOMixPC8O8: ['/Mixer/OutputMix', 7, 7],
132                 self.sldOMixPC9O9: ['/Mixer/OutputMix', 8, 8],
133                 self.sldOMixPC10O10: ['/Mixer/OutputMix', 9, 9],
134                
135                 self.sldOMixPC1O3: ['/Mixer/OutputMix', 0, 2],
136                 self.sldOMixPC2O4: ['/Mixer/OutputMix', 1, 3],
137                 self.sldOMixPC1O5: ['/Mixer/OutputMix', 0, 4],
138                 self.sldOMixPC2O6: ['/Mixer/OutputMix', 1, 5],
139                 self.sldOMixPC1O7: ['/Mixer/OutputMix', 0, 6],
140                 self.sldOMixPC2O8: ['/Mixer/OutputMix', 1, 7],
141                 self.sldOMixPC1O9: ['/Mixer/OutputMix', 0, 8],
142                 self.sldOMixPC2O10: ['/Mixer/OutputMix', 1, 9],
143                
144                 self.sldOMixIMixO1: ['/Mixer/OutputMix', 10, 0],
145                 self.sldOMixIMixO2: ['/Mixer/OutputMix', 11, 1],
146                 self.sldOMixIMixO3: ['/Mixer/OutputMix', 10, 2],
147                 self.sldOMixIMixO4: ['/Mixer/OutputMix', 11, 3],
148                 self.sldOMixIMixO5: ['/Mixer/OutputMix', 10, 4],
149                 self.sldOMixIMixO6: ['/Mixer/OutputMix', 11, 5],
150                 self.sldOMixIMixO7: ['/Mixer/OutputMix', 10, 6],
151                 self.sldOMixIMixO8: ['/Mixer/OutputMix', 11, 7],
152                 self.sldOMixIMixO9: ['/Mixer/OutputMix', 10, 8],
153                 self.sldOMixIMixO10: ['/Mixer/OutputMix', 11, 9],
154                 }
155
156
157             self.SelectorControls={
158                 # control elements
159                 self.chkInsert1: ['/Control/Insert1'],
160                 self.chkInsert2: ['/Control/Insert2'],
161                 self.chkPhantom14: ['/Control/Phantom_1to4'],
162                 self.chkPhantom58: ['/Control/Phantom_5to8'],
163                 self.chkAC3: ['/Control/AC3pass'],
164                 self.chkMidiThru: ['/Control/MidiTru'],
165                 self.chkHighVoltage: ['/Control/UseHighVoltageRail'],
166                 # Mixer switches
167                 self.chkMute12: ['/Mixer/Out12Mute'],
168                 self.chkHwCtrl12: ['/Mixer/Out12HwCtrl'],
169                 self.chkPad12: ['/Mixer/Out12Pad'],
170                 self.chkDim12: ['/Mixer/Out12Dim'],
171                 self.chkMute34: ['/Mixer/Out34Mute'],
172                 self.chkHwCtrl34: ['/Mixer/Out34HwCtrl'],
173                 self.chkPad34: ['/Mixer/Out34Pad'],
174                 self.chkDim34: ['/Mixer/Out34Dim'],
175                 self.chkMute56: ['/Mixer/Out56Mute'],
176                 self.chkHwCtrl56: ['/Mixer/Out56HwCtrl'],
177                 self.chkPad56: ['/Mixer/Out56Pad'],
178                 self.chkDim56: ['/Mixer/Out56Dim'],
179                 self.chkMute78: ['/Mixer/Out78Mute'],
180                 self.chkHwCtrl78: ['/Mixer/Out78HwCtrl'],
181                 self.chkPad78: ['/Mixer/Out78Pad'],
182                 self.chkDim78: ['/Mixer/Out78Dim'],
183             }
184
185             self.VolumeControlsLowRes={
186                 self.sldOut12Level:      ['/Mixer/Out12Level'],
187                 self.sldOut34Level:      ['/Mixer/Out34Level'],
188                 self.sldOut56Level:      ['/Mixer/Out56Level'],
189                 self.sldOut78Level:      ['/Mixer/Out78Level'],
190             }
191
192             self.TriggerButtonControls={
193                 self.btnReboot:      ['/Control/Reboot'],
194                 self.btnIdentify:    ['/Control/FlashLed'],
195             }
196
197     def updateValues(self):
198         for ctrl, info in self.VolumeControls.iteritems():
199             vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
200                                                 self.VolumeControls[ctrl][1],
201                                                 self.VolumeControls[ctrl][2])
202
203             print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
204             ctrl.setValue(0x7FFF-vol)
205
206         for ctrl, info in self.VolumeControlsLowRes.iteritems():
207             vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
208
209             print "%s volume is %d" % (ctrl.name() , vol)
210             ctrl.setValue(vol)
211
212         for ctrl, info in self.SelectorControls.iteritems():
213             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
214             print "%s state is %d" % (ctrl.name() , state)
215             if state:
216                 ctrl.setChecked(True)
217             else:
218                 ctrl.setChecked(False)
219
220         for ctrl, info in self.TriggerButtonControls.iteritems():
221             pass
222
223     def initValues(self):
224         self.updateValues()
225         for ctrl, info in self.VolumeControls.iteritems():
226             # connect the UI element
227             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
228
229         for ctrl, info in self.VolumeControlsLowRes.iteritems():
230             # connect the UI element
231             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
232
233         for ctrl, info in self.SelectorControls.iteritems():
234             # connect the UI element
235             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
236
237         for ctrl, info in self.TriggerButtonControls.iteritems():
238             # connect the UI element
239             QObject.connect(ctrl,SIGNAL('clicked()'),self.triggerButton)
240
Note: See TracBrowser for help on using the browser.