root/trunk/libffado/support/mixer-qt4/ffado/mixer/edirolfa66.py

Revision 1640, 3.7 kB (checked in by arnonym, 12 years ago)

Make it more pythonic.

All ffado stuff is now in packages getting installed to the official python dirs. Ideally this would allow other apps to use the stuff from us.

Maybe the generic widgets (that are used by multiple mixers) should go into ffado/widgets...

  • Property svn:mergeinfo set to
Line 
1 #
2 # Copyright (C) 2005-2008 by Daniel Wagner
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 PyQt4.QtCore import SIGNAL, SLOT, QObject
24 from PyQt4.QtGui import QWidget
25 from ffado.config import *
26
27 import logging
28 log = logging.getLogger('edirolfa66')
29
30 class EdirolFa66Control(QWidget):
31     def __init__(self, parent = None):
32         QWidget.__init__(self, parent)
33         uicLoad("ffado/mixer/edirolfa66", self)
34
35         self.VolumeControls = {
36             #          feature name, channel, qt slider
37             'vol1'  :   ['/Mixer/Feature_Volume_1', 1, self.sldInput1],
38             'vol2'  :   ['/Mixer/Feature_Volume_1', 2, self.sldInput2],
39             'vol3'  :   ['/Mixer/Feature_Volume_2', 1, self.sldInput3],
40             'vol4'  :   ['/Mixer/Feature_Volume_2', 2, self.sldInput4],
41             'vol5'  :   ['/Mixer/Feature_Volume_3', 1, self.sldInput5],
42             'vol6'  :   ['/Mixer/Feature_Volume_3', 2, self.sldInput6],
43
44             'bal1'  :   ['/Mixer/Feature_LRBalance_1', 1, self.sldBal1],
45             'bal2'  :   ['/Mixer/Feature_LRBalance_1', 2, self.sldBal2],
46             'bal3'  :   ['/Mixer/Feature_LRBalance_2', 1, self.sldBal3],
47             'bal4'  :   ['/Mixer/Feature_LRBalance_2', 2, self.sldBal4],
48             'bal5'  :   ['/Mixer/Feature_LRBalance_3', 1, self.sldBal5],
49             'bal6'  :   ['/Mixer/Feature_LRBalance_3', 2, self.sldBal6],
50             }
51
52     def setVolumeIn1(self, vol):
53         self.setValue('vol1', vol)
54
55     def setVolumeIn2(self, vol):
56         self.setValue('vol2', vol)
57
58     def setVolumeIn3(self, vol):
59         self.setValue('vol3', vol)
60
61     def setVolumeIn4(self, vol):
62         self.setValue('vol4', vol)
63
64     def setVolumeIn5(self, vol):
65         self.setValue('vol5', vol)
66
67     def setVolumeIn6(self, vol):
68         self.setValue('vol6', vol)
69
70     def setBalanceIn1(self, bal):
71         self.setValue('bal1', bal)
72
73     def setBalanceIn2(self, bal):
74         self.setValue('bal2', bal)
75
76     def setBalanceIn3(self, bal):
77         self.setValue('bal3', bal)
78
79     def setBalanceIn4(self, bal):
80         self.setValue('bal4', bal)
81
82     def setBalanceIn5(self, bal):
83         self.setValue('bal5', bal)
84
85     def setBalanceIn6(self, bal):
86         self.setValue('bal6', bal)
87
88     def setValue(self, name, val):
89         ctrl = self.VolumeControls[name]
90         log.debug("setting %s to %d" % (name, val))
91         self.hw.setContignuous(ctrl[0], val, idx = ctrl[1])
92
93     def initValues(self):
94         for name, ctrl in self.VolumeControls.iteritems():
95             val = self.hw.getContignuous(ctrl[0], idx = ctrl[1])
96             log.debug("%s value is %d" % (name , val))
97
98             # Workaround: The current value is not properly initialized
99             # on the device and returns after bootup always 0.
100             # Though we happen to know what the correct value should
101             # be therefore we overwrite the 0
102             if name[0:3] == 'bal' and val == 0:
103                 if ctrl[1] == 1:
104                     val = 32512
105                 else:
106                     val = -32768
107
108             ctrl[2].setValue(val)
109
110 # vim: et
Note: See TracBrowser for help on using the browser.