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

Revision 1171, 8.7 kB (checked in by ppalmers, 13 years ago)

implement save to device for saffire LE

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             self.TriggerButtonControls={
113                 self.btnSaveSettings:        ['/Mixer/SaveSettings'],
114             }
115
116     def updateMatrixVolume(self,a0):
117         sender = self.sender()
118         vol = 0x7FFF-a0
119         print "set %s %d %d to %d" % (
120                     self.VolumeControls[sender][0],
121                     self.VolumeControls[sender][1],
122                     self.VolumeControls[sender][2],
123                     vol)
124         self.hw.setMatrixMixerValue(self.VolumeControls[sender][0],
125                                     self.VolumeControls[sender][1],
126                                     self.VolumeControls[sender][2],
127                                     vol)
128     def updateLowResVolume(self,a0):
129         sender = self.sender()
130         vol = a0
131         print "set %s to %d" % (
132                     self.VolumeControlsLowRes[sender][0],
133                     vol)
134         self.hw.setDiscrete(self.VolumeControlsLowRes[sender][0], vol)
135
136     def updateSelector(self,a0):
137         sender = self.sender()
138         if a0:
139             state = 1
140         else:
141             state = 0
142         print "set %s to %d" % (
143                     self.SelectorControls[sender][0],
144                     state)
145         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
146
147     def triggerButton(self):
148         sender = self.sender()
149         print "trigger %s" % (
150                     self.TriggerButtonControls[sender][0])
151         self.hw.setDiscrete(self.TriggerButtonControls[sender][0], 1)
152
153     def initValues(self):
154             for ctrl, info in self.VolumeControls.iteritems():
155                 vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
156                                                   self.VolumeControls[ctrl][1],
157                                                   self.VolumeControls[ctrl][2])
158
159                 print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
160                 ctrl.setValue(0x7FFF-vol)
161
162                 # connect the UI element
163                 QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
164
165             for ctrl, info in self.VolumeControlsLowRes.iteritems():
166                 vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
167
168                 print "%s volume is %d" % (ctrl.name() , vol)
169                 ctrl.setValue(vol)
170
171                 # connect the UI element
172                 QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
173
174             for ctrl, info in self.SelectorControls.iteritems():
175                 state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
176                 print "%s state is %d" % (ctrl.name() , state)
177                 if state:
178                     ctrl.setChecked(True)
179                 else:
180                     ctrl.setChecked(False)
181
182                 # connect the UI element
183                 QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
184
185             for ctrl, info in self.TriggerButtonControls.iteritems():
186                 # connect the UI element
187                 QObject.connect(ctrl,SIGNAL('clicked()'),self.triggerButton)
Note: See TracBrowser for help on using the browser.