Mixer/BeBoB/MAudio: improve the number of characters in a line
[ffado.git] / libffado / support / mixer-qt4 / ffado / mixer / maudio_bebob.py
blob55d7394b3a19aaa25d1bc2a3b06f65143f1c3a79
1 from PyQt4.QtCore import SIGNAL, QObject, Qt
2 from PyQt4.QtGui import QSizePolicy, QHBoxLayout, QVBoxLayout, QGroupBox
3 from PyQt4.QtGui import QWidget, QTabWidget, QLabel, QSlider, QToolButton
4 from math import log10
5 from ffado.config import *
7 import logging
8 log = logging.getLogger('MAudioBeBoB')
10 class MAudio_BeBoB_Input_Widget(QWidget):
11 def __init__(self, parent=None):
12 QWidget.__init__(self, parent)
13 uicLoad("ffado/mixer/maudio_bebob_input", self)
15 class MAudio_BeBoB_Output_Widget(QWidget):
16 def __init__(self, parent=None):
17 QWidget.__init__(self, parent)
18 uicLoad("ffado/mixer/maudio_bebob_output", self)
21 class MAudio_BeBoB(QWidget):
22 def __init__(self, parent=None):
23 QWidget.__init__(self, parent)
25 info = {
26 0x0000000a: (0, "Ozonic"),
27 0x00010062: (1, "Firewire Solo"),
28 0x00010060: (2, "Firewire Audiophile"),
29 0x00010046: (3, "Firewire 410"),
30 0x00010071: (4, "Firewire 1814"),
31 0x00010091: (4, "ProjectMix I/O"),
34 labels = (
36 "inputs": ("Analog 1/2", "Analog 3/4",
37 "Stream 1/2", "Stream 3/4"),
38 "mixers": ("Mixer 1/2", "Mixer 3/4"),
39 "outputs": ("Analog 1/2", "Analog 3/4")
42 "inputs": ("Analog 1/2", "Digital 1/2",
43 "Stream 1/2", "Stream 3/4"),
44 "mixers": ("Mixer 1/2", "Mixer 3/4"),
45 "outputs": ("Analog 1/2", "Digital 1/2")
48 "inputs": ("Analog 1/2", "Digital 1/2",
49 "Stream 1/2", "Stream 3/4", "Stream 5/6"),
50 "mixers": ("Mixer 1/2", "Mixer 3/4", "Mixer 5/6", "Aux 1/2"),
51 "outputs": ("Analog 1/2", "Analog 3/4", "Digital 1/2",
52 "Headphone 1/2")
55 "inputs": ("Analog 1/2", "Digital 1/2",
56 "Stream 1/2", "Stream 3/4", "Stream 5/6",
57 "Stream 7/8", "Stream 9/10"),
58 "mixers": ("Mixer 1/2", "Mixer 3/4", "Mixer 5/6", "Mixer 7/8",
59 "Mixer 9/10", "Aux 1/2"),
60 "outputs": ("Analog 1/2", "Analog 3/4", "Analog 5/6", "Analog 7/8",
61 "Digital 1/2", "Headphone 1/2")
64 "inputs": ("Analog 1/2", "Analog 3/4", "Analog 5/6", "Analog 7/8",
65 "Stream 1/2", "Stream 3/4", "S/PDIF 1/2",
66 "ADAT 1/2", "ADAT 3/4", "ADAT 5/6", "ADAT 7/8"),
67 "mixers": ("Mixer 1/2", "Mixer 3/4", "Aux 1/2"),
68 "outputs": ("Analog 1/2", "Analog 3/4",
69 "Headphone 1/2", "Headphone 3/4")
73 # hardware inputs and stream playbacks
74 # format: function_id/channel_idx/panning-able
75 # NOTE: function_id = channel_idx = panning-able = labels["inputs"]
76 inputs = (
78 (0x03, 0x04, 0x01, 0x02),
79 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
80 (True, True, False, False)
83 (0x01, 0x02, 0x04, 0x03),
84 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
85 (True, True, False, False)
88 (0x04, 0x05, 0x01, 0x02, 0x03),
89 ((0x01, 0x02), (0x01, 0x02),
90 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
91 (True, True, False, False, False)
94 (0x03, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01),
95 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
96 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08)),
97 (True, True, False, False, False, False, False)
100 (0x01, 0x02, 0x03, 0x04, 0x0a, 0x0b, 0x05, 0x06, 0x07, 0x08, 0x09),
101 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
102 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
103 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
104 (True, True, True, True, False, False, True,
105 True, True, True, True)
109 # jack sources except for headphone
110 # format: function_id/source id
111 # NOTE: "function_id" = labels["output"] - "Headphone 1/2/3/4"
112 # NOTE: "source_id" = labels["mixer"]
113 jack_src = (
114 None,
115 None,
116 ((0x01, 0x02, 0x03),
117 (0x00, 0x00, 0x00, 0x01)),
118 ((0x02, 0x03, 0x04, 0x05, 0x06),
119 (0x00, 0x00, 0x00, 0x00, 0x00, 0x01)),
120 ((0x03, 0x04),
121 (0x00, 0x01, 0x02))
124 # headphone sources
125 # format: sink id/source id
126 # NOTE: "source_id" = labels["mixer"]
127 hp_src = (
128 None,
129 None,
130 ((0x04,),
131 (0x00, 0x01, 0x02, 0x03)),
132 ((0x07,),
133 (0x02, 0x03, 0x04, 0x05, 0x06, 0x07)),
134 ((0x01, 0x02),
135 (0x01, 0x02, 0x04))
138 # hardware outputs
139 # format: function id
140 # NOTE: "function_id" = labels["output"]
141 outputs = (
142 (0x05, 0x06),
143 (0x02, 0x03),
144 (0x0c, 0x0d, 0x0e, 0x0f),
145 (0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f),
146 (0x0c, 0x0d, 0x0f, 0x10)
149 # Mixer inputs/outputs
150 # format: function_id/out_stereo_channel_id/in_id/in_stereo_channel_id
151 # NOTE: function_id = out_stereo_channel_id = labels["mixers"]
152 # NOTE: in_id = in_stereo_channel_id = labels["inputs"]
153 mixers = (
155 (0x01, 0x02),
156 ((0x01, 0x02), (0x01, 0x02)),
157 (0x02, 0x03, 0x00, 0x01),
158 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
161 (0x01, 0x01),
162 ((0x01, 0x02), (0x03, 0x04)),
163 (0x00, 0x01, 0x03, 0x02),
164 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
167 (0x01, 0x02, 0x03, 0x04),
168 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
169 (0x03, 0x04, 0x00, 0x01, 0x02),
170 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
171 (0x01, 0x02), (0x01, 0x02))
174 (0x01, 0x01, 0x01, 0x01, 0x01, 0x07),
175 ((0x01, 0x02), (0x03, 0x04),
176 (0x05, 0x06), (0x07, 0x08), (0x09, 0x0a), (0x01, 0x02)),
177 (0x02, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00),
178 ((0x01, 0x02), (0x01, 0x02),
179 (0x01, 0x02), (0x01, 0x02), (0x03, 0x04),
180 (0x05, 0x06), (0x07, 0x08))
183 (0x01, 0x02, 0x03),
184 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02)),
185 (0x01, 0x01, 0x01, 0x01,
186 0x02, 0x02, 0x03,
187 0x04, 0x04, 0x04, 0x04),
188 ((0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08),
189 (0x01, 0x02), (0x03, 0x04), (0x01, 0x02),
190 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08))
194 # Aux mixer inputs/outputs
195 # format: function_id/input_id/input_stereo_channel_id
196 # NOTE: input_id = labels["inputs"]
197 aux = (
198 None,
199 None,
201 0x0b,
202 (0x09, 0x0a, 0x06, 0x07, 0x08),
203 ((0x01, 0x02), (0x01, 0x02),
204 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
207 0x09,
208 (0x07, 0x08, 0x06, 0x05, 0x05, 0x05, 0x05),
209 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
210 (0x01, 0x02), (0x03, 0x04), (0x05, 0x06), (0x07, 0x08))
213 0x0e,
214 (0x13, 0x14, 0x15, 0x16, 0x11, 0x12, 0x17, 0x18, 0x19, 0x1a, 0x1b),
215 ((0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
216 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02),
217 (0x01, 0x02), (0x01, 0x02), (0x01, 0x02), (0x01, 0x02))
221 def getDisplayTitle(self):
222 model = self.configrom.getModelId()
223 return self.info[model][1]
225 def buildMixer(self):
226 self.Selectors = {}
227 self.Pannings = {}
228 self.Volumes = {}
229 self.Mutes = {}
230 self.Mixers = {}
231 self.FW410HP = 0
233 model = self.configrom.getModelId()
234 if model not in self.info:
235 return
237 self.id = self.info[model][0]
239 tabs_layout = QHBoxLayout(self)
240 tabs = QTabWidget(self)
242 self.addInputTab(tabs)
243 self.addMixTab(tabs)
244 if self.aux[self.id] is not None:
245 self.addAuxTab(tabs)
246 self.addOutputTab(tabs)
248 tabs_layout.addWidget(tabs)
251 def addInputTab(self, tabs):
252 tab_input = QWidget(self)
253 tabs.addTab(tab_input, "In")
255 tab_input_layout = QHBoxLayout()
256 tab_input.setLayout(tab_input_layout)
258 in_labels = self.labels[self.id]["inputs"]
259 in_ids = self.inputs[self.id][0]
260 in_pan = self.inputs[self.id][2]
262 for i in range(len(in_ids)):
263 l_idx = self.inputs[self.id][1][i][0]
264 r_idx = self.inputs[self.id][1][i][1]
266 widget = MAudio_BeBoB_Input_Widget(tab_input)
267 tab_input_layout.addWidget(widget)
269 widget.name.setText(in_labels[i])
271 self.Volumes[widget.l_sld] = (
272 "/Mixer/Feature_Volume_%d" % in_ids[i], l_idx,
273 widget.r_sld, r_idx,
274 widget.link
276 self.Volumes[widget.r_sld] = (
277 "/Mixer/Feature_Volume_%d" % in_ids[i], r_idx,
278 widget.l_sld, l_idx,
279 widget.link
281 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
283 if not in_pan[i]:
284 widget.l_pan.setDisabled(True)
285 widget.r_pan.setDisabled(True)
286 else:
287 self.Pannings[widget.l_pan] = (
288 "/Mixer/Feature_LRBalance_%d" % in_ids[i],
289 l_idx
291 self.Pannings[widget.r_pan] = (
292 "/Mixer/Feature_LRBalance_%d" % in_ids[i],
293 r_idx
296 tab_input_layout.addStretch()
299 def addMixTab(self, tabs):
300 tab_mix = QWidget(self)
301 tabs.addTab(tab_mix, "Mix")
303 tab_layout = QHBoxLayout()
304 tab_mix.setLayout(tab_layout)
306 in_labels = self.labels[self.id]["inputs"]
307 in_idxs = self.inputs[self.id][0]
309 mix_labels = self.labels[self.id]["mixers"]
310 mix_idxs = self.mixers[self.id][0]
312 for i in range(len(mix_idxs)):
313 if mix_labels[i] == 'Aux 1/2':
314 continue
316 grp = QGroupBox(tab_mix)
317 grp_layout = QVBoxLayout()
318 grp.setLayout(grp_layout)
319 tab_layout.addWidget(grp)
321 label = QLabel(grp)
322 grp_layout.addWidget(label)
324 label.setText(mix_labels[i])
325 label.setAlignment(Qt.AlignCenter)
326 label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
328 for j in range(len(in_idxs)):
329 mix_in_id = self.mixers[self.id][2][j]
331 button = QToolButton(grp)
332 grp_layout.addWidget(button)
334 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
335 button.setText('%s In' % in_labels[j])
336 button.setCheckable(True)
338 self.Mixers[button] = (
339 "/Mixer/EnhancedMixer_%d" % mix_idxs[i],
340 mix_in_id, j, i
343 grp_layout.addStretch()
344 tab_layout.addStretch()
346 def addAuxTab(self, tabs):
347 #local functions
348 def addLinkButton(parent, layout):
349 button = QToolButton(parent)
350 layout.addWidget(button)
351 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
352 button.setText('Link')
353 button.setCheckable(True)
354 return button
355 def addMuteButton(parent, layout):
356 button = QToolButton(parent)
357 layout.addWidget(button)
358 button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
359 button.setText('Mute')
360 button.setCheckable(True)
361 return button
363 # local processing
364 tab_aux = QWidget(self)
365 tabs.addTab(tab_aux, "Aux")
367 layout = QHBoxLayout()
368 tab_aux.setLayout(layout)
370 aux_label = self.labels[self.id]["mixers"][-1]
371 aux_id = self.aux[self.id][0]
373 aux_in_labels = self.labels[self.id]["inputs"]
374 aux_in_ids = self.aux[self.id][1]
376 for i in range(len(aux_in_ids)):
377 in_ch_l = self.aux[self.id][2][i][0]
378 in_ch_r = self.aux[self.id][2][i][1]
380 grp = QGroupBox(tab_aux)
381 grp_layout = QVBoxLayout()
382 grp.setLayout(grp_layout)
383 layout.addWidget(grp)
385 label = QLabel(grp)
386 grp_layout.addWidget(label)
387 label.setText("%s\nIn" % aux_in_labels[i])
388 label.setAlignment(Qt.AlignCenter)
390 grp_sld = QGroupBox(grp)
391 grp_sld_layout = QHBoxLayout()
392 grp_sld.setLayout(grp_sld_layout)
393 grp_layout.addWidget(grp_sld)
395 l_sld = QSlider(grp_sld)
396 grp_sld_layout.addWidget(l_sld)
397 r_sld = QSlider(grp_sld)
398 grp_sld_layout.addWidget(r_sld)
400 button = addLinkButton(grp, grp_layout)
401 self.Volumes[l_sld] = (
402 "/Mixer/Feature_Volume_%d" % aux_in_ids[i], in_ch_l,
403 r_sld, in_ch_r,
404 button
406 self.Volumes[r_sld] = (
407 "/Mixer/Feature_Volume_%d" % aux_in_ids[i], in_ch_r,
408 l_sld, in_ch_l,
409 button
412 button = addMuteButton(grp, grp_layout)
413 self.Mutes[button] = (l_sld, r_sld)
415 grp = QGroupBox(tab_aux)
416 grp_layout = QVBoxLayout()
417 grp.setLayout(grp_layout)
418 layout.addWidget(grp)
420 label = QLabel(grp)
421 grp_layout.addWidget(label)
422 label.setText("%s\nOut" % aux_label)
423 label.setAlignment(Qt.AlignCenter)
425 grp_sld = QGroupBox(grp)
426 grp_sld_layout = QHBoxLayout()
427 grp_sld.setLayout(grp_sld_layout)
428 grp_layout.addWidget(grp_sld)
430 l_sld = QSlider(grp_sld)
431 grp_sld_layout.addWidget(l_sld)
432 r_sld = QSlider(grp_sld)
433 grp_sld_layout.addWidget(r_sld)
435 button = addLinkButton(grp, grp_layout)
436 self.Volumes[l_sld] = (
437 "/Mixer/Feature_Volume_%d" % aux_id, 1,
438 r_sld, 2,
439 button
441 self.Volumes[r_sld] = (
442 "/Mixer/Feature_Volume_%d" % aux_id, 2,
443 l_sld, 1,
444 button
447 button = addMuteButton(grp, grp_layout)
448 self.Mutes[button] = (l_sld, r_sld)
450 layout.addStretch()
452 def addOutputTab(self, tabs):
453 tab_out = QWidget(self)
454 tabs.addTab(tab_out, "Out")
456 layout = QHBoxLayout()
457 tab_out.setLayout(layout)
459 out_labels = self.labels[self.id]["outputs"]
460 out_ids = self.outputs[self.id]
462 mixer_labels = self.labels[self.id]["mixers"]
464 if self.jack_src[self.id] is None:
465 for i in range(len(out_ids)):
466 label = QLabel(tab_out)
467 layout.addWidget(label)
468 label.setText("%s Out is fixed to %s Out" %
469 (mixer_labels[i], out_labels[i]))
470 return
472 mixer_ids = self.jack_src[self.id][1]
475 for i in range(len(out_ids)):
476 out_label = out_labels[i]
477 if out_label.find('Headphone') >= 0:
478 continue
480 out_id = self.jack_src[self.id][0][i]
482 widget = MAudio_BeBoB_Output_Widget(tab_out)
483 layout.addWidget(widget)
485 widget.name.setText(out_label)
487 self.Volumes[widget.l_sld] = (
488 "/Mixer/Feature_Volume_%d" % out_ids[i], 1,
489 widget.r_sld, 2,
490 widget.link
492 self.Volumes[widget.r_sld] = (
493 "/Mixer/Feature_Volume_%d" % out_ids[i], 2,
494 widget.l_sld, 1,
495 widget.link
497 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
499 self.Selectors[widget.cmb_src] = ("/Mixer/Selector_%d" % out_id, )
501 for j in range(len(mixer_ids)):
502 if i != j and j != len(mixer_ids) - 1:
503 continue
504 widget.cmb_src.addItem("%s Out" % mixer_labels[j], mixer_ids[j])
506 # add headphone
507 hp_idx = 0
508 for i in range(len(out_ids)):
509 out_label = out_labels[i]
510 if out_label.find('Headphone') < 0:
511 continue
513 hp_label = self.labels[self.id]["outputs"][i]
514 hp_id = self.hp_src[self.id][0][hp_idx]
515 hp_idx += 1
517 mixer_labels = self.labels[self.id]["mixers"]
519 widget = MAudio_BeBoB_Output_Widget(tab_out)
520 layout.addWidget(widget)
522 widget.name.setText(hp_label)
524 mixer_labels = self.labels[self.id]["mixers"]
525 mixer_ids = self.mixers[self.id][0]
527 self.Volumes[widget.l_sld] = (
528 "/Mixer/Feature_Volume_%d" % out_ids[i], 1,
529 widget.r_sld, 2,
530 widget.link
532 self.Volumes[widget.r_sld] = (
533 "/Mixer/Feature_Volume_%d" % out_ids[i], 2,
534 widget.l_sld, 1,
535 widget.link
537 self.Mutes[widget.mute] = (widget.l_sld, widget.r_sld)
539 for i in range(len(mixer_ids)):
540 widget.cmb_src.addItem("%s Out" % mixer_labels[i], mixer_ids[i])
542 if self.id != 3:
543 self.Selectors[widget.cmb_src] = ("/Mixer/Selector_%d" % hp_id, )
544 else:
545 QObject.connect(widget.cmb_src, SIGNAL('activated(int)'),
546 self.update410HP)
547 self.FW410HP = widget.cmb_src
549 layout.addStretch()
551 def initValues(self):
552 for ctl, params in self.Selectors.items():
553 path = params[0]
554 state = self.hw.getDiscrete(path)
555 ctl.setCurrentIndex(state)
556 QObject.connect(ctl, SIGNAL('activated(int)'), self.updateSelector)
558 # Right - Center - Left
559 # 0x8000 - 0x0000 - 0x0001 - 0x7FFE
560 # ..., -1, 0, +1, ...
561 for ctl, params in self.Pannings.items():
562 path = params[0]
563 idx = params[1]
564 curr = self.hw.getContignuous(path, idx)
565 state = -(curr / 0x7FFE) * 50 + 50
566 ctl.setValue(state)
567 QObject.connect(ctl, SIGNAL('valueChanged(int)'),
568 self.updatePanning)
570 for ctl, params in self.Volumes.items():
571 path = params[0]
572 idx = params[1]
573 p_idx = params[3]
574 link = params[4]
576 db = self.hw.getContignuous(path, idx)
577 vol = self.db2vol(db)
578 ctl.setValue(vol)
579 QObject.connect(ctl, SIGNAL('valueChanged(int)'), self.updateVolume)
581 # to activate link button, a pair is checked twice, sign...
582 pair_db = self.hw.getContignuous(path, p_idx)
583 if pair_db == db:
584 link.setChecked(True)
586 for ctl, params in self.Mutes.items():
587 QObject.connect(ctl, SIGNAL('clicked(bool)'), self.updateMute)
589 for ctl, params in self.Mixers.items():
590 path = params[0]
591 in_id = params[1]
592 mix_in_idx = params[2]
593 mix_out_idx = params[3]
594 in_ch_l = self.mixers[self.id][3][mix_in_idx][0]
595 out_ch_l = self.mixers[self.id][1][mix_out_idx][0]
596 # see /libffado/src/bebob/bebob_mixer.cpp
597 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
598 curr = self.hw.getContignuous(path, mux_id)
599 if curr == 0:
600 state = True
601 else:
602 state = False
603 ctl.setChecked(state)
604 QObject.connect(ctl, SIGNAL('clicked(bool)'), self.updateMixer)
606 if self.id == 3:
607 self.read410HP()
609 # helper functions
610 def vol2db(self, vol):
611 return (log10(vol + 1) - 2) * 16384
613 def db2vol(self, db):
614 return pow(10, db / 16384 + 2) - 1
616 def getMultiplexedId(self, in_id, in_ch_l, out_ch_l):
617 # see /libffado/src/bebob/bebob_mixer.cpp
618 return (in_id << 8) | (in_ch_l << 4) | (out_ch_l << 0)
620 def updateSelector(self, state):
621 sender = self.sender()
622 path = self.Selectors[sender][0]
623 log.debug("set %s to %d" % (path, state))
624 self.hw.setDiscrete(path, state)
626 def updatePanning(self, state):
627 sender = self.sender()
628 path = self.Pannings[sender][0]
629 idx = self.Pannings[sender][1]
630 value = (state - 50) * 0x7FFE / -50
631 log.debug("set %s for %d to %d(%d)" % (path, idx, value, state))
632 self.hw.setContignuous(path, value, idx)
634 def updateVolume(self, vol):
635 sender = self.sender()
636 path = self.Volumes[sender][0]
637 idx = self.Volumes[sender][1]
638 pair = self.Volumes[sender][2]
639 link = self.Volumes[sender][4]
641 db = self.vol2db(vol)
642 log.debug("set %s for %d to %d(%d)" % (path, idx, db, vol))
643 self.hw.setContignuous(path, db, idx)
645 if link.isChecked():
646 pair.setValue(vol)
648 # device remeber gain even if muted
649 def updateMute(self, state):
650 sender = self.sender()
651 l_sld = self.Mutes[sender][0]
652 r_sld = self.Mutes[sender][1]
654 if state:
655 db = 0x8000
656 else:
657 db = 0x0000
658 for w in [l_sld, r_sld]:
659 path = self.Volumes[w][0]
660 self.hw.setContignuous(path, db)
661 w.setDisabled(state)
663 def updateMixer(self, checked):
664 if checked:
665 state = 0x0000
666 else:
667 state = 0x8000
669 sender = self.sender()
670 path = self.Mixers[sender][0]
671 in_id = self.Mixers[sender][1]
672 mix_in_idx = self.Mixers[sender][2]
673 mix_out_idx = self.Mixers[sender][3]
674 in_ch_l = self.mixers[self.id][3][mix_in_idx][0]
675 out_ch_l = self.mixers[self.id][1][mix_out_idx][0]
677 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
679 log.debug("set %s for 0x%04X(%d/%d/%d) to %d" %
680 (path, mux_id, in_id, in_ch_l, out_ch_l, state))
681 self.hw.setContignuous(path, state, mux_id)
683 def read410HP(self):
684 path = "/Mixer/Selector_7"
685 sel = self.hw.getDiscrete(path)
686 if sel > 0:
687 enbl = 5
688 else:
689 enbl = -1
691 path = "/Mixer/EnhancedMixer_7"
692 for i in range(5):
693 in_id = 0
694 in_ch_l = i * 2 + 1
695 out_ch_l = 1
696 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
697 state = self.hw.getContignuous(path, mux_id)
698 if enbl < 0 and state == 0:
699 enbl = i
700 else:
701 self.hw.setContignuous(path, 0x8000, mux_id)
702 # if inconsistency between Selector and Mixer, set AUX as default
703 if enbl == -1:
704 self.hw.setDiscrete('/Mixer/Selector_7', 1)
705 enbl = 5
707 self.FW410HP.setCurrentIndex(enbl)
709 def update410HP(self, state):
710 # each output from mixer can be multiplexed in headphone
711 # but here they are exclusive because of GUI simpleness, sigh...
712 path = "/Mixer/EnhancedMixer_7"
713 for i in range(5):
714 in_id = 0
715 in_ch_l = i * 2 + 1
716 out_ch_l = 1
717 mux_id = self.getMultiplexedId(in_id, in_ch_l, out_ch_l)
718 if i == state:
719 value = 0x0000
720 else:
721 value = 0x8000
722 self.hw.setContignuous(path, value, mux_id)
724 # Mixer/Aux is selectable exclusively
725 path = "/Mixer/Selector_7"
726 sel = (state == 5)
727 self.hw.setDiscrete(path, sel)