| 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, Qt |
|---|
| 24 |
from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, \ |
|---|
| 25 |
QGroupBox, QTabWidget, QLabel, \ |
|---|
| 26 |
QPushButton, QSpacerItem, QSizePolicy |
|---|
| 27 |
from mixer_audiofire_stripui import Ui_AfMonitorWidget |
|---|
| 28 |
from mixer_audiofire_settingsui import Ui_AfSettingsWidget |
|---|
| 29 |
import logging |
|---|
| 30 |
log = logging.getLogger('audiofire') |
|---|
| 31 |
|
|---|
| 32 |
class AfMonitorWidget(QWidget, Ui_AfMonitorWidget): |
|---|
| 33 |
def __init__(self,parent = None): |
|---|
| 34 |
QWidget.__init__(self,parent) |
|---|
| 35 |
self.setupUi(self) |
|---|
| 36 |
|
|---|
| 37 |
class AfSettingsWidget(QWidget, Ui_AfSettingsWidget): |
|---|
| 38 |
def __init__(self,parent = None): |
|---|
| 39 |
QWidget.__init__(self,parent) |
|---|
| 40 |
self.setupUi(self) |
|---|
| 41 |
|
|---|
| 42 |
class AudioFireMixer(QWidget): |
|---|
| 43 |
def __init__(self,parent = None): |
|---|
| 44 |
QWidget.__init__(self,parent) |
|---|
| 45 |
log.debug("Init AudioFire mixer window") |
|---|
| 46 |
|
|---|
| 47 |
def getDisplayTitle(self): |
|---|
| 48 |
modelId = self.configrom.getModelId() |
|---|
| 49 |
if modelId == 0x0AF2: |
|---|
| 50 |
return "AudioFire2" |
|---|
| 51 |
if modelId == 0x0AF4: |
|---|
| 52 |
return "AudioFire4" |
|---|
| 53 |
if modelId == 0x0AF8: |
|---|
| 54 |
return "AudioFire8" |
|---|
| 55 |
if modelId == 0x0AF12: |
|---|
| 56 |
return "AudioFire12" |
|---|
| 57 |
return "Generic FireWorks" |
|---|
| 58 |
|
|---|
| 59 |
def updateMatrixButton(self,a0): |
|---|
| 60 |
sender = self.sender() |
|---|
| 61 |
if a0: |
|---|
| 62 |
state = 1 |
|---|
| 63 |
else: |
|---|
| 64 |
state = 0 |
|---|
| 65 |
log.debug("set %s %d %d to %d" % ( |
|---|
| 66 |
self.MatrixButtonControls[sender][0], |
|---|
| 67 |
self.MatrixButtonControls[sender][1], |
|---|
| 68 |
self.MatrixButtonControls[sender][2], |
|---|
| 69 |
state)) |
|---|
| 70 |
self.hw.setMatrixMixerValue(self.MatrixButtonControls[sender][0], |
|---|
| 71 |
self.MatrixButtonControls[sender][1], |
|---|
| 72 |
self.MatrixButtonControls[sender][2], |
|---|
| 73 |
state) |
|---|
| 74 |
|
|---|
| 75 |
def updateMatrixRotary(self,a0): |
|---|
| 76 |
sender = self.sender() |
|---|
| 77 |
vol = a0 |
|---|
| 78 |
log.debug("set %s %d %d to %d" % ( |
|---|
| 79 |
self.MatrixRotaryControls[sender][0], |
|---|
| 80 |
self.MatrixRotaryControls[sender][1], |
|---|
| 81 |
self.MatrixRotaryControls[sender][2], |
|---|
| 82 |
vol)) |
|---|
| 83 |
self.hw.setMatrixMixerValue(self.MatrixRotaryControls[sender][0], |
|---|
| 84 |
self.MatrixRotaryControls[sender][1], |
|---|
| 85 |
self.MatrixRotaryControls[sender][2], |
|---|
| 86 |
vol) |
|---|
| 87 |
|
|---|
| 88 |
def updateMatrixVolume(self,a0): |
|---|
| 89 |
sender = self.sender() |
|---|
| 90 |
vol = a0 |
|---|
| 91 |
#vol = 0x01000000-vol |
|---|
| 92 |
log.debug("set %s %d %d to %d" % ( |
|---|
| 93 |
self.MatrixVolumeControls[sender][0], |
|---|
| 94 |
self.MatrixVolumeControls[sender][1], |
|---|
| 95 |
self.MatrixVolumeControls[sender][2], |
|---|
| 96 |
vol)) |
|---|
| 97 |
self.hw.setMatrixMixerValue(self.MatrixVolumeControls[sender][0], |
|---|
| 98 |
self.MatrixVolumeControls[sender][1], |
|---|
| 99 |
self.MatrixVolumeControls[sender][2], |
|---|
| 100 |
vol) |
|---|
| 101 |
|
|---|
| 102 |
def updateVolume(self,a0): |
|---|
| 103 |
sender = self.sender() |
|---|
| 104 |
vol = a0 |
|---|
| 105 |
#vol = 0x01000000-vol |
|---|
| 106 |
log.debug("set %s to %d" % ( |
|---|
| 107 |
self.VolumeControls[sender][0], |
|---|
| 108 |
vol)) |
|---|
| 109 |
self.hw.setContignuous(self.VolumeControls[sender][0], |
|---|
| 110 |
vol) |
|---|
| 111 |
|
|---|
| 112 |
def updateSelector(self,a0): |
|---|
| 113 |
sender = self.sender() |
|---|
| 114 |
if a0: |
|---|
| 115 |
state = 1 |
|---|
| 116 |
else: |
|---|
| 117 |
state = 0 |
|---|
| 118 |
log.debug("set %s to %d" % ( |
|---|
| 119 |
self.SelectorControls[sender][0], |
|---|
| 120 |
state)) |
|---|
| 121 |
self.hw.setDiscrete(self.SelectorControls[sender][0], state) |
|---|
| 122 |
|
|---|
| 123 |
def updateTrigger(self): |
|---|
| 124 |
sender = self.sender() |
|---|
| 125 |
log.debug("trigger %s" % (self.TriggerControls[sender][0])) |
|---|
| 126 |
self.hw.setDiscrete(self.TriggerControls[sender][0], 1) |
|---|
| 127 |
|
|---|
| 128 |
def updateSPDIFmodeControl(self,a0): |
|---|
| 129 |
sender = self.sender() |
|---|
| 130 |
if a0: |
|---|
| 131 |
state = 1 |
|---|
| 132 |
else: |
|---|
| 133 |
state = 0 |
|---|
| 134 |
if state: |
|---|
| 135 |
log.debug("set %s to %d" % ( |
|---|
| 136 |
self.SPDIFmodeControls[sender][0], |
|---|
| 137 |
self.SPDIFmodeControls[sender][1])) |
|---|
| 138 |
self.hw.setDiscrete(self.SPDIFmodeControls[sender][0], self.SPDIFmodeControls[sender][1]) |
|---|
| 139 |
|
|---|
| 140 |
def buildMixer(self): |
|---|
| 141 |
log.debug("Building mixer") |
|---|
| 142 |
self.MatrixButtonControls={} |
|---|
| 143 |
self.MatrixRotaryControls={} |
|---|
| 144 |
self.MatrixVolumeControls={} |
|---|
| 145 |
self.VolumeControls={} |
|---|
| 146 |
self.SelectorControls={} |
|---|
| 147 |
self.SPDIFmodeControls={} |
|---|
| 148 |
self.TriggerControls={} |
|---|
| 149 |
|
|---|
| 150 |
nb_pys_out = self.hw.getDiscrete("/HwInfo/PhysicalAudioOutCount") |
|---|
| 151 |
nb_pys_in = self.hw.getDiscrete("/HwInfo/PhysicalAudioInCount") |
|---|
| 152 |
|
|---|
| 153 |
outputtabslayout = QHBoxLayout( self ) |
|---|
| 154 |
outputtabs = QTabWidget(self) |
|---|
| 155 |
outputtabslayout.addWidget( outputtabs, 1 ) |
|---|
| 156 |
|
|---|
| 157 |
for outpair in range(nb_pys_out/2): |
|---|
| 158 |
tab = QWidget( outputtabs ) |
|---|
| 159 |
tablayout = QHBoxLayout( tab ) |
|---|
| 160 |
|
|---|
| 161 |
grpMonitor = QGroupBox(tab) |
|---|
| 162 |
tablayout.addWidget(grpMonitor) |
|---|
| 163 |
|
|---|
| 164 |
grpPlayback = QGroupBox(tab) |
|---|
| 165 |
tablayout.addWidget(grpPlayback) |
|---|
| 166 |
|
|---|
| 167 |
grpOutput = QGroupBox(tab) |
|---|
| 168 |
tablayout.addWidget(grpOutput) |
|---|
| 169 |
|
|---|
| 170 |
grpMonitor.setTitle("Monitor") |
|---|
| 171 |
grpPlayback.setTitle("Playback") |
|---|
| 172 |
grpOutput.setTitle("Output") |
|---|
| 173 |
|
|---|
| 174 |
# monitor controls |
|---|
| 175 |
grpMonitorLayout = QHBoxLayout() |
|---|
| 176 |
grpMonitor.setLayout(grpMonitorLayout); |
|---|
| 177 |
output_id = outpair * 2 |
|---|
| 178 |
for inpair in range(nb_pys_in/2): |
|---|
| 179 |
# create GUI elements |
|---|
| 180 |
strip = AfMonitorWidget( grpMonitor ) |
|---|
| 181 |
grpMonitorLayout.addWidget( strip, 1 ) |
|---|
| 182 |
input_id = inpair*2 |
|---|
| 183 |
strip.lblName.setText("IN %d/%d" % (input_id+1, input_id+2)) |
|---|
| 184 |
|
|---|
| 185 |
# add the elements to the control structure |
|---|
| 186 |
|
|---|
| 187 |
self.MatrixButtonControls[strip.btnMute0] = ['/Mixer/MonitorMute', input_id, output_id] |
|---|
| 188 |
self.MatrixButtonControls[strip.btnMute1] = ['/Mixer/MonitorMute', input_id + 1, output_id + 1] |
|---|
| 189 |
self.MatrixButtonControls[strip.btnSolo0] = ['/Mixer/MonitorSolo', input_id, output_id] |
|---|
| 190 |
self.MatrixButtonControls[strip.btnSolo1] = ['/Mixer/MonitorSolo', input_id + 1, output_id + 1] |
|---|
| 191 |
self.MatrixRotaryControls[strip.rotPan0] = ['/Mixer/MonitorPan', input_id, output_id] |
|---|
| 192 |
self.MatrixRotaryControls[strip.rotPan1] = ['/Mixer/MonitorPan', input_id + 1, output_id + 1] |
|---|
| 193 |
self.MatrixVolumeControls[strip.sldGain0] = ['/Mixer/MonitorGain', input_id, output_id] |
|---|
| 194 |
self.MatrixVolumeControls[strip.sldGain1] = ['/Mixer/MonitorGain', input_id + 1, output_id + 1] |
|---|
| 195 |
|
|---|
| 196 |
# playback |
|---|
| 197 |
grpPlaybackLayout = QHBoxLayout() |
|---|
| 198 |
grpPlayback.setLayout(grpPlaybackLayout); |
|---|
| 199 |
strip = AfMonitorWidget( grpPlayback ) |
|---|
| 200 |
grpPlaybackLayout.addWidget(strip, 1) |
|---|
| 201 |
strip.lblName.setText("Playback %d/%d" % (output_id+1, output_id+2)) |
|---|
| 202 |
|
|---|
| 203 |
self.VolumeControls[strip.sldGain0] = ["/Mixer/PC%dGain" % (output_id)] |
|---|
| 204 |
self.VolumeControls[strip.sldGain1] = ["/Mixer/PC%dGain" % (output_id+1)] |
|---|
| 205 |
self.SelectorControls[strip.btnMute0] = ["/Mixer/PC%dMute" % (output_id)] |
|---|
| 206 |
self.SelectorControls[strip.btnMute1] = ["/Mixer/PC%dMute" % (output_id+1)] |
|---|
| 207 |
self.SelectorControls[strip.btnSolo0] = ["/Mixer/PC%dSolo" % (output_id)] |
|---|
| 208 |
self.SelectorControls[strip.btnSolo1] = ["/Mixer/PC%dSolo" % (output_id+1)] |
|---|
| 209 |
|
|---|
| 210 |
# fix up mixer strip gui |
|---|
| 211 |
strip.rotPan0.hide() |
|---|
| 212 |
strip.rotPan1.hide() |
|---|
| 213 |
|
|---|
| 214 |
# output |
|---|
| 215 |
grpOutputLayout = QHBoxLayout() |
|---|
| 216 |
grpOutput.setLayout(grpOutputLayout); |
|---|
| 217 |
strip = AfMonitorWidget( grpOutput ) |
|---|
| 218 |
grpOutputLayout.addWidget(strip, 1) |
|---|
| 219 |
strip.lblName.setText("Output %d/%d" % (output_id+1, output_id+2)) |
|---|
| 220 |
|
|---|
| 221 |
self.VolumeControls[strip.sldGain0] = ["/Mixer/OUT%dGain" % (output_id)] |
|---|
| 222 |
self.VolumeControls[strip.sldGain1] = ["/Mixer/OUT%dGain" % (output_id+1)] |
|---|
| 223 |
self.SelectorControls[strip.btnMute0] = ["/Mixer/OUT%dMute" % (output_id)] |
|---|
| 224 |
self.SelectorControls[strip.btnMute1] = ["/Mixer/OUT%dMute" % (output_id+1)] |
|---|
| 225 |
self.SelectorControls[strip.btnSolo0] = ["/Mixer/OUT%dNominal" % (output_id)] |
|---|
| 226 |
self.SelectorControls[strip.btnSolo1] = ["/Mixer/OUT%dNominal" % (output_id+1)] |
|---|
| 227 |
|
|---|
| 228 |
# fix up mixer strip gui |
|---|
| 229 |
strip.btnSolo0.setText("Pad") |
|---|
| 230 |
strip.btnSolo1.setText("Pad") |
|---|
| 231 |
strip.rotPan0.hide() |
|---|
| 232 |
strip.rotPan1.hide() |
|---|
| 233 |
|
|---|
| 234 |
# add the tab |
|---|
| 235 |
outputtabs.addTab( tab, "OUT %d/%d" % (output_id+1, output_id+2)) |
|---|
| 236 |
|
|---|
| 237 |
# add an input config tab |
|---|
| 238 |
tab = QWidget( outputtabs ) |
|---|
| 239 |
tablayout = QHBoxLayout( tab ) |
|---|
| 240 |
|
|---|
| 241 |
for inpair in range(nb_pys_in): |
|---|
| 242 |
# create GUI elements |
|---|
| 243 |
log.debug("strip") |
|---|
| 244 |
grpInput = QGroupBox(tab) |
|---|
| 245 |
tablayout.addWidget(grpInput) |
|---|
| 246 |
grpInput.setTitle("IN %d" % (inpair+1)) |
|---|
| 247 |
|
|---|
| 248 |
grpInputLayout = QVBoxLayout() |
|---|
| 249 |
grpInput.setLayout(grpInputLayout); |
|---|
| 250 |
|
|---|
| 251 |
label = QLabel( grpInput ) |
|---|
| 252 |
grpInputLayout.addWidget( label ) |
|---|
| 253 |
label.setText("frienlyname %d" % (inpair+1)) |
|---|
| 254 |
label.setAlignment(Qt.AlignCenter) |
|---|
| 255 |
|
|---|
| 256 |
btn = QPushButton( grpInput ) |
|---|
| 257 |
grpInputLayout.addWidget( btn ) |
|---|
| 258 |
btn.setText("Pad") |
|---|
| 259 |
btn.setCheckable(True) |
|---|
| 260 |
self.SelectorControls[btn] = ["/Mixer/IN%dNominal" % (inpair)] |
|---|
| 261 |
|
|---|
| 262 |
spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding) |
|---|
| 263 |
grpInputLayout.addItem(spacer) |
|---|
| 264 |
|
|---|
| 265 |
outputtabs.addTab( tab, "INPUT") |
|---|
| 266 |
|
|---|
| 267 |
# add an settings tab |
|---|
| 268 |
tab = QWidget( outputtabs ) |
|---|
| 269 |
tablayout = QHBoxLayout( tab ) |
|---|
| 270 |
outputtabs.addTab( tab, "SETTINGS") |
|---|
| 271 |
settings = AfSettingsWidget( tab ) |
|---|
| 272 |
|
|---|
| 273 |
has_sw_phantom = self.hw.getDiscrete("/HwInfo/PhantomPower") |
|---|
| 274 |
if has_sw_phantom: |
|---|
| 275 |
self.SelectorControls[settings.btnPhantom] = ["/PhantomPower"] |
|---|
| 276 |
else: |
|---|
| 277 |
settings.btnPhantom.hide() |
|---|
| 278 |
|
|---|
| 279 |
self.TriggerControls[settings.btnSaveSettings] = ["/SaveSettings"] |
|---|
| 280 |
self.TriggerControls[settings.btnIdentify] = ["/Identify"] |
|---|
| 281 |
|
|---|
| 282 |
self.SPDIFmodeControls[settings.radioConsumer] = ["/SpdifMode", 0] |
|---|
| 283 |
self.SPDIFmodeControls[settings.radioProfessional] = ["/SpdifMode", 1] |
|---|
| 284 |
|
|---|
| 285 |
def initValues(self): |
|---|
| 286 |
log.debug("Init values") |
|---|
| 287 |
|
|---|
| 288 |
for ctrl, info in self.MatrixVolumeControls.iteritems(): |
|---|
| 289 |
vol = self.hw.getMatrixMixerValue(self.MatrixVolumeControls[ctrl][0], |
|---|
| 290 |
self.MatrixVolumeControls[ctrl][1], |
|---|
| 291 |
self.MatrixVolumeControls[ctrl][2]) |
|---|
| 292 |
|
|---|
| 293 |
#vol = 0x01000000-vol |
|---|
| 294 |
log.debug("%s volume is %d" % (ctrl.objectName() , vol)) |
|---|
| 295 |
ctrl.setValue(vol) |
|---|
| 296 |
|
|---|
| 297 |
# connect the UI element |
|---|
| 298 |
QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume) |
|---|
| 299 |
|
|---|
| 300 |
for ctrl, info in self.MatrixButtonControls.iteritems(): |
|---|
| 301 |
state = self.hw.getMatrixMixerValue(self.MatrixButtonControls[ctrl][0], |
|---|
| 302 |
self.MatrixButtonControls[ctrl][1], |
|---|
| 303 |
self.MatrixButtonControls[ctrl][2]) |
|---|
| 304 |
|
|---|
| 305 |
log.debug("%s state is %d" % (ctrl.objectName() , state)) |
|---|
| 306 |
if state: |
|---|
| 307 |
ctrl.setChecked(True) |
|---|
| 308 |
else: |
|---|
| 309 |
ctrl.setChecked(False) |
|---|
| 310 |
|
|---|
| 311 |
# connect the UI element |
|---|
| 312 |
QObject.connect(ctrl,SIGNAL('clicked(bool)'),self.updateMatrixButton) |
|---|
| 313 |
|
|---|
| 314 |
for ctrl, info in self.MatrixRotaryControls.iteritems(): |
|---|
| 315 |
vol = self.hw.getMatrixMixerValue(self.MatrixRotaryControls[ctrl][0], |
|---|
| 316 |
self.MatrixRotaryControls[ctrl][1], |
|---|
| 317 |
self.MatrixRotaryControls[ctrl][2]) |
|---|
| 318 |
|
|---|
| 319 |
log.debug("%s value is %d" % (ctrl.objectName(), vol)) |
|---|
| 320 |
ctrl.setValue(vol) |
|---|
| 321 |
|
|---|
| 322 |
# connect the UI element |
|---|
| 323 |
QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixRotary) |
|---|
| 324 |
|
|---|
| 325 |
for ctrl, info in self.VolumeControls.iteritems(): |
|---|
| 326 |
vol = self.hw.getContignuous(self.VolumeControls[ctrl][0]) |
|---|
| 327 |
|
|---|
| 328 |
#vol = 0x01000000-vol |
|---|
| 329 |
log.debug("%s volume is %d" % (ctrl.objectName() , vol)) |
|---|
| 330 |
ctrl.setValue(vol) |
|---|
| 331 |
|
|---|
| 332 |
# connect the UI element |
|---|
| 333 |
QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateVolume) |
|---|
| 334 |
|
|---|
| 335 |
for ctrl, info in self.SelectorControls.iteritems(): |
|---|
| 336 |
state = self.hw.getDiscrete(self.SelectorControls[ctrl][0]) |
|---|
| 337 |
log.debug("%s state is %d" % (ctrl.objectName() , state)) |
|---|
| 338 |
if state: |
|---|
| 339 |
ctrl.setChecked(True) |
|---|
| 340 |
else: |
|---|
| 341 |
ctrl.setChecked(False) |
|---|
| 342 |
|
|---|
| 343 |
# connect the UI element |
|---|
| 344 |
QObject.connect(ctrl,SIGNAL('clicked(bool)'),self.updateSelector) |
|---|
| 345 |
|
|---|
| 346 |
for ctrl, info in self.TriggerControls.iteritems(): |
|---|
| 347 |
# connect the UI element |
|---|
| 348 |
QObject.connect(ctrl,SIGNAL('clicked()'),self.updateTrigger) |
|---|
| 349 |
|
|---|
| 350 |
for ctrl, info in self.SPDIFmodeControls.iteritems(): |
|---|
| 351 |
state = self.hw.getDiscrete(self.SPDIFmodeControls[ctrl][0]) |
|---|
| 352 |
log.debug("%s state is %d" % (ctrl.objectName() , state)) |
|---|
| 353 |
if state == self.SPDIFmodeControls[ctrl][1]: |
|---|
| 354 |
ctrl.setChecked(True) |
|---|
| 355 |
else: |
|---|
| 356 |
ctrl.setChecked(False) |
|---|
| 357 |
|
|---|
| 358 |
# connect the UI element |
|---|
| 359 |
QObject.connect(ctrl,SIGNAL('toggled(bool)'),self.updateSPDIFmodeControl) |
|---|