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

Revision 2803, 5.3 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

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