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

Revision 1167, 8.1 kB (checked in by ppalmers, 14 years ago)

impement level control for saffire LE outputs (cfr ticket #56)

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_saffireleui import *
25
26 class SaffireLEMixer(SaffireLEMixerUI):
27     def __init__(self,parent = None,name = None,fl = 0):
28         SaffireLEMixerUI.__init__(self,parent,name,fl)
29
30     def init(self):
31             print "Init Saffire LE mixer window"
32
33             self.VolumeControls={
34                     self.sldIN1Out1: ['/Mixer/LEMix48', 0, 0],
35                     self.sldIN1Out2: ['/Mixer/LEMix48', 0, 1],
36                     self.sldIN1Out3: ['/Mixer/LEMix48', 0, 2],
37                     self.sldIN1Out4: ['/Mixer/LEMix48', 0, 3],
38                     self.sldIN2Out1: ['/Mixer/LEMix48', 1, 0],
39                     self.sldIN2Out2: ['/Mixer/LEMix48', 1, 1],
40                     self.sldIN2Out3: ['/Mixer/LEMix48', 1, 2],
41                     self.sldIN2Out4: ['/Mixer/LEMix48', 1, 3],
42                     self.sldIN3Out1: ['/Mixer/LEMix48', 2, 0],
43                     self.sldIN3Out2: ['/Mixer/LEMix48', 2, 1],
44                     self.sldIN3Out3: ['/Mixer/LEMix48', 2, 2],
45                     self.sldIN3Out4: ['/Mixer/LEMix48', 2, 3],
46                     self.sldIN4Out1: ['/Mixer/LEMix48', 3, 0],
47                     self.sldIN4Out2: ['/Mixer/LEMix48', 3, 1],
48                     self.sldIN4Out3: ['/Mixer/LEMix48', 3, 2],
49                     self.sldIN4Out4: ['/Mixer/LEMix48', 3, 3],
50                     self.sldSPDIF1Out1: ['/Mixer/LEMix48', 4, 0],
51                     self.sldSPDIF1Out2: ['/Mixer/LEMix48', 4, 1],
52                     self.sldSPDIF1Out3: ['/Mixer/LEMix48', 4, 2],
53                     self.sldSPDIF1Out4: ['/Mixer/LEMix48', 4, 3],
54                     self.sldSPDIF2Out1: ['/Mixer/LEMix48', 5, 0],
55                     self.sldSPDIF2Out2: ['/Mixer/LEMix48', 5, 1],
56                     self.sldSPDIF2Out3: ['/Mixer/LEMix48', 5, 2],
57                     self.sldSPDIF2Out4: ['/Mixer/LEMix48', 5, 3],
58                    
59                     self.sldPC1Out1: ['/Mixer/LEMix48', 6, 0],
60                     self.sldPC1Out2: ['/Mixer/LEMix48', 6, 1],
61                     self.sldPC1Out3: ['/Mixer/LEMix48', 6, 2],
62                     self.sldPC1Out4: ['/Mixer/LEMix48', 6, 3],
63                     self.sldPC2Out1: ['/Mixer/LEMix48', 7, 0],
64                     self.sldPC2Out2: ['/Mixer/LEMix48', 7, 1],
65                     self.sldPC2Out3: ['/Mixer/LEMix48', 7, 2],
66                     self.sldPC2Out4: ['/Mixer/LEMix48', 7, 3],
67                     self.sldPC3Out1: ['/Mixer/LEMix48', 8, 0],
68                     self.sldPC3Out2: ['/Mixer/LEMix48', 8, 1],
69                     self.sldPC3Out3: ['/Mixer/LEMix48', 8, 2],
70                     self.sldPC3Out4: ['/Mixer/LEMix48', 8, 3],
71                     self.sldPC4Out1: ['/Mixer/LEMix48', 9, 0],
72                     self.sldPC4Out2: ['/Mixer/LEMix48', 9, 1],
73                     self.sldPC4Out3: ['/Mixer/LEMix48', 9, 2],
74                     self.sldPC4Out4: ['/Mixer/LEMix48', 9, 3],
75                     self.sldPC5Out1: ['/Mixer/LEMix48', 10, 0],
76                     self.sldPC5Out2: ['/Mixer/LEMix48', 10, 1],
77                     self.sldPC5Out3: ['/Mixer/LEMix48', 10, 2],
78                     self.sldPC5Out4: ['/Mixer/LEMix48', 10, 3],
79                     self.sldPC6Out1: ['/Mixer/LEMix48', 11, 0],
80                     self.sldPC6Out2: ['/Mixer/LEMix48', 11, 1],
81                     self.sldPC6Out3: ['/Mixer/LEMix48', 11, 2],
82                     self.sldPC6Out4: ['/Mixer/LEMix48', 11, 3],
83                     self.sldPC7Out1: ['/Mixer/LEMix48', 12, 0],
84                     self.sldPC7Out2: ['/Mixer/LEMix48', 12, 1],
85                     self.sldPC7Out3: ['/Mixer/LEMix48', 12, 2],
86                     self.sldPC7Out4: ['/Mixer/LEMix48', 12, 3],
87                     self.sldPC8Out1: ['/Mixer/LEMix48', 13, 0],
88                     self.sldPC8Out2: ['/Mixer/LEMix48', 13, 1],
89                     self.sldPC8Out3: ['/Mixer/LEMix48', 13, 2],
90                     self.sldPC8Out4: ['/Mixer/LEMix48', 13, 3],
91                    }
92
93             self.SelectorControls={
94                     self.chkOut12Mute:          ['/Mixer/Out12Mute'],
95                     self.chkOut12HwCtrl:        ['/Mixer/Out12HwCtrl'],
96                     self.chkOut34Mute:          ['/Mixer/Out34Mute'],
97                     self.chkOut34HwCtrl:        ['/Mixer/Out34HwCtrl'],
98                     self.chkOut56Mute:          ['/Mixer/Out56Mute'],
99                     self.chkOut56HwCtrl:        ['/Mixer/Out56HwCtrl'],
100                     self.chkSPDIFTransparent:   ['/Mixer/SpdifTransparent'],
101                     self.chkMIDITru:            ['/Mixer/MidiThru'],
102                     self.chkHighGain3:          ['/Mixer/HighGainLine3'],
103                     self.chkHighGain4:          ['/Mixer/HighGainLine4'],
104                     }
105
106             self.VolumeControlsLowRes={
107                     self.sldOut12Level:      ['/Mixer/Out12Level'],
108                     self.sldOut34Level:      ['/Mixer/Out34Level'],
109                     self.sldOut56Level:      ['/Mixer/Out56Level'],
110                     }
111
112     def updateMatrixVolume(self,a0):
113         sender = self.sender()
114         vol = 0x7FFF-a0
115         print "set %s %d %d to %d" % (
116                     self.VolumeControls[sender][0],
117                     self.VolumeControls[sender][1],
118                     self.VolumeControls[sender][2],
119                     vol)
120         self.hw.setMatrixMixerValue(self.VolumeControls[sender][0],
121                                     self.VolumeControls[sender][1],
122                                     self.VolumeControls[sender][2],
123                                     vol)
124     def updateLowResVolume(self,a0):
125         sender = self.sender()
126         vol = a0
127         print "set %s to %d" % (
128                     self.VolumeControlsLowRes[sender][0],
129                     vol)
130         self.hw.setDiscrete(self.VolumeControlsLowRes[sender][0], vol)
131
132     def updateSelector(self,a0):
133         sender = self.sender()
134         if a0:
135             state = 1
136         else:
137             state = 0
138         print "set %s to %d" % (
139                     self.SelectorControls[sender][0],
140                     state)
141         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
142
143     def initValues(self):
144             for ctrl, info in self.VolumeControls.iteritems():
145                 vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
146                                                   self.VolumeControls[ctrl][1],
147                                                   self.VolumeControls[ctrl][2])
148
149                 print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
150                 ctrl.setValue(0x7FFF-vol)
151
152                 # connect the UI element
153                 QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
154
155             for ctrl, info in self.VolumeControlsLowRes.iteritems():
156                 vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
157
158                 print "%s volume is %d" % (ctrl.name() , vol)
159                 ctrl.setValue(vol)
160
161                 # connect the UI element
162                 QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
163
164             for ctrl, info in self.SelectorControls.iteritems():
165                 state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
166                 print "%s state is %d" % (ctrl.name() , state)
167                 if state:
168                     ctrl.setChecked(True)
169                 else:
170                     ctrl.setChecked(False)
171
172                 # connect the UI element
173                 QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
Note: See TracBrowser for help on using the browser.