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

Revision 1336, 13.8 kB (checked in by ppalmers, 16 years ago)

Bring trunk up to date with branches/libffado-2.0:

"""
svn merge -r 1254:1299 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1301:1320 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1322:1323 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1329:HEAD svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
"""

Add getSupportedSamplingFrequencies() to DICE, RME and Metric Halo AvDevices?

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_audiofire_stripui import *
25 from mixer_audiofire_settingsui import *
26
27 class AudioFireMixer(QWidget):
28     def __init__(self,parent = None,name = None,fl = 0):
29         QWidget.__init__(self,parent,name,fl)
30
31     def init(self):
32             print "Init AudioFire mixer window"
33
34     def updateMatrixButton(self,a0):
35         sender = self.sender()
36         if a0:
37             state = 1
38         else:
39             state = 0
40         print "set %s %d %d to %d" % (
41                     self.MatrixButtonControls[sender][0],
42                     self.MatrixButtonControls[sender][1],
43                     self.MatrixButtonControls[sender][2],
44                     state)
45         self.hw.setMatrixMixerValue(self.MatrixButtonControls[sender][0],
46                                     self.MatrixButtonControls[sender][1],
47                                     self.MatrixButtonControls[sender][2],
48                                     state)
49
50     def updateMatrixRotary(self,a0):
51         sender = self.sender()
52         vol = a0
53         print "set %s %d %d to %d" % (
54                     self.MatrixRotaryControls[sender][0],
55                     self.MatrixRotaryControls[sender][1],
56                     self.MatrixRotaryControls[sender][2],
57                     vol)
58         self.hw.setMatrixMixerValue(self.MatrixRotaryControls[sender][0],
59                                     self.MatrixRotaryControls[sender][1],
60                                     self.MatrixRotaryControls[sender][2],
61                                     vol)
62
63     def updateMatrixVolume(self,a0):
64         sender = self.sender()
65         vol = 0x01000000-a0
66         print "set %s %d %d to %d" % (
67                     self.MatrixVolumeControls[sender][0],
68                     self.MatrixVolumeControls[sender][1],
69                     self.MatrixVolumeControls[sender][2],
70                     vol)
71         self.hw.setMatrixMixerValue(self.MatrixVolumeControls[sender][0],
72                                     self.MatrixVolumeControls[sender][1],
73                                     self.MatrixVolumeControls[sender][2],
74                                     vol)
75
76     def updateVolume(self,a0):
77         sender = self.sender()
78         vol = 0x01000000-a0
79         print "set %s to %d" % (
80                     self.VolumeControls[sender][0],
81                     vol)
82         self.hw.setContignuous(self.VolumeControls[sender][0],
83                               vol)
84
85     def updateSelector(self,a0):
86         sender = self.sender()
87         if a0:
88             state = 1
89         else:
90             state = 0
91         print "set %s to %d" % (
92                     self.SelectorControls[sender][0],
93                     state)
94         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
95
96     def updateTrigger(self):
97         sender = self.sender()
98         print "trigger %s" % (self.TriggerControls[sender][0])
99         self.hw.setDiscrete(self.TriggerControls[sender][0], 1)
100
101     def updateSPDIFmodeControl(self,a0):
102         sender = self.sender()
103         if a0:
104             state = 1
105         else:
106             state = 0
107         if state:
108             print "set %s to %d" % (
109                         self.SPDIFmodeControls[sender][0],
110                         self.SPDIFmodeControls[sender][1])
111             self.hw.setDiscrete(self.SPDIFmodeControls[sender][0], self.SPDIFmodeControls[sender][1])
112
113     def buildMixer(self):
114         print "Building mixer"
115         self.MatrixButtonControls={}
116         self.MatrixRotaryControls={}
117         self.MatrixVolumeControls={}
118         self.VolumeControls={}
119         self.SelectorControls={}
120         self.SPDIFmodeControls={}
121         self.TriggerControls={}
122
123         nb_pys_out = self.hw.getDiscrete("/HwInfo/PhysicalAudioOutCount")
124         nb_pys_in = self.hw.getDiscrete("/HwInfo/PhysicalAudioInCount")
125
126         outputtabslayout = QHBoxLayout( self )
127         outputtabs = QTabWidget(self)
128         outputtabslayout.addWidget( outputtabs, 1 )
129
130         for outpair in range(nb_pys_out/2):
131             tab = QWidget( outputtabs )
132             tablayout = QHBoxLayout( tab )
133            
134             grpMonitor = QGroupBox(tab,"grpMonitor")
135             tablayout.addWidget(grpMonitor)
136    
137             grpPlayback = QGroupBox(tab,"grpPlayback")
138             tablayout.addWidget(grpPlayback)
139    
140             grpOutput = QGroupBox(tab,"grpOutput")
141             tablayout.addWidget(grpOutput)
142    
143             grpMonitor.setTitle("Monitor")
144             grpPlayback.setTitle("Playback")
145             grpOutput.setTitle("Output")
146            
147             # monitor controls
148             grpMonitor.setColumnLayout(0,Qt.Vertical)
149             grpMonitor.layout().setSpacing(6)
150             grpMonitor.layout().setMargin(11)
151             grpMonitorLayout = QHBoxLayout(grpMonitor.layout())
152
153             output_id = outpair * 2
154             for inpair in range(nb_pys_in/2):
155                 # create GUI elements
156                 strip = AfMonitorWidget( grpMonitor )
157                 grpMonitorLayout.addWidget( strip, 1 )
158                 input_id = inpair*2
159                 strip.lblName.setText("IN %d/%d" % (input_id+1, input_id+2))
160
161                 # add the elements to the control structure
162
163                 self.MatrixButtonControls[strip.btnMute0] = ['/Mixer/MonitorMute', input_id, output_id]
164                 self.MatrixButtonControls[strip.btnMute1] = ['/Mixer/MonitorMute', input_id + 1, output_id + 1]
165                 self.MatrixButtonControls[strip.btnSolo0] = ['/Mixer/MonitorSolo', input_id, output_id]
166                 self.MatrixButtonControls[strip.btnSolo1] = ['/Mixer/MonitorSolo', input_id + 1, output_id + 1]
167                 self.MatrixRotaryControls[strip.rotPan0]  = ['/Mixer/MonitorPan', input_id, output_id]
168                 self.MatrixRotaryControls[strip.rotPan1]  = ['/Mixer/MonitorPan', input_id + 1, output_id + 1]
169                 self.MatrixVolumeControls[strip.sldGain0]  = ['/Mixer/MonitorGain', input_id, output_id]
170                 self.MatrixVolumeControls[strip.sldGain1]  = ['/Mixer/MonitorGain', input_id + 1, output_id + 1]
171
172             # playback
173             grpPlayback.setColumnLayout(0,Qt.Vertical)
174             grpPlayback.layout().setSpacing(6)
175             grpPlayback.layout().setMargin(11)
176             grpPlaybackLayout = QHBoxLayout(grpPlayback.layout())
177             strip = AfMonitorWidget( grpPlayback )
178             grpPlaybackLayout.addWidget(strip, 1)
179             strip.lblName.setText("Playback %d/%d" % (output_id+1, output_id+2))
180
181             self.VolumeControls[strip.sldGain0] = ["/Mixer/PC%dGain" % (output_id)]
182             self.VolumeControls[strip.sldGain1] = ["/Mixer/PC%dGain" % (output_id+1)]
183             self.SelectorControls[strip.btnMute0] = ["/Mixer/PC%dMute" % (output_id)]
184             self.SelectorControls[strip.btnMute1] = ["/Mixer/PC%dMute" % (output_id+1)]
185             self.SelectorControls[strip.btnSolo0] = ["/Mixer/PC%dSolo" % (output_id)]
186             self.SelectorControls[strip.btnSolo1] = ["/Mixer/PC%dSolo" % (output_id+1)]
187
188             # fix up mixer strip gui
189             strip.rotPan0.hide()
190             strip.rotPan1.hide()
191
192             # output
193             grpOutput.setColumnLayout(0,Qt.Vertical)
194             grpOutput.layout().setSpacing(6)
195             grpOutput.layout().setMargin(11)
196             grpOutputLayout = QHBoxLayout(grpOutput.layout())
197             strip = AfMonitorWidget( grpOutput )
198             grpOutputLayout.addWidget(strip, 1)
199             strip.lblName.setText("Output %d/%d" % (output_id+1, output_id+2))
200
201             self.VolumeControls[strip.sldGain0] = ["/Mixer/OUT%dGain" % (output_id)]
202             self.VolumeControls[strip.sldGain1] = ["/Mixer/OUT%dGain" % (output_id+1)]
203             self.SelectorControls[strip.btnMute0] = ["/Mixer/OUT%dMute" % (output_id)]
204             self.SelectorControls[strip.btnMute1] = ["/Mixer/OUT%dMute" % (output_id+1)]
205             self.SelectorControls[strip.btnSolo0] = ["/Mixer/OUT%dNominal" % (output_id)]
206             self.SelectorControls[strip.btnSolo1] = ["/Mixer/OUT%dNominal" % (output_id+1)]
207
208             # fix up mixer strip gui
209             strip.btnSolo0.setText("Pad")
210             strip.btnSolo1.setText("Pad")
211             strip.rotPan0.hide()
212             strip.rotPan1.hide()
213
214             # add the tab
215             outputtabs.addTab( tab, "OUT %d/%d" % (output_id+1, output_id+2))
216
217         # add an input config tab
218         tab = QWidget( outputtabs )
219         tablayout = QHBoxLayout( tab )
220
221         for inpair in range(nb_pys_in):
222             # create GUI elements
223             print "strip"
224             grpInput = QGroupBox(tab,"grpInput")
225             tablayout.addWidget(grpInput)
226             grpInput.setTitle("IN %d" % (inpair+1))
227
228             grpInput.setColumnLayout(0,Qt.Horizontal)
229             grpInput.layout().setSpacing(6)
230             grpInput.layout().setMargin(11)
231             grpInputLayout = QVBoxLayout(grpInput.layout())
232
233             label = QLabel( grpInput )
234             grpInputLayout.addWidget( label )
235             label.setText("frienlyname %d" % (inpair+1))
236             label.setAlignment(QLabel.AlignCenter)
237
238             btn = QPushButton( grpInput )
239             grpInputLayout.addWidget( btn )
240             btn.setText("Pad")
241             btn.setToggleButton( True )
242             self.SelectorControls[btn] = ["/Mixer/IN%dNominal" % (inpair)]
243
244             spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding)
245             grpInputLayout.addItem(spacer)
246
247         outputtabs.addTab( tab, "INPUT")
248
249         # add an settings tab
250         tab = QWidget( outputtabs )
251         tablayout = QHBoxLayout( tab )
252         outputtabs.addTab( tab, "SETTINGS")
253         settings = AfSettingsWidget( tab )
254
255         has_sw_phantom = self.hw.getDiscrete("/HwInfo/PhantomPower")
256         if has_sw_phantom:
257             self.SelectorControls[settings.btnPhantom] = ["/PhantomPower"]
258         else:
259             settings.btnPhantom.hide()
260
261         self.TriggerControls[settings.btnSaveSettings] = ["/SaveSettings"]
262         self.TriggerControls[settings.btnIdentify] = ["/Identify"]
263
264         self.SPDIFmodeControls[settings.btnConsumer] = ["/SpdifMode", 0]
265         self.SPDIFmodeControls[settings.btnProfessional] = ["/SpdifMode", 1]
266
267     def initValues(self):
268         print "Init values"
269
270         for ctrl, info in self.MatrixVolumeControls.iteritems():
271             vol = self.hw.getMatrixMixerValue(self.MatrixVolumeControls[ctrl][0],
272                                                 self.MatrixVolumeControls[ctrl][1],
273                                                 self.MatrixVolumeControls[ctrl][2])
274
275             print "%s volume is %d" % (ctrl.name() , 0x01000000-vol)
276             ctrl.setValue(0x01000000-vol)
277
278             # connect the UI element
279             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
280
281         for ctrl, info in self.MatrixButtonControls.iteritems():
282             state = self.hw.getMatrixMixerValue(self.MatrixButtonControls[ctrl][0],
283                                                 self.MatrixButtonControls[ctrl][1],
284                                                 self.MatrixButtonControls[ctrl][2])
285
286             print "%s state is %d" % (ctrl.name() , state)
287             if state:
288                 ctrl.setOn(True)
289             else:
290                 ctrl.setOn(False)
291
292             # connect the UI element
293             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateMatrixButton)
294
295         for ctrl, info in self.MatrixRotaryControls.iteritems():
296             vol = self.hw.getMatrixMixerValue(self.MatrixRotaryControls[ctrl][0],
297                                                 self.MatrixRotaryControls[ctrl][1],
298                                                 self.MatrixRotaryControls[ctrl][2])
299
300             print "%s value is %d" % (ctrl.name(), vol)
301             ctrl.setValue(vol)
302
303             # connect the UI element
304             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixRotary)
305
306         for ctrl, info in self.VolumeControls.iteritems():
307             vol = self.hw.getContignuous(self.VolumeControls[ctrl][0])
308
309             print "%s volume is %d" % (ctrl.name() , 0x01000000-vol)
310             ctrl.setValue(0x01000000-vol)
311
312             # connect the UI element
313             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateVolume)
314
315         for ctrl, info in self.SelectorControls.iteritems():
316             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
317             print "%s state is %d" % (ctrl.name() , state)
318             if state:
319                 ctrl.setOn(True)
320             else:
321                 ctrl.setOn(False)
322
323             # connect the UI element
324             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
325
326         for ctrl, info in self.TriggerControls.iteritems():
327             # connect the UI element
328             QObject.connect(ctrl,SIGNAL('clicked()'),self.updateTrigger)
329
330         for ctrl, info in self.SPDIFmodeControls.iteritems():
331             state = self.hw.getDiscrete(self.SPDIFmodeControls[ctrl][0])
332             print "%s state is %d" % (ctrl.name() , state)
333             if state == self.SPDIFmodeControls[ctrl][1]:
334                 ctrl.setOn(True)
335             else:
336                 ctrl.setOn(False)
337
338             # connect the UI element
339             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSPDIFmodeControl)
Note: See TracBrowser for help on using the browser.