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

Revision 684, 10.5 kB (checked in by ppalmers, 15 years ago)

- extend the saffire pro mixer

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