1 |
# |
---|
2 |
# Copyright (C) 2009 by Jonathan Woithe |
---|
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, Qt |
---|
24 |
from PyQt4.QtGui import QWidget, QApplication |
---|
25 |
from mixer_rmeui import * |
---|
26 |
|
---|
27 |
import logging |
---|
28 |
log = logging.getLogger('rme') |
---|
29 |
|
---|
30 |
# Model defines. These must agree with what is used in rme_avdevice.h. |
---|
31 |
RME_MODEL_NONE = 0x0000 |
---|
32 |
RME_MODEL_FF800 = 0x0001 |
---|
33 |
RME_MODEL_FF400 = 0x0002 |
---|
34 |
|
---|
35 |
class RmeMixer(QWidget, Ui_RmeMixerUI): |
---|
36 |
def __init__(self,parent = None): |
---|
37 |
QWidget.__init__(self,parent) |
---|
38 |
self.setupUi(self) |
---|
39 |
|
---|
40 |
self.init() |
---|
41 |
|
---|
42 |
def init(self): |
---|
43 |
|
---|
44 |
self.PhantomSwitches={ |
---|
45 |
self.phantom_0: ['/Control/Phantom', 0], |
---|
46 |
self.phantom_1: ['/Control/Phantom', 1], |
---|
47 |
self.phantom_2: ['/Control/Phantom', 2], |
---|
48 |
self.phantom_3: ['/Control/Phantom', 3], |
---|
49 |
} |
---|
50 |
|
---|
51 |
self.Switches={ |
---|
52 |
self.ff400_chan3_opt_instr: ['/Control/Chan3_opt_instr'], |
---|
53 |
self.ff400_chan3_opt_pad: ['/Control/Chan3_opt_pad'], |
---|
54 |
self.ff400_chan4_opt_instr: ['/Control/Chan4_opt_instr'], |
---|
55 |
self.ff400_chan4_opt_pad: ['/Control/Chan4_opt_pad'], |
---|
56 |
} |
---|
57 |
|
---|
58 |
self.Radiobuttons={ |
---|
59 |
self.level_in_lo_gain: ['/Control/Input_level', 1], |
---|
60 |
self.level_in_p4dBu: ['/Control/Input_level', 2], |
---|
61 |
self.level_in_m10dBV: ['/Control/Input_level', 3], |
---|
62 |
|
---|
63 |
self.level_out_hi_gain: ['/Control/Output_level', 1], |
---|
64 |
self.level_out_p4dBu: ['/Control/Output_level', 2], |
---|
65 |
self.level_out_m10dBV: ['/Control/Output_level', 3], |
---|
66 |
|
---|
67 |
self.phones_hi_gain: ['/Control/Phones_level', 1], |
---|
68 |
self.phones_p4dBu: ['/Control/Phones_level', 2], |
---|
69 |
self.phones_m10dBV: ['/Control/Phones_level', 3], |
---|
70 |
} |
---|
71 |
|
---|
72 |
|
---|
73 |
self.Gains={ |
---|
74 |
self.gain_mic1: ['/Control/Gains', 0], |
---|
75 |
self.gain_mic2: ['/Control/Gains', 1], |
---|
76 |
self.gain_input3: ['/Control/Gains', 2], |
---|
77 |
self.gain_input4: ['/Control/Gains', 3], |
---|
78 |
} |
---|
79 |
|
---|
80 |
# Other mixer variables |
---|
81 |
self.is_streaming = 0 |
---|
82 |
self.sample_rate = 0 |
---|
83 |
self.model = 0 |
---|
84 |
self.tco_present = 0 |
---|
85 |
|
---|
86 |
# Public slot: update phantom power hardware switches |
---|
87 |
def updatePhantomSwitch(self, a0): |
---|
88 |
sender = self.sender() |
---|
89 |
# Value is the phantom switch value, with a corresponding enable |
---|
90 |
# bit in the high 16 bit word |
---|
91 |
val = (a0 << self.PhantomSwitches[sender][1]) | (0x00010000 << self.PhantomSwitches[sender][1]) |
---|
92 |
log.debug("phantom switch %d set to %d" % (self.PhantomSwitches[sender][1], a0)) |
---|
93 |
self.hw.setDiscrete(self.PhantomSwitches[sender][0], val) |
---|
94 |
|
---|
95 |
# Public slot: update generic switches |
---|
96 |
def updateSwitch(self, a0): |
---|
97 |
sender = self.sender() |
---|
98 |
log.debug("switch %s set to %d" % (self.Switches[sender][0], a0)) |
---|
99 |
self.hw.setDiscrete(self.Switches[sender][0], a0) |
---|
100 |
|
---|
101 |
# Public slot: update generic radiobuttons |
---|
102 |
def updateRadiobutton(self, a0): |
---|
103 |
sender = self.sender() |
---|
104 |
if (a0 != 0): |
---|
105 |
# Only change the control state on a button being "checked" |
---|
106 |
log.debug("radiobutton group %s set to %d" % (self.Radiobuttons[sender][0], self.Radiobuttons[sender][1])) |
---|
107 |
self.hw.setDiscrete(self.Radiobuttons[sender][0], self.Radiobuttons[sender][1]) |
---|
108 |
|
---|
109 |
# Public slot: update gains |
---|
110 |
def updateGain(self, a0): |
---|
111 |
sender = self.sender() |
---|
112 |
log.debug("gain %s[%d] set to %d" % (self.Gains[sender][0], self.Gains[sender][1], a0)) |
---|
113 |
self.hw.setMatrixMixerValue(self.Gains[sender][0], 0, self.Gains[sender][1], a0) |
---|
114 |
|
---|
115 |
# Hide and disable a control |
---|
116 |
def disable_hide(self,widget): |
---|
117 |
widget.hide() |
---|
118 |
widget.setEnabled(False) |
---|
119 |
|
---|
120 |
def initValues(self): |
---|
121 |
# Is the device streaming? |
---|
122 |
#self.is_streaming = self.hw.getDiscrete('/Mixer/Info/IsStreaming') |
---|
123 |
self.is_streaming = 0 |
---|
124 |
#log.debug("device streaming flag: %d" % (self.is_streaming)) |
---|
125 |
|
---|
126 |
# Retrieve other device settings as needed and customise the UI |
---|
127 |
# based on these options. |
---|
128 |
self.model = self.hw.getDiscrete('/Control/Model') |
---|
129 |
log.debug("device model identifier: %d" % (self.model)) |
---|
130 |
self.tco_present = self.hw.getDiscrete('/Control/TCO_present') |
---|
131 |
log.debug("device has TCO: %d" % (self.tco_present)) |
---|
132 |
#self.sample_rate = self.hw.getDiscrete('/Mixer/Info/SampleRate') |
---|
133 |
#log.debug("device sample rate: %d" % (self.sample_rate)) |
---|
134 |
|
---|
135 |
# The Fireface-400 only has 2 phantom-capable channels |
---|
136 |
if (self.model == RME_MODEL_FF400): |
---|
137 |
self.disable_hide(self.phantom_2) |
---|
138 |
self.disable_hide(self.phantom_3) |
---|
139 |
else: |
---|
140 |
self.phantom_0.setText("Mic 7") |
---|
141 |
self.phantom_1.setText("Mic 8") |
---|
142 |
self.phantom_2.setText("Mic 9") |
---|
143 |
self.phantom_3.setText("Mic 10") |
---|
144 |
|
---|
145 |
# Instrument options, input jack selection controls and an ADAT2 |
---|
146 |
# input are applicable only to the FF800 |
---|
147 |
if (self.model != RME_MODEL_FF800): |
---|
148 |
self.instrument_options_group.setEnabled(False) |
---|
149 |
self.input_plug_select_group.setEnabled(False) |
---|
150 |
self.sync_ref_adat2.setEnabled(False) |
---|
151 |
self.sync_check_adat2_label.setEnabled(False) |
---|
152 |
self.sync_check_adat2_status.setEnabled(False) |
---|
153 |
|
---|
154 |
# Only the FF400 has specific channel 3/4 options, input gain |
---|
155 |
# controls and switchable phones level |
---|
156 |
if (self.model != RME_MODEL_FF400): |
---|
157 |
self.disable_hide(self.input_gains_group) |
---|
158 |
self.disable_hide(self.channel_3_4_options_group) |
---|
159 |
self.phones_level_group.setEnabled(False) |
---|
160 |
|
---|
161 |
# Get current hardware values and connect GUI element signals to |
---|
162 |
# their respective slots |
---|
163 |
for ctrl, info in self.PhantomSwitches.iteritems(): |
---|
164 |
if (not(ctrl.isEnabled())): |
---|
165 |
continue |
---|
166 |
val = (self.hw.getDiscrete(info[0]) >> info[1]) & 0x01 |
---|
167 |
log.debug("phantom switch %d is %d" % (info[1], val)) |
---|
168 |
if val: |
---|
169 |
ctrl.setChecked(True) |
---|
170 |
else: |
---|
171 |
ctrl.setChecked(False) |
---|
172 |
QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updatePhantomSwitch) |
---|
173 |
|
---|
174 |
for ctrl, info in self.Switches.iteritems(): |
---|
175 |
if (not(ctrl.isEnabled())): |
---|
176 |
continue |
---|
177 |
val = self.hw.getDiscrete(info[0]) |
---|
178 |
log.debug("switch %s is %d" % (info[0], val)) |
---|
179 |
if val: |
---|
180 |
ctrl.setChecked(True) |
---|
181 |
else: |
---|
182 |
ctrl.setChecked(False) |
---|
183 |
QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateSwitch) |
---|
184 |
|
---|
185 |
for ctrl, info in self.Radiobuttons.iteritems(): |
---|
186 |
if (not(ctrl.isEnabled())): |
---|
187 |
continue; |
---|
188 |
# This is a touch wasteful since it means we retrieve the control |
---|
189 |
# value once per radio button rather than once per radio button |
---|
190 |
# group. In time we might introduce radiobutton groupings in the |
---|
191 |
# self.* datastructures to avoid this, but for the moment this is |
---|
192 |
# easy and it works. |
---|
193 |
val = self.hw.getDiscrete(info[0]) |
---|
194 |
if (val == info[1]): |
---|
195 |
val = 1 |
---|
196 |
else: |
---|
197 |
val = 0 |
---|
198 |
ctrl.setChecked(val) |
---|
199 |
log.debug("Radiobutton %s[%d] is %d" % (info[0], info[1], val)) |
---|
200 |
QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updateRadiobutton) |
---|
201 |
|
---|
202 |
for ctrl, info in self.Gains.iteritems(): |
---|
203 |
if (not(ctrl.isEnabled())): |
---|
204 |
continue |
---|
205 |
val = self.hw.getMatrixMixerValue(info[0], 0, info[1]) |
---|
206 |
log.debug("gain %s[%d] is %d" % (info[0], info[1], val)) |
---|
207 |
ctrl.setValue(val); |
---|
208 |
QObject.connect(ctrl, SIGNAL('valueChanged(int)'), self.updateGain) |
---|