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