root/trunk/libffado/support/mixer-qt4/mixer_rme.py

Revision 1608, 4.5 kB (checked in by jwoithe, 15 years ago)

RME: refine available mixer device controls depending on the model in use.

Line 
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         # Other mixer variables
52         self.is_streaming = 0
53         self.sample_rate = 0
54         self.model = 0
55         self.tco_present = 0
56
57     # Public slot: update phantom power hardware switchs
58     def updatePhantomSwitch(self, a0):
59         sender = self.sender()
60         # Value is the phantom switch value, with a corresponding enable
61         # bit in the high 16 bit word
62         val = (a0 << self.PhantomSwitches[sender][1]) | (0x00010000 << self.PhantomSwitches[sender][1])
63         log.debug("phantom switch %d set to %d" % (self.PhantomSwitches[sender][1], a0))
64         self.hw.setDiscrete(self.PhantomSwitches[sender][0], val)
65
66     # Hide and disable a control
67     def disable_hide(self,widget):
68         widget.hide()
69         widget.setEnabled(False)
70
71     def initValues(self):
72         # Is the device streaming?
73         #self.is_streaming = self.hw.getDiscrete('/Mixer/Info/IsStreaming')
74         self.is_streaming = 0
75         #log.debug("device streaming flag: %d" % (self.is_streaming))
76
77         # Retrieve other device settings as needed and customise the UI
78         # based on these options.
79         self.model = self.hw.getDiscrete('/Control/Model')
80         log.debug("device model identifier: %d" % (self.model))
81         self.tco_present = self.hw.getDiscrete('/Control/TCO_present')
82         log.debug("device has TCO: %d" % (self.tco_present))
83         #self.sample_rate = self.hw.getDiscrete('/Mixer/Info/SampleRate')
84         #log.debug("device sample rate: %d" % (self.sample_rate))
85
86         # The Fireface-400 only has 2 phantom-capable channels
87         if (self.model == RME_MODEL_FF400):
88             self.disable_hide(self.phantom_2)
89             self.disable_hide(self.phantom_3)
90         else:
91             self.phantom_0.setText("Mic 7")
92             self.phantom_1.setText("Mic 8")
93             self.phantom_2.setText("Mic 9")
94             self.phantom_3.setText("Mic 10")
95
96         # Instrument options, input jack selection controls and an ADAT2
97         # input are applicable only to the FF800
98         if (self.model != RME_MODEL_FF800):
99             self.instrument_options_group.setEnabled(False)
100             self.input_plug_select_group.setEnabled(False)
101             self.sync_ref_adat2.setEnabled(False)
102
103         # Only the FF400 has specific channel 3/4 options
104         if (self.model != RME_MODEL_FF400):
105             self.channel_3_4_options_group.setEnabled(False)
106             self.phones_level_group.setEnabled(False)
107
108         # Get current hardware values and connect GUI element signals to
109         # their respective slots
110         for ctrl, info in self.PhantomSwitches.iteritems():
111             if (not(ctrl.isEnabled())):
112                 continue
113             val = (self.hw.getDiscrete(info[0]) >> info[1]) & 0x01
114             log.debug("phantom switch %d is %d" % (info[1], val))
115             if val:
116                 ctrl.setChecked(True)
117             else:
118                 ctrl.setChecked(False)
119             QObject.connect(ctrl, SIGNAL('toggled(bool)'), self.updatePhantomSwitch)
Note: See TracBrowser for help on using the browser.