root/branches/libffado-2.0/support/mixer-qt4/mixer_phase24.py

Revision 1364, 5.2 kB (checked in by ppalmers, 12 years ago)

port mixer UI's to Qt4. Make Qt4 the first option to be checked in scons.

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