Mixer/BeBoB/MAudio: remove unused variables
[ffado.git] / libffado / support / mixer-qt4 / ffado / mixer / maudio_bebob.py
blob6df57343bc2223aaf6635afebf34729e0409f244
1 from PyQt4.QtCore import SIGNAL, QObject, Qt
2 from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, QTabWidget, QGroupBox, QLabel, QSlider, QToolButton, QSizePolicy
3 from math import log10
4 from ffado.config import *
6 import logging
7 log = logging.getLogger('MAudioBeBoB')
9 class MAudio_BeBoB_Input_Widget(QWidget):
10 def __init__(self, parent=None):
11 QWidget.__init__(self, parent)
12 uicLoad("ffado/mixer/maudio_bebob_input", self)
14 class MAudio_BeBoB_Output_Widget(QWidget):
15 def __init__(self, parent=None):
16 QWidget.__init__(self, parent)
17 uicLoad("ffado/mixer/maudio_bebob_output", self)
20 class MAudio_BeBoB(QWidget):
21 def __init__(self, parent=None):
22 QWidget.__init__(self, parent)
24 info = {
25 0x0000000a: (0, "Ozonic"),
26 0x00010062: (1, "Firewire Solo"),
27 0x00010060: (2, "Firewire Audiophile"),
28 0x00010046: (3, "Firewire 410"),
29 0x00010071: (4, "Firewire 1814"),
30 0x00010091: (4, "ProjectMix I/O"),
33 labels = (
35 "inputs": ("Analog 1/2", "Analog 3/4",
36 "Stream 1/2", "Stream 3/4"),
37 "mixers": ("Mixer 1/2", "Mixer 3/4"),
38 "outputs": ("Analog 1/2", "Analog 3/4")
41 "inputs": ("Analog 1/2", "Digital 1/2",
42 "Stream 1/2", "Stream 3/4"),
43 "mixers": ("Mixer 1/2", "Mixer 3/4"),
44 "outputs": ("Analog 1/2", "Digital 1/2")
47 "inputs": ("Analog 1/2", "Digital 1/2",
48 "Stream 1/2", "Stream 3/4", "Stream 5/6"),
49 "mixers": ("Mixer 1/2", "Mixer 3/4", "Mixer 5/6", "Aux 1/2"),
50 "outputs": ("Analog 1/2", "Analog 3/4", "Digital 1/2",
51 "Headphone 1/2")
54 "inputs": ("Analog 1/2", "Digital 1/2",
55 "Stream 1/2", "Stream 3/4", "Stream 5/6",
56 "Stream 7/8", "Stream 9/10"),
57 "mixers": ("Mixer 1/2", "Mixer 3/4", "Mixer 5/6", "Mixer 7/8",
58 "Mixer 9/10", "Aux 1/2"),
59 "outputs": ("Analog 1/2", "Analog 3/4", "Analog 5/6", "Analog 7/8",
60 "Digital 1/2", "Headphone 1/2")
63 "inputs": ("Analog 1/2", "Analog 3/4", "Analog 5/6", "Analog 7/8",
64 "Stream 1/2", "Stream 3/4", "S/PDIF 1/2",
65 "ADAT 1/2", "ADAT 3/4", "ADAT 5/6", "ADAT 7/8"),
66 "mixers": ("Mixer 1/2", "Mixer 3/4", "Aux 1/2"),
67 "outputs": ("Analog 1/2", "Analog 3/4",
68 "Headphone 1/2", "Headphone 3/4")
72 # hardware inputs and stream playbacks
73 # format: function_id/channel_idx/panning-able
74 # NOTE: function_id = channel_idx = panning-able = labels["inputs"]
75 inputs = (
77 (0x03, 0x04, 0x01, 0x02),
78 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
79 (True, True, False, False)
82 (0x01, 0x02, 0x04, 0x03),
83 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
84 (True, True, False, False)
87 (0x04, 0x05, 0x01, 0x02, 0x03),
88 ((0x01, 0x02), (0x01, 0x02),
89 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
90 (True, True, False, False, False)
93 (0x03, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01),
94 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
95 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08)),
96 (True, True, False, False, False, False, False)
99 (0x01, 0x02, 0x03, 0x04, 0x0a, 0x0b, 0x05, 0x06, 0x07, 0x08, 0x09),
100 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
101 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
102 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
103 (True, True, True, True, False, False, True,
104 True, True, True, True)
108 # jack sources except for headphone
109 # format: function_id/source id
110 # NOTE: "function_id" = labels["output"] - "Headphone 1/2/3/4"
111 # NOTE: "source_id" = labels["mixer"]
112 jack_src = (
113 None,
114 None,
115 ((0x01, 0x02, 0x03),
116 (0x00, 0x00, 0x00, 0x01)),
117 ((0x02, 0x03, 0x04, 0x05, 0x06),
118 (0x00, 0x00, 0x00, 0x00, 0x00, 0x01)),
119 ((0x03, 0x04),
120 (0x00, 0x01, 0x02))
123 # headphone sources
124 # format: sink id/source id
125 # NOTE: "source_id" = labels["mixer"]
126 hp_src = (
127 None,
128 None,
129 ((0x04,),
130 (0x00, 0x01, 0x02, 0x03)),
131 ((0x07,),
132 (0x02, 0x03, 0x04, 0x05, 0x06, 0x07)),
133 ((0x01, 0x02),
134 (0x01, 0x02, 0x04))
137 # hardware outputs
138 # format: function id
139 # NOTE: "function_id" = labels["output"]
140 outputs = (
141 (0x05, 0x06),
142 (0x02, 0x03),
143 (0x0c, 0x0d, 0x0e, 0x0f),
144 (0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f),
145 (0x0c, 0x0d, 0x0f, 0x10)
148 # Mixer inputs/outputs
149 # format: function_id/out_stereo_channel_id/in_id/in_stereo_channel_id
150 # NOTE: function_id = out_stereo_channel_id = labels["mixers"]
151 # NOTE: in_id = in_stereo_channel_id = labels["inputs"]
152 mixers = (
154 (0x01, 0x02),
155 ((0x01, 0x02), (0x01, 0x02)),
156 (0x02, 0x03, 0x00, 0x01),
157 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
160 (0x01, 0x01),
161 ((0x01, 0x02), (0x03, 0x04)),
162 (0x00, 0x01, 0x03, 0x02),
163 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
166 (0x01, 0x02, 0x03, 0x04),
167 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
168 (0x03, 0x04, 0x00, 0x01, 0x02),
169 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
170 (0x01, 0x02), (0x01, 0x02))
173 (0x01, 0x01, 0x01, 0x01, 0x01, 0x07),
174 ((0x01, 0x02), (0x03, 0x04),
175 (0x05, 0x06), (0x07, 0x08), (0x09, 0x0a), (0x01, 0x02)),
176 (0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00),
177 ((0x01, 0x02), (0x01, 0x02),
178 (0x01, 0x02), (0x01, 0x02), (0x03, 0x04),
179 (0x05, 0x06), (0x07, 0x08))
182 (0x01, 0x02, 0x03),
183 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
184 (0x01, 0x01, 0x01, 0x01,
185 0x02, 0x02, 0x03,
186 0x04, 0x04, 0x04, 0x04),
187 ((0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08),
188 (0x01, 0x02), (0x03, 0x04), (0x01, 0x02),
189 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08))
193 # Aux mixer inputs/outputs
194 # format: function_id/input_id/input_stereo_channel_id
195 # NOTE: input_id = labels["inputs"]
196 aux = (
197 None,
198 None,
200 0x0b,
201 (0x09, 0x0a, 0x06, 0x07, 0x08),
202 ((0x01, 0x02), (0x01, 0x02),
203 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
206 0x09,
207 (0x07, 0x08, 0x06, 0x05, 0x05, 0x05, 0x05),
208 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
209 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08))
212 0x0e,
213 (0x13, 0x14, 0x15, 0x16, 0x11, 0x12, 0x17, 0x18, 0x19, 0x1a, 0x1b),
214 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
215 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
216 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
220 def getDisplayTitle(self):
221 model = self.configrom.getModelId()
222 return self.info[model][1]
224 def buildMixer(self):
225 self.Selectors = {}
226 self.Pannings = {}
227 self.Volumes = {}
228 self.Mutes = {}
229 self.Mixers = {}
230 self.FW410HP = 0
232 model = self.configrom.getModelId()
233 if model not in self.info:
234 return
236 self.id = self.info[model][0]
238 tabs_layout = QHBoxLayout(self)
239 tabs = QTabWidget(self)
241 self.addInputTab(tabs)
242 self.addMixTab(tabs)
243 if self.aux[self.id] is not None:
244 self.addAuxTab(tabs)
245 self.addOutputTab(tabs)
247 tabs_layout.addWidget(tabs)
250 def addInputTab(self, tabs):
251 tab_input = QWidget(self)
252 tabs.addTab(tab_input, "In")
254 tab_input_layout = QHBoxLayout()
255 tab_input.setLayout(tab_input_layout)
257 in_labels = self.labels[self.id]["inputs"]
258 in_ids = self.inputs[self.id][0]
259 in_pan = self.inputs[self.id][2]
261 for i in range(len(in_ids)):
262 l_idx = self.inputs[self.id][1][i][0]
263 r_idx = self.inputs[self.id][1][i][1]
265 widget = MAudio_BeBoB_Input_Widget(tab_input)
266 tab_input_layout.addWidget(widget)
268 widget.name.setText(in_labels[i])
270 self.Volumes[widget.l_sld] = (
271 "/Mixer/Feature_Volume_%d" % in_ids[i], l_idx,
272 widget.r_sld, r_idx,
273 widget.link
275 self.Volumes[widget.r_sld] = (
276 "/Mixer/Feature_Volume_%d" % in_ids[i], r_idx,
277 widget.l_sld, l_idx,
278 widget.link
280 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
282 if not in_pan[i]:
283 widget.l_pan.setDisabled(True)
284 widget.r_pan.setDisabled(True)
285 else:
286 self.Pannings[widget.l_pan] = (
287 "/Mixer/Feature_LRBalance_%d" % in_ids[i],
288 l_idx
290 self.Pannings[widget.r_pan] = (
291 "/Mixer/Feature_LRBalance_%d" % in_ids[i],
292 r_idx
295 tab_input_layout.addStretch()
298 def addMixTab(self, tabs):
299 tab_mix = QWidget(self)
300 tabs.addTab(tab_mix, "Mix")
302 tab_layout = QHBoxLayout()
303 tab_mix.setLayout(tab_layout)
305 in_labels = self.labels[self.id]["inputs"]
306 in_idxs = self.inputs[self.id][0]
308 mix_labels = self.labels[self.id]["mixers"]
309 mix_idxs = self.mixers[self.id][0]
311 for i in range(len(mix_idxs)):
312 if mix_labels[i] == 'Aux 1/2':
313 continue
315 grp = QGroupBox(tab_mix)
316 grp_layout = QVBoxLayout()
317 grp.setLayout(grp_layout)
318 tab_layout.addWidget(grp)
320 label = QLabel(grp)
321 grp_layout.addWidget(label)
323 label.setText(mix_labels[i])
324 label.setAlignment(Qt.AlignCenter)
325 label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
327 for j in range(len(in_idxs)):
328 mix_in_id = self.mixers[self.id][2][j]
330 button = QToolButton(grp)
331 grp_layout.addWidget(button)
333 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
334 button.setText('%s In' % in_labels[j])
335 button.setCheckable(True)
337 self.Mixers[button] = (
338 "/Mixer/EnhancedMixer_%d" % mix_idxs[i],
339 mix_in_id, j, i
342 grp_layout.addStretch()
343 tab_layout.addStretch()
345 def addAuxTab(self, tabs):
346 #local functions
347 def addLinkButton(parent, layout):
348 button = QToolButton(grp)
349 grp_layout.addWidget(button)
350 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
351 button.setText('Link')
352 button.setCheckable(True)
353 return button
354 def addMuteButton(parent, layout):
355 button = QToolButton(parent)
356 layout.addWidget(button)
357 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
358 button.setText('Mute')
359 button.setCheckable(True)
360 return button
362 # local processing
363 tab_aux = QWidget(self)
364 tabs.addTab(tab_aux, "Aux")
366 layout = QHBoxLayout()
367 tab_aux.setLayout(layout)
369 aux_label = self.labels[self.id]["mixers"][-1]
370 aux_id = self.aux[self.id][0]
372 aux_in_labels = self.labels[self.id]["inputs"]
373 aux_in_ids = self.aux[self.id][1]
375 for i in range(len(aux_in_ids)):
376 in_ch_l = self.aux[self.id][2][i][0]
377 in_ch_r = self.aux[self.id][2][i][1]
379 grp = QGroupBox(tab_aux)
380 grp_layout = QVBoxLayout()
381 grp.setLayout(grp_layout)
382 layout.addWidget(grp)
384 label = QLabel(grp)
385 grp_layout.addWidget(label)
386 label.setText("%s\nIn" % aux_in_labels[i])
387 label.setAlignment(Qt.AlignCenter)
389 grp_sld = QGroupBox(grp)
390 grp_sld_layout = QHBoxLayout()
391 grp_sld.setLayout(grp_sld_layout)
392 grp_layout.addWidget(grp_sld)
394 l_sld = QSlider(grp_sld)
395 grp_sld_layout.addWidget(l_sld)
396 r_sld = QSlider(grp_sld)
397 grp_sld_layout.addWidget(r_sld)
399 button = addLinkButton(grp, grp_layout)
400 self.Volumes[l_sld] = (
401 "/Mixer/Feature_Volume_%d" % aux_in_ids[i], in_ch_l,
402 r_sld, in_ch_r,
403 button
405 self.Volumes[r_sld] = (
406 "/Mixer/Feature_Volume_%d" % aux_in_ids[i], in_ch_r,
407 l_sld, in_ch_l,
408 button
411 button = addMuteButton(grp, grp_layout)
412 self.Mutes[button] = (l_sld, r_sld)
414 grp = QGroupBox(tab_aux)
415 grp_layout = QVBoxLayout()
416 grp.setLayout(grp_layout)
417 layout.addWidget(grp)
419 label = QLabel(grp)
420 grp_layout.addWidget(label)
421 label.setText("%s\nOut" % aux_label)
422 label.setAlignment(Qt.AlignCenter)
424 grp_sld = QGroupBox(grp)
425 grp_sld_layout = QHBoxLayout()
426 grp_sld.setLayout(grp_sld_layout)
427 grp_layout.addWidget(grp_sld)
429 l_sld = QSlider(grp_sld)
430 grp_sld_layout.addWidget(l_sld)
431 r_sld = QSlider(grp_sld)
432 grp_sld_layout.addWidget(r_sld)
434 button = addLinkButton(grp, grp_layout)
435 self.Volumes[l_sld] = (
436 "/Mixer/Feature_Volume_%d" % aux_id, 1,
437 r_sld, 2,
438 button
440 self.Volumes[r_sld] = (
441 "/Mixer/Feature_Volume_%d" % aux_id, 2,
442 l_sld, 1,
443 button
446 button = addMuteButton(grp, grp_layout)
447 self.Mutes[button] = (l_sld, r_sld)
449 layout.addStretch()
451 def addOutputTab(self, tabs):
452 tab_out = QWidget(self)
453 tabs.addTab(tab_out, "Out")
455 layout = QHBoxLayout()
456 tab_out.setLayout(layout)
458 out_labels = self.labels[self.id]["outputs"]
459 out_ids = self.outputs[self.id]
461 mixer_labels = self.labels[self.id]["mixers"]
463 if self.jack_src[self.id] is None:
464 for i in range(len(out_ids)):
465 label = QLabel(tab_out)
466 layout.addWidget(label)
467 label.setText("%s Out is fixed to %s Out" % (mixer_labels[i], out_labels[i]))
468 return
470 mixer_ids = self.jack_src[self.id][1]
473 for i in range(len(out_ids)):
474 out_label = out_labels[i]
475 if out_label.find('Headphone') >= 0:
476 continue
478 out_id = self.jack_src[self.id][0][i]
480 widget = MAudio_BeBoB_Output_Widget(tab_out)
481 layout.addWidget(widget)
483 widget.name.setText(out_label)
485 self.Volumes[widget.l_sld] = (
486 "/Mixer/Feature_Volume_%d" % out_ids[i], 1,
487 widget.r_sld, 2,
488 widget.link
490 self.Volumes[widget.r_sld] = (
491 "/Mixer/Feature_Volume_%d" % out_ids[i], 2,
492 widget.l_sld, 1,
493 widget.link
495 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
497 self.Selectors[widget.cmb_src] = ("/Mixer/Selector_%d" % out_id, )
499 for j in range(len(mixer_ids)):
500 if i != j and j != len(mixer_ids) - 1:
501 continue
502 widget.cmb_src.addItem("%s Out" % mixer_labels[j], mixer_ids[j])
504 # add headphone
505 hp_idx = 0
506 for i in range(len(out_ids)):
507 out_label = out_labels[i]
508 if out_label.find('Headphone') < 0:
509 continue
511 hp_label = self.labels[self.id]["outputs"][i]
512 hp_id = self.hp_src[self.id][0][hp_idx]
513 hp_idx += 1
515 mixer_labels = self.labels[self.id]["mixers"]
517 widget = MAudio_BeBoB_Output_Widget(tab_out)
518 layout.addWidget(widget)
520 widget.name.setText(hp_label)
522 mixer_labels = self.labels[self.id]["mixers"]
523 mixer_ids = self.mixers[self.id][0]
525 self.Volumes[widget.l_sld] = (
526 "/Mixer/Feature_Volume_%d" % out_ids[i], 1,
527 widget.r_sld, 2,
528 widget.link
530 self.Volumes[widget.r_sld] = (
531 "/Mixer/Feature_Volume_%d" % out_ids[i], 2,
532 widget.l_sld, 1,
533 widget.link
535 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
537 for i in range(len(mixer_ids)):
538 widget.cmb_src.addItem("%s Out" % mixer_labels[i], mixer_ids[i])
540 if self.id != 3:
541 self.Selectors[widget.cmb_src] = ("/Mixer/Selector_%d" % hp_id)
542 else:
543 QObject.connect(widget.cmb_src, SIGNAL('activated(int)'), self.update410HP)
544 self.FW410HP = widget.cmb_src
546 layout.addStretch()
548 def initValues(self):
549 for ctl, params in self.Selectors.items():
550 path = params[0]
551 state = self.hw.getDiscrete(path)
552 ctl.setCurrentIndex(state)
553 QObject.connect(ctl, SIGNAL('activated(int)'), self.updateSelector)
555 # Right - Center - Left
556 # 0x8000 - 0x0000 - 0x0001 - 0x7FFE
557 # ..., -1, 0, +1, ...
558 for ctl, params in self.Pannings.items():
559 path = params[0]
560 idx = params[1]
561 curr = self.hw.getContignuous(path, idx)
562 state = -(curr / 0x7FFE) * 50 + 50
563 ctl.setValue(state)
564 QObject.connect(ctl, SIGNAL('valueChanged(int)'), self.updatePanning)
566 for ctl, params in self.Volumes.items():
567 path = params[0]
568 idx = params[1]
569 p_idx = params[3]
570 link = params[4]
572 db = self.hw.getContignuous(path, idx)
573 vol = self.db2vol(db)
574 ctl.setValue(vol)
575 QObject.connect(ctl, SIGNAL('valueChanged(int)'), self.updateVolume)
577 # to activate link button, a pair is checked twice, sign...
578 pair_db = self.hw.getContignuous(path, p_idx)
579 if pair_db == db:
580 link.setChecked(True)
582 for ctl, params in self.Mutes.items():
583 QObject.connect(ctl, SIGNAL('clicked(bool)'), self.updateMute)
585 for ctl, params in self.Mixers.items():
586 path = params[0]
587 in_id = params[1]
588 mix_in_idx = params[2]
589 mix_out_idx = params[3]
590 in_ch_l = self.mixers[self.id][3][mix_in_idx][0]
591 out_ch_l = self.mixers[self.id][1][mix_out_idx][0]
592 # see /libffado/src/bebob/bebob_mixer.cpp
593 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
594 curr = self.hw.getContignuous(path, mux_id)
595 if curr == 0:
596 state = True
597 else:
598 state = False
599 ctl.setChecked(state)
600 QObject.connect(ctl, SIGNAL('clicked(bool)'), self.updateMixer)
602 if self.id == 3:
603 self.read410HP()
605 # helper functions
606 def vol2db(self, vol):
607 return (log10(vol + 1) - 2) * 16384
609 def db2vol(self, db):
610 return pow(10, db / 16384 + 2) - 1
612 def getMultiplexedId(self, in_id, in_ch_l, out_ch_l):
613 # see /libffado/src/bebob/bebob_mixer.cpp
614 return (in_id << 8) | (in_ch_l << 4) | (out_ch_l << 0)
616 def updateSelector(self, state):
617 sender = self.sender()
618 path = self.Selectors[sender][0]
619 log.debug("set %s to %d" % (path, state))
620 self.hw.setDiscrete(path, state)
622 def updatePanning(self, state):
623 sender = self.sender()
624 path = self.Pannings[sender][0]
625 idx = self.Pannings[sender][1]
626 value = (state - 50) * 0x7FFE / -50
627 log.debug("set %s for %d to %d(%d)" % (path, idx, value, state))
628 self.hw.setContignuous(path, value, idx)
630 def updateVolume(self, vol):
631 sender = self.sender()
632 path = self.Volumes[sender][0]
633 idx = self.Volumes[sender][1]
634 pair = self.Volumes[sender][2]
635 link = self.Volumes[sender][4]
637 db = self.vol2db(vol)
638 log.debug("set %s for %d to %d(%d)" % (path, idx, db, vol))
639 self.hw.setContignuous(path, db, idx)
641 if link.isChecked():
642 pair.setValue(vol)
644 # device remeber gain even if muted
645 def updateMute(self, state):
646 sender = self.sender()
647 l_sld = self.Mutes[sender][0]
648 r_sld = self.Mutes[sender][1]
650 if state:
651 db = 0x8000
652 else:
653 db = 0x0000
654 for w in [l_sld, r_sld]:
655 path = self.Volumes[w][0]
656 self.hw.setContignuous(path, db)
657 w.setDisabled(state)
659 def updateMixer(self, checked):
660 if checked:
661 state = 0x0000
662 else:
663 state = 0x8000
665 sender = self.sender()
666 path = self.Mixers[sender][0]
667 in_id = self.Mixers[sender][1]
668 mix_in_idx = self.Mixers[sender][2]
669 mix_out_idx = self.Mixers[sender][3]
670 in_ch_l = self.mixers[self.id][3][mix_in_idx][0]
671 out_ch_l = self.mixers[self.id][1][mix_out_idx][0]
673 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
675 log.debug("set %s for 0x%04X(%d/%d/%d) to %d" % (path, mux_id, in_id, in_ch_l, out_ch_l, state))
676 self.hw.setContignuous(path, state, mux_id)
678 def read410HP(self):
679 path = "/Mixer/Selector_7"
680 sel = self.hw.getDiscrete(path)
681 if sel > 0:
682 enbl = 5
683 else:
684 enbl = -1
686 path = "/Mixer/EnhancedMixer_7"
687 for i in range(5):
688 in_id = 0
689 in_ch_l = i * 2 + 1
690 out_ch_l = 1
691 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
692 state = self.hw.getContignuous(path, mux_id)
693 if enbl < 0 and state == 0:
694 enbl = i
695 else:
696 self.hw.setContignuous(path, 0x8000, mux_id)
697 # if inconsistency between Selector and Mixer, set AUX as default
698 if enbl == -1:
699 self.hw.setDiscrete('/Mixer/Selector_7', 1)
700 enbl = 5
702 self.FW410HP.setCurrentIndex(enbl)
704 def update410HP(self, state):
705 # each output from mixer can be multiplexed in headphone
706 # but here they are exclusive because of GUI simpleness, sigh...
707 path = "/Mixer/EnhancedMixer_7"
708 for i in range(5):
709 in_id = 0
710 in_ch_l = i * 2 + 1
711 out_ch_l = 1
712 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
713 if i == state:
714 value = 0x0000
715 else:
716 value = 0x8000
717 self.hw.setContignuous(path, value, mux_id)
719 # Mixer/Aux is selectable exclusively
720 path = "/Mixer/Selector_7"
721 sel = (state == 5)
722 self.hw.setDiscrete(path, sel)