1 |
# |
---|
2 |
# Copyright (C) 2005-2008 by Pieter Palmers |
---|
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 mixer_phase24ui import * |
---|
26 |
|
---|
27 |
import logging |
---|
28 |
log = logging.getLogger('phase24') |
---|
29 |
|
---|
30 |
class Phase24Control(QWidget, Ui_Phase24ControlUI): |
---|
31 |
def __init__(self,parent = None): |
---|
32 |
QWidget.__init__(self,parent) |
---|
33 |
self.setupUi(self) |
---|
34 |
|
---|
35 |
self.VolumeControls={ |
---|
36 |
'analogin' : ['/Mixer/Feature_Volume_6', self.sldLineIn], |
---|
37 |
'spdifin' : ['/Mixer/Feature_Volume_7', self.sldSPDIFIn], |
---|
38 |
'out12' : ['/Mixer/Feature_Volume_3', self.sldInput12], |
---|
39 |
'out34' : ['/Mixer/Feature_Volume_4', self.sldInput34], |
---|
40 |
'outspdif' : ['/Mixer/Feature_Volume_5', self.sldSPDIFOut], |
---|
41 |
} |
---|
42 |
|
---|
43 |
self.SelectorControls={ |
---|
44 |
'outsource12': ['/Mixer/Selector_1', self.cmbOutSource12], |
---|
45 |
'outsource34': ['/Mixer/Selector_2', self.cmbOutSource34], |
---|
46 |
'outsourcespdif': ['/Mixer/Selector_3', self.cmbOutSourceSPDIF], |
---|
47 |
'syncsource': ['/Mixer/Selector_4', self.cmbSetSyncSource], |
---|
48 |
} |
---|
49 |
|
---|
50 |
# public slot |
---|
51 |
def setVolume12(self,a0): |
---|
52 |
self.setVolume('out12', a0) |
---|
53 |
|
---|
54 |
# public slot |
---|
55 |
def setVolume34(self,a0): |
---|
56 |
self.setVolume('out34', a0) |
---|
57 |
|
---|
58 |
# public slot |
---|
59 |
def setVolumeLineIn(self,a0): |
---|
60 |
self.setVolume('analogin', a0) |
---|
61 |
|
---|
62 |
# public slot |
---|
63 |
def setVolumeSPDIFOut(self,a0): |
---|
64 |
self.setVolume('outspdif', a0) |
---|
65 |
|
---|
66 |
# public slot |
---|
67 |
def setVolumeSPDIFIn(self,a0): |
---|
68 |
self.setVolume('spdifin', a0) |
---|
69 |
|
---|
70 |
# public slot |
---|
71 |
def setVolumeMaster(self,a0): |
---|
72 |
if self.isPhaseX24: |
---|
73 |
return |
---|
74 |
self.setVolume('master', a0) |
---|
75 |
|
---|
76 |
# public slot |
---|
77 |
def setLineLevel(self,a0): |
---|
78 |
log.debug("setting line level to %d" % (a0 * -768)) |
---|
79 |
self.hw.setContignuous('/Mixer/Feature_2', a0 * -768) |
---|
80 |
|
---|
81 |
# public slot |
---|
82 |
def setFrontLevel(self,a0): |
---|
83 |
if self.isPhaseX24: |
---|
84 |
return |
---|
85 |
if(a0 == 0): |
---|
86 |
log.debug("setting front level to %d" % (0)) |
---|
87 |
self.hw.setContignuous('/Mixer/Feature_8', 0) |
---|
88 |
else: |
---|
89 |
log.debug("setting front level to %d" % (1536)) |
---|
90 |
self.hw.setContignuous('/Mixer/Feature_8', 1536) |
---|
91 |
|
---|
92 |
# public slot |
---|
93 |
def setOutSource12(self,a0): |
---|
94 |
self.setSelector('outsource12', a0) |
---|
95 |
|
---|
96 |
# public slot |
---|
97 |
def setOutSource34(self,a0): |
---|
98 |
self.setSelector('outsource34', a0) |
---|
99 |
|
---|
100 |
# public slot |
---|
101 |
def setOutSourceSPDIF(self,a0): |
---|
102 |
self.setSelector('outsourcespdif', a0) |
---|
103 |
|
---|
104 |
# public slot |
---|
105 |
def setSyncSource(self,a0): |
---|
106 |
self.setSelector('syncsource', a0) |
---|
107 |
|
---|
108 |
def setVolume(self,a0,a1): |
---|
109 |
name=a0 |
---|
110 |
vol = -a1 |
---|
111 |
log.debug("setting %s volume to %d" % (name, vol)) |
---|
112 |
self.hw.setContignuous(self.VolumeControls[name][0], vol) |
---|
113 |
|
---|
114 |
def setSelector(self,a0,a1): |
---|
115 |
name=a0 |
---|
116 |
state = a1 |
---|
117 |
log.debug("setting %s state to %d" % (name, state)) |
---|
118 |
self.hw.setDiscrete(self.SelectorControls[name][0], state) |
---|
119 |
|
---|
120 |
def initValues(self): |
---|
121 |
self.modelId = self.configrom.getModelId() |
---|
122 |
if self.modelId == 0x00000007: |
---|
123 |
self.isPhaseX24 = True |
---|
124 |
else: |
---|
125 |
self.isPhaseX24 = False |
---|
126 |
|
---|
127 |
if self.isPhaseX24: |
---|
128 |
self.setWindowTitle("Terratec Phase X24 Control") |
---|
129 |
self.cmbFrontLevel.setEnabled(False) |
---|
130 |
self.sldMaster.setEnabled(False) |
---|
131 |
else: |
---|
132 |
self.setWindowTitle("Terratec Phase 24 Control") |
---|
133 |
|
---|
134 |
self.VolumeControls['master'] = ['/Mixer/Feature_1', self.sldMaster] |
---|
135 |
self.sldMaster.setEnabled(True) |
---|
136 |
|
---|
137 |
self.cmbFrontLevel.setEnabled(True) |
---|
138 |
val = self.hw.getContignuous('/Mixer/Feature_8') |
---|
139 |
if val > 0: |
---|
140 |
self.cmbFrontLevel.setCurrentIndex(1) |
---|
141 |
else: |
---|
142 |
self.cmbFrontLevel.setCurrentIndex(0) |
---|
143 |
|
---|
144 |
for name, ctrl in self.VolumeControls.iteritems(): |
---|
145 |
vol = self.hw.getContignuous(ctrl[0]) |
---|
146 |
log.debug("%s volume is %d" % (name , vol)) |
---|
147 |
ctrl[1].setValue(-vol) |
---|
148 |
|
---|
149 |
for name, ctrl in self.SelectorControls.iteritems(): |
---|
150 |
state = self.hw.getDiscrete(ctrl[0]) |
---|
151 |
log.debug("%s state is %d" % (name , state)) |
---|
152 |
ctrl[1].setCurrentIndex(state) |
---|
153 |
|
---|
154 |
val = self.hw.getContignuous('/Mixer/Feature_2')/-768 |
---|
155 |
if val > 4: |
---|
156 |
self.cmbLineLevel.setCurrentIndex(4) |
---|
157 |
else: |
---|
158 |
self.cmbLineLevel.setCurrentIndex(val) |
---|