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

Revision 1006, 9.6 kB (checked in by jwoithe, 13 years ago)

MOTU: implement "phones source" control.
MOTU: commence work on optical mode control. For various reasons this isn't functional yet.

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: channel pan
39     def updatePan(self, a0):
40         sender = self.sender()
41         pan = a0
42         print "setting %s channel pan to %d" % (self.ChannelPans[sender][0], pan)
43         self.hw.setDiscrete(self.ChannelPans[sender][0], pan)
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.ChannelPans={
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
95         self.BinarySwitches={
96             self.mix1ana1_mute:  ['/Mixer/Mix1/Ana1_mute'],
97             self.mix1ana2_mute:  ['/Mixer/Mix1/Ana2_mute'],
98             self.mix1ana3_mute:  ['/Mixer/Mix1/Ana3_mute'],
99             self.mix1ana4_mute:  ['/Mixer/Mix1/Ana4_mute'],
100             self.mix1ana5_mute:  ['/Mixer/Mix1/Ana5_mute'],
101             self.mix1ana6_mute:  ['/Mixer/Mix1/Ana6_mute'],
102             self.mix1ana7_mute:  ['/Mixer/Mix1/Ana7_mute'],
103             self.mix1ana8_mute:  ['/Mixer/Mix1/Ana8_mute'],
104             self.mix1_mute:  ['/Mixer/Mix1/Mix_mute'],
105             self.mix1ana1_solo:  ['/Mixer/Mix1/Ana1_solo'],
106             self.mix1ana2_solo:  ['/Mixer/Mix1/Ana2_solo'],
107             self.mix1ana3_solo:  ['/Mixer/Mix1/Ana3_solo'],
108             self.mix1ana4_solo:  ['/Mixer/Mix1/Ana4_solo'],
109             self.mix1ana5_solo:  ['/Mixer/Mix1/Ana5_solo'],
110             self.mix1ana6_solo:  ['/Mixer/Mix1/Ana6_solo'],
111             self.mix1ana7_solo:  ['/Mixer/Mix1/Ana7_solo'],
112             self.mix1ana8_solo:  ['/Mixer/Mix1/Ana8_solo'],
113             self.ana5_level:     ['/Mixer/Control/Ana5_level'],
114             self.ana6_level:     ['/Mixer/Control/Ana6_level'],
115             self.ana7_level:     ['/Mixer/Control/Ana7_level'],
116             self.ana8_level:     ['/Mixer/Control/Ana8_level'],
117             self.ana5_boost:     ['/Mixer/Control/Ana5_boost'],
118             self.ana6_boost:     ['/Mixer/Control/Ana6_boost'],
119             self.ana7_boost:     ['/Mixer/Control/Ana7_boost'],
120             self.ana8_boost:     ['/Mixer/Control/Ana8_boost'],
121         }
122
123         self.MixDests={
124             self.mix1_dest:      ['/Mixer/Mix1/Mix_dest'],
125
126             self.phones_src:     ['/Mixer/Control/Phones_src'],
127
128             self.optical_in_mode:   ['/Mixer/Control/OpticalIn_mode'],
129             self.optical_out_mode:  ['/Mixer/Control/OpticalOut_mode'],
130         }
131
132         self.SelectorControls={
133
134         }
135
136         # Other mixer variables
137         self.is_streaming = 0
138         self.sample_rate = 0
139
140     def initValues(self):
141         # Is the device streaming?
142         self.is_streaming = self.hw.getDiscrete('/Mixer/Info/IsStreaming')
143         print "device streaming flag: %d" % (self.is_streaming)
144
145         # Retrieve other device settings as needed
146         self.sample_rate = self.hw.getDiscrete('/Mixer/Info/SampleRate')
147         print "device sample rate: %d" % (self.sample_rate)
148         self.has_mic_inputs = self.hw.getDiscrete('/Mixer/Info/HasMicInputs')
149         print "device has mic inputs: %d" % (self.has_mic_inputs)
150         self.has_aesebu_inputs = self.hw.getDiscrete('/Mixer/Info/HasAESEBUInputs')
151         print "device has AES/EBU inputs: %d" % (self.has_aesebu_inputs)
152         self.has_spdif_inputs = self.hw.getDiscrete('/Mixer/Info/HasSPDIFInputs')
153         print "device has SPDIF inputs: %d" % (self.has_spdif_inputs)
154
155         # Customise the UI based on device options retrieved
156         if (self.has_mic_inputs):
157             # Mic input controls displace AES/EBU since no current device
158             # has both.
159             self.mix1_aes_group.setTitle("Mic inputs")
160             # FIXME: when implmented, will mic channels just reuse the AES/EBU
161             # dbus path?  If not we'll have to reset the respective values in
162             # the control arrays (self.ChannelFaders etc).
163         else:
164             if (not(self.has_aesebu_inputs)):
165                 self.mix1_aes_group.setEnabled(False)
166         if (not(self.has_spdif_inputs)):
167             self.mix1_spdif_group.setEnabled(False)
168
169         # Some controls must be disabled if the device is streaming
170         if (self.is_streaming):
171             print "Disabling controls which require inactive streaming"
172             self.optical_in_mode.setEnabled(False)
173             self.optical_out_mode.setEnabled(False)
174
175         # Some channels aren't available at higher sampling rates
176         if (self.sample_rate > 96000):
177             print "Disabling controls not present above 96 kHz"
178             self.mix1_adat_group.setEnabled(False)
179             self.mix1_aes_group.setEnabled(False)
180             self.mix1_spdif_group.setEnabled(False)
181         if (self.sample_rate > 48000):
182             print "Disabling controls not present above 48 kHz"
183             self.mix1_adat58_group.setEnabled(False)
184
185         # Now fetch the current values into the respective controls.  Don't
186         # bother fetching controls which are disabled.
187         for ctrl, info in self.ChannelFaders.iteritems():
188             if (not(ctrl.isEnabled())):
189                 continue
190             vol = 128-self.hw.getDiscrete(info[0])
191             print "%s channel fader is %d" % (info[0] , vol)
192             ctrl.setValue(vol)
193             QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateFader)
194
195         for ctrl, info in self.ChannelPans.iteritems():
196             if (not(ctrl.isEnabled())):
197                 continue
198             pan = self.hw.getDiscrete(info[0])
199             print "%s channel pan is %d" % (info[0] , pan)
200             ctrl.setValue(pan)
201             QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updatePan)
202
203         for ctrl, info in self.BinarySwitches.iteritems():
204             if (not(ctrl.isEnabled())):
205                 continue
206             val = self.hw.getDiscrete(info[0])
207             print "%s switch is %d" % (info[0] , val)
208             ctrl.setChecked(val)
209             QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateBinarySwitch)
210
211         for ctrl, info in self.MixDests.iteritems():
212             if (not(ctrl.isEnabled())):
213                 continue
214             dest = self.hw.getDiscrete(info[0])
215             print "%s mix destination is %d" % (info[0] , dest)
216             ctrl.setCurrentItem(dest)
217             QObject.connect(ctrl, SIGNAL('activated(int)'), self.updateMixDest)
218
219         for name, ctrl in self.SelectorControls.iteritems():
220             state = self.hw.getDiscrete(ctrl[0])
221             print "%s state is %d" % (name , state)
222             ctrl[1].setCurrentItem(state)   
223
224         # FIXME: If optical mode is not ADAT, disable ADAT controls here.
225         # It can't be done earlier because we need the current values of the
226         # ADAT channel controls in case the user goes ahead and enables the
227         # ADAT optical mode.
Note: See TracBrowser for help on using the browser.