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

Revision 1085, 11.6 kB (checked in by jwoithe, 16 years ago)

MOTU: Name channel pair control widgets in mixer. Disable channel pair widgets for the moment since they are not implemented.
MOTU: In mixer python glue code, renamed pan object handlers to generic control handlers since they can be used for more than just the pan controls.
Fix minor grammar issues in registration dialog.
In registration module, ensure the ffado configuration directory exists before trying to save information into it. The test is still a bit rough and could be made more robust.
ffadomixer: explicitly set the size of the toplevel tab widget to that of the mixer it contains. Without this for me on Qt 3.3.8 the ffado mixer window is created way too small. The solution is a bit hacky and could possibly do with refinement.
ffadomixer: don't include the generic mixer controls for MOTU devices since they don't give us anything useful yet and could be a source of confusion for users.

Line 
1 #
2 # Copyright (C) 2005-2008 by Pieter Palmers
3 # Copyright (C) 2008 by Jonathan Woithe
4 #
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
7 #
8 # FFADO is based upon FreeBoB.
9 #
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 2 of the License, or
13 # (at your option) version 3 of the License.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 #
23
24 from qt import *
25 from mixer_motuui import *
26
27 class MotuMixer(MotuMixerUI):
28     def __init__(self,parent = None,name = None,modal = 0,fl = 0):
29         MotuMixerUI.__init__(self,parent,name,modal,fl)
30
31     # public slot: channel/mix faders
32     def updateFader(self, a0):
33         sender = self.sender()
34         vol = 128-a0
35         print "setting %s channel/mix fader to %d" % (self.ChannelFaders[sender][0], vol)
36         self.hw.setDiscrete(self.ChannelFaders[sender][0], vol)
37
38     # public slot: a generic multivalue control
39     def updateControl(self, a0):
40         sender = self.sender()
41         val = a0
42         print "setting %s control to %d" % (self.Controls[sender][0], val)
43         self.hw.setDiscrete(self.Controls[sender][0], val)
44
45     # public slot: generic binary switch
46     def updateBinarySwitch(self, a0):
47         sender = self.sender()
48         val=a0
49         print "setting %s switch to %d" % (self.BinarySwitches[sender][0], val)
50         self.hw.setDiscrete(self.BinarySwitches[sender][0], val)
51
52     # public slot: mix destination control
53     def updateMixDest(self, a0):
54         sender = self.sender()
55         dest=a0
56         print "setting %s mix destination to %d" % (self.MixDests[sender][0], dest)
57         self.hw.setDiscrete(self.MixDests[sender][0], dest)
58
59     # public slots: mix output controls
60     def set_mix1_dest(self,a0):
61         self.setMixDest('mix1', a0)
62
63     def setSelector(self,a0,a1):
64         name=a0
65         state = a1
66         print "setting %s state to %d" % (name, state)
67         self.hw.setDiscrete(self.SelectorControls[name][0], state)
68
69     def init(self):
70         print "Init MOTU mixer window"
71
72         self.ChannelFaders={
73             self.mix1ana1_fader: ['/Mixer/Mix1/Ana1_fader'],
74             self.mix1ana2_fader: ['/Mixer/Mix1/Ana2_fader'],
75             self.mix1ana3_fader: ['/Mixer/Mix1/Ana3_fader'],
76             self.mix1ana4_fader: ['/Mixer/Mix1/Ana4_fader'],
77             self.mix1ana5_fader: ['/Mixer/Mix1/Ana5_fader'],
78             self.mix1ana6_fader: ['/Mixer/Mix1/Ana6_fader'],
79             self.mix1ana7_fader: ['/Mixer/Mix1/Ana7_fader'],
80             self.mix1ana8_fader: ['/Mixer/Mix1/Ana8_fader'],
81             self.mix1_fader: ['/Mixer/Mix1/Mix_fader'],
82             }
83
84         self.Controls={
85             self.mix1ana1_pan:   ['/Mixer/Mix1/Ana1_pan'],
86             self.mix1ana2_pan:   ['/Mixer/Mix1/Ana2_pan'],
87             self.mix1ana3_pan:   ['/Mixer/Mix1/Ana3_pan'],
88             self.mix1ana4_pan:   ['/Mixer/Mix1/Ana4_pan'],
89             self.mix1ana5_pan:   ['/Mixer/Mix1/Ana5_pan'],
90             self.mix1ana6_pan:   ['/Mixer/Mix1/Ana6_pan'],
91             self.mix1ana7_pan:   ['/Mixer/Mix1/Ana7_pan'],
92             self.mix1ana8_pan:   ['/Mixer/Mix1/Ana8_pan'],
93
94             self.ana1_trimgain:  ['/Mixer/Control/Ana1_trimgain'],
95             self.ana2_trimgain:  ['/Mixer/Control/Ana2_trimgain'],
96             self.ana3_trimgain:  ['/Mixer/Control/Ana3_trimgain'],
97             self.ana4_trimgain:  ['/Mixer/Control/Ana4_trimgain'],
98         }
99
100         self.BinarySwitches={
101             self.mix1ana1_mute:  ['/Mixer/Mix1/Ana1_mute'],
102             self.mix1ana2_mute:  ['/Mixer/Mix1/Ana2_mute'],
103             self.mix1ana3_mute:  ['/Mixer/Mix1/Ana3_mute'],
104             self.mix1ana4_mute:  ['/Mixer/Mix1/Ana4_mute'],
105             self.mix1ana5_mute:  ['/Mixer/Mix1/Ana5_mute'],
106             self.mix1ana6_mute:  ['/Mixer/Mix1/Ana6_mute'],
107             self.mix1ana7_mute:  ['/Mixer/Mix1/Ana7_mute'],
108             self.mix1ana8_mute:  ['/Mixer/Mix1/Ana8_mute'],
109             self.mix1ana1_solo:  ['/Mixer/Mix1/Ana1_solo'],
110             self.mix1ana2_solo:  ['/Mixer/Mix1/Ana2_solo'],
111             self.mix1ana3_solo:  ['/Mixer/Mix1/Ana3_solo'],
112             self.mix1ana4_solo:  ['/Mixer/Mix1/Ana4_solo'],
113             self.mix1ana5_solo:  ['/Mixer/Mix1/Ana5_solo'],
114             self.mix1ana6_solo:  ['/Mixer/Mix1/Ana6_solo'],
115             self.mix1ana7_solo:  ['/Mixer/Mix1/Ana7_solo'],
116             self.mix1ana8_solo:  ['/Mixer/Mix1/Ana8_solo'],
117             self.mix1_mute:      ['/Mixer/Mix1/Mix_mute'],
118             self.ana1_pad:       ['/Mixer/Control/Ana1_pad'],
119             self.ana2_pad:       ['/Mixer/Control/Ana2_pad'],
120             self.ana3_pad:       ['/Mixer/Control/Ana3_pad'],
121             self.ana4_pad:       ['/Mixer/Control/Ana4_pad'],
122             self.ana5_level:     ['/Mixer/Control/Ana5_level'],
123             self.ana6_level:     ['/Mixer/Control/Ana6_level'],
124             self.ana7_level:     ['/Mixer/Control/Ana7_level'],
125             self.ana8_level:     ['/Mixer/Control/Ana8_level'],
126             self.ana5_boost:     ['/Mixer/Control/Ana5_boost'],
127             self.ana6_boost:     ['/Mixer/Control/Ana6_boost'],
128             self.ana7_boost:     ['/Mixer/Control/Ana7_boost'],
129             self.ana8_boost:     ['/Mixer/Control/Ana8_boost'],
130         }
131
132         # Ultimately these may be rolled into the BinarySwitches controls,
133         # but since they aren't implemented and therefore need to be
134         # disabled it's easier to keep them separate for the moment.
135         self.PairSwitches={
136             self.mix1ana1_2_pair:   ['Mixer/Mix1/Ana1_2_pair'],
137             self.mix1ana3_4_pair:   ['Mixer/Mix1/Ana3_4_pair'],
138             self.mix1ana5_6_pair:   ['Mixer/Mix1/Ana5_6_pair'],
139             self.mix1ana7_8_pair:   ['Mixer/Mix1/Ana7_8_pair'],
140             self.mix1aes1_2_pair:   ['Mixer/Mix1/Aes1_2_pair'],
141             self.mix1adat1_2_pair:  ['Mixer/Mix1/Adat1_2_pair'],
142             self.mix1adat3_4_pair:  ['Mixer/Mix1/Adat3_4_pair'],
143             self.mix1adat5_6_pair:  ['Mixer/Mix1/Adat5_6_pair'],
144             self.mix1adat7_8_pair:  ['Mixer/Mix1/Adat7_8_pair'],
145             self.mix1spdif1_2_pair: ['Mixer/Mix1/Spdif1_2_pair'],
146         }
147
148         self.MixDests={
149             self.mix1_dest:      ['/Mixer/Mix1/Mix_dest'],
150
151             self.phones_src:     ['/Mixer/Control/Phones_src'],
152
153             self.optical_in_mode:   ['/Mixer/Control/OpticalIn_mode'],
154             self.optical_out_mode:  ['/Mixer/Control/OpticalOut_mode'],
155         }
156
157         self.SelectorControls={
158
159         }
160
161         # Other mixer variables
162         self.is_streaming = 0
163         self.sample_rate = 0
164
165     def initValues(self):
166         # Is the device streaming?
167         self.is_streaming = self.hw.getDiscrete('/Mixer/Info/IsStreaming')
168         print "device streaming flag: %d" % (self.is_streaming)
169
170         # Retrieve other device settings as needed
171         self.sample_rate = self.hw.getDiscrete('/Mixer/Info/SampleRate')
172         print "device sample rate: %d" % (self.sample_rate)
173         self.has_mic_inputs = self.hw.getDiscrete('/Mixer/Info/HasMicInputs')
174         print "device has mic inputs: %d" % (self.has_mic_inputs)
175         self.has_aesebu_inputs = self.hw.getDiscrete('/Mixer/Info/HasAESEBUInputs')
176         print "device has AES/EBU inputs: %d" % (self.has_aesebu_inputs)
177         self.has_spdif_inputs = self.hw.getDiscrete('/Mixer/Info/HasSPDIFInputs')
178         print "device has SPDIF inputs: %d" % (self.has_spdif_inputs)
179         self.has_optical_spdif = self.hw.getDiscrete('/Mixer/Info/HasOpticalSPDIF')
180         print "device has optical SPDIF: %d" % (self.has_optical_spdif)
181
182         # Customise the UI based on device options retrieved
183         if (self.has_mic_inputs):
184             # Mic input controls displace AES/EBU since no current device
185             # has both.
186             self.mix1_aes_group.setTitle("Mic inputs")
187             # FIXME: when implmented, will mic channels just reuse the AES/EBU
188             # dbus path?  If not we'll have to reset the respective values in
189             # the control arrays (self.ChannelFaders etc).
190         else:
191             if (not(self.has_aesebu_inputs)):
192                 self.mix1_aes_group.setEnabled(False)
193         if (not(self.has_spdif_inputs)):
194             self.mix1_spdif_group.setEnabled(False)
195
196         # Some devices don't have the option of selecting an optical SPDIF
197         # mode.
198         if (not(self.has_optical_spdif)):
199             self.optical_in_mode.removeItem(2)
200             self.optical_out_mode.removeItem(2)
201
202         # Some controls must be disabled if the device is streaming
203         if (self.is_streaming):
204             print "Disabling controls which require inactive streaming"
205             self.optical_in_mode.setEnabled(False)
206             self.optical_out_mode.setEnabled(False)
207
208         # Some channels aren't available at higher sampling rates
209         if (self.sample_rate > 96000):
210             print "Disabling controls not present above 96 kHz"
211             self.mix1_adat_group.setEnabled(False)
212             self.mix1_aes_group.setEnabled(False)
213             self.mix1_spdif_group.setEnabled(False)
214         if (self.sample_rate > 48000):
215             print "Disabling controls not present above 48 kHz"
216             self.mix1_adat58_group.setEnabled(False)
217
218         # Now fetch the current values into the respective controls.  Don't
219         # bother fetching controls which are disabled.
220         for ctrl, info in self.ChannelFaders.iteritems():
221             if (not(ctrl.isEnabled())):
222                 continue
223             vol = 128-self.hw.getDiscrete(info[0])
224             print "%s channel fader is %d" % (info[0] , vol)
225             ctrl.setValue(vol)
226             QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateFader)
227
228         for ctrl, info in self.Controls.iteritems():
229             if (not(ctrl.isEnabled())):
230                 continue
231             pan = self.hw.getDiscrete(info[0])
232             print "%s control is %d" % (info[0] , pan)
233             ctrl.setValue(pan)
234             QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateControl)
235
236         # Disable the channel pair controls since they aren't yet implemented
237         for ctrl, info in self.PairSwitches.iteritems():
238             print "%s control is not implemented yet: disabling" % (info[0])
239             ctrl.setEnabled(False)
240
241         for ctrl, info in self.BinarySwitches.iteritems():
242             if (not(ctrl.isEnabled())):
243                 continue
244             val = self.hw.getDiscrete(info[0])
245             print "%s switch is %d" % (info[0] , val)
246             ctrl.setChecked(val)
247             QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateBinarySwitch)
248
249         for ctrl, info in self.MixDests.iteritems():
250             if (not(ctrl.isEnabled())):
251                 continue
252             dest = self.hw.getDiscrete(info[0])
253             print "%s mix destination is %d" % (info[0] , dest)
254             ctrl.setCurrentItem(dest)
255             QObject.connect(ctrl, SIGNAL('activated(int)'), self.updateMixDest)
256
257         for name, ctrl in self.SelectorControls.iteritems():
258             state = self.hw.getDiscrete(ctrl[0])
259             print "%s state is %d" % (name , state)
260             ctrl[1].setCurrentItem(state)   
261
262         # FIXME: If optical mode is not ADAT, disable ADAT controls here.
263         # It can't be done earlier because we need the current values of the
264         # ADAT channel controls in case the user goes ahead and enables the
265         # ADAT optical mode.
Note: See TracBrowser for help on using the browser.