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

Revision 1640, 5.3 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('edirolfa101')
29
30 class EdirolFa101Control(QWidget):
31     def __init__(self, parent = None):
32         QWidget.__init__(self, parent)
33         uicLoad("ffado/mixer/edirolfa101", self)
34
35     def setVolumeIn1(self, vol):
36         self.setValue('vol1', vol)
37
38     def setVolumeIn2(self, vol):
39         self.setValue('vol2', vol)
40
41     def setVolumeIn3(self, vol):
42         self.setValue('vol3', vol)
43
44     def setVolumeIn4(self, vol):
45         self.setValue('vol4', vol)
46
47     def setVolumeIn5(self, vol):
48         self.setValue('vol5', vol)
49
50     def setVolumeIn6(self, vol):
51         self.setValue('vol6', vol)
52
53     def setVolumeIn7(self, vol):
54         self.setValue('vol7', vol)
55
56     def setVolumeIn8(self, vol):
57         self.setValue('vol8', vol)
58
59     def setVolumeIn9(self, vol):
60         self.setValue('vol9', vol)
61
62     def setVolumeIn10(self,vol):
63         self.setValue('vol10', vol)
64
65     def setBalanceIn1(self, bal):
66         self.setValue('bal1', bal)
67
68     def setBalanceIn2(self, bal):
69         self.setValue('bal2', bal)
70
71     def setBalanceIn3(self, bal):
72         self.setValue('bal3', bal)
73
74     def setBalanceIn4(self, bal):
75         self.setValue('bal4', bal)
76
77     def setBalanceIn5(self, bal):
78         self.setValue('bal5', bal)
79
80     def setBalanceIn6(self, bal):
81         self.setValue('bal6', bal)
82
83     def setBalanceIn7(self, bal):
84         self.setValue('bal7', bal)
85
86     def setBalanceIn8(self, bal):
87         self.setValue('bal8', bal)
88
89     def setBalanceIn9(self, bal):
90         self.setValue('bal9', bal)
91
92     def setBalanceIn10(self,bal):
93         self.setValue('bal10', bal)
94
95     def getIndexByName(self, name):
96         index = int(name.lstrip('volba')) - 1
97         streamingMap    = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
98         nonStreamingMap = [ 9, 10, 1, 2, 3, 4, 5, 6, 7, 8 ]
99
100         if self.is_streaming:
101             index = streamingMap[index]
102         else:
103             index = nonStreamingMap[index]
104         return index
105        
106     def getWidgetByName(self, name):
107         index = self.getIndexByName(name)
108         widgetName = ''
109         if name[0:3] == 'vol':
110             widgetName = 'sldInput%d' % (index)
111         else:
112             widgetName = 'sldBal%d' % (index)
113         return getattr(self, widgetName)
114            
115     def getFeatureByName(self, name):
116         index = self.getIndexByName(name)
117         featureName = ''
118         if name[0:3] == 'vol':
119             featureName = '/Mixer/Feature_Volume_%d' % ((index + 1) / 2)
120         else:
121             featureName = '/Mixer/Feature_LRBalance_%d' % ((index + 1) / 2)
122         return featureName
123
124     def getChannelIndexByName(self, name):
125         index = self.getIndexByName(name)
126         return ((index - 1) % 2) + 1
127
128     def setValue(self, name, val):
129         log.debug("setting %s to %d" % (name, val))
130         self.updateStreamingState()
131         feature = self.getFeatureByName(name)
132         widget = self.getWidgetByName(name)
133         channel = self.getChannelIndexByName(name)
134         self.hw.setContignuous(feature, val, idx = channel)
135
136     def updateStreamingState(self):
137         ss = self.streamingstatus.selected()
138         ss_txt = self.streamingstatus.getEnumLabel(ss)
139         if ss_txt != 'Idle':
140             self.is_streaming = True
141         else:
142             self.is_streaming = False
143        
144     def initValues(self):
145         self.updateStreamingState()
146        
147         for i in range(1, 11):
148             name = 'vol%d' % i
149             feature = self.getFeatureByName(name)
150             widget = self.getWidgetByName(name)
151             channel = self.getChannelIndexByName(name)
152
153             val = self.hw.getContignuous(feature, idx = channel)
154             log.debug("%s value is %d" % (name , val))
155             widget.setValue(val)
156            
157         for i in range(1, 11):
158             name = 'bal%d' % i
159             feature = self.getFeatureByName(name)
160             widget = self.getWidgetByName(name)
161             channel = self.getChannelIndexByName(name)
162
163             val = self.hw.getContignuous(feature, idx = channel)
164             # Workaround: The current value is not properly initialized
165             # on the device and returns after bootup always 0.
166             # Though we happen to know what the correct value should
167             # be therefore we overwrite the 0
168             if channel == 1:
169                 val = 32512
170             else:
171                 val = -32768
172             log.debug("%s value is %d" % (name , val))
173             widget.setValue(val)
174
175 # vim: et
Note: See TracBrowser for help on using the browser.