root/branches/libffado-2.0/support/mixer/mixer_saffire_base.py

Revision 1216, 5.2 kB (checked in by ppalmers, 13 years ago)

add support for the different mixers at different samplerates or configurations for the saffires

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
25 # the class that holds all actual control code
26 class SaffireMixerBase():
27     def __init__(self):
28         pass
29
30     def updateMatrixVolume(self,a0):
31         sender = self.sender()
32         vol = 0x7FFF-a0
33         print "set %s %d %d to %d" % (
34                     self.VolumeControls[sender][0],
35                     self.VolumeControls[sender][1],
36                     self.VolumeControls[sender][2],
37                     vol)
38         self.hw.setMatrixMixerValue(self.VolumeControls[sender][0],
39                                     self.VolumeControls[sender][1],
40                                     self.VolumeControls[sender][2],
41                                     vol)
42     def updateLowResVolume(self,a0):
43         sender = self.sender()
44         vol = a0
45         print "set %s to %d" % (
46                     self.VolumeControlsLowRes[sender][0],
47                     vol)
48         self.hw.setDiscrete(self.VolumeControlsLowRes[sender][0], vol)
49
50     def updateSelector(self,a0):
51         sender = self.sender()
52         if a0:
53             state = 1
54         else:
55             state = 0
56         print "set %s to %d" % (
57                     self.SelectorControls[sender][0],
58                     state)
59         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
60
61     def triggerButton(self):
62         sender = self.sender()
63         print "trigger %s" % (
64                     self.TriggerButtonControls[sender][0])
65         self.hw.setDiscrete(self.TriggerButtonControls[sender][0], 1)
66
67     def saveText(self):
68         sender = self.sender()
69         textbox = self.saveTextControls[sender][0]
70         print "save %s" % (
71                     textbox.text().ascii())
72         self.hw.setText(self.TextControls[textbox][0], textbox.text().ascii())
73
74     def initCombo(self, combo):
75         path = self.ComboControls[combo][0]
76         combo.clear()
77         for i in range( self.hw.enumCount(path) ):
78             combo.insertItem( self.hw.enumGetLabel(path, i) )
79         combo.setCurrentItem( self.hw.enumSelected(path) )
80
81     def selectCombo(self, mode):
82         sender = self.sender()
83         path = self.ComboControls[sender][0]
84         self.hw.enumSelect(path, mode)
85         sender.setCurrentItem( self.hw.enumSelected(path) )
86
87     def updateValues(self):
88         for ctrl, info in self.VolumeControls.iteritems():
89             vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
90                                                 self.VolumeControls[ctrl][1],
91                                                 self.VolumeControls[ctrl][2])
92
93             print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
94             ctrl.setValue(0x7FFF-vol)
95
96         for ctrl, info in self.VolumeControlsLowRes.iteritems():
97             vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
98
99             print "%s volume is %d" % (ctrl.name() , vol)
100             ctrl.setValue(vol)
101
102         for ctrl, info in self.SelectorControls.iteritems():
103             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
104             print "%s state is %d" % (ctrl.name() , state)
105             if state:
106                 ctrl.setChecked(True)
107             else:
108                 ctrl.setChecked(False)
109
110         for ctrl, info in self.TriggerButtonControls.iteritems():
111             pass
112
113         for ctrl, info in self.TextControls.iteritems():
114             text = self.hw.getText(self.TextControls[ctrl][0])
115             print "%s text is %s" % (ctrl.name() , text)
116             ctrl.setText(text)
117
118         for ctrl, info in self.ComboControls.iteritems():
119             self.initCombo(ctrl)
120
121     def initValues(self):
122         self.updateValues()
123         for ctrl, info in self.VolumeControls.iteritems():
124             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
125
126         for ctrl, info in self.VolumeControlsLowRes.iteritems():
127             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
128
129         for ctrl, info in self.SelectorControls.iteritems():
130             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
131
132         for ctrl, info in self.TriggerButtonControls.iteritems():
133             QObject.connect(ctrl,SIGNAL('clicked()'),self.triggerButton)
134
135         for ctrl, info in self.saveTextControls.iteritems():
136             QObject.connect(ctrl,SIGNAL('clicked()'), self.saveText)
137
138         for ctrl, info in self.ComboControls.iteritems():
139             QObject.connect(ctrl, SIGNAL('activated(int)'), self.selectCombo)
Note: See TracBrowser for help on using the browser.