root/trunk/libffado/support/mixer-qt4/ffado/mixer/yamahago.py

Revision 2404, 5.5 kB (checked in by jwoithe, 4 years ago)

Yamaha GO4x: add device specific mixer GUIs for the GO44 and GO46. Patch by Takashi Sakamoto. While these devices are similar to the Phase24 their internal structures are different, necessitating a specific mixer GUI module.

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, QMessageBox
25 from math import log10
26 from ffado.config import *
27
28 import logging
29 log = logging.getLogger('YamahaGo')
30
31 class YamahaGo(QWidget):
32         def __init__(self,parent = None):
33                 QWidget.__init__(self,parent)
34
35         # startup
36         def initValues(self):
37                 self.modelId = self.configrom.getModelId()
38                 # GO44
39                 if self.modelId == 0x0010000B:
40                         self.is46 = False
41                 # GO46
42                 elif self.modelId == 0x0010000C:
43                         self.is46 = True
44                 else:
45                         return
46
47                 if (not self.is46):
48                         uicLoad("ffado/mixer/yamahago44", self)
49                         self.setWindowTitle("Yamaha GO44 Control")
50                 else:
51                         uicLoad("ffado/mixer/yamahago46", self)
52                         self.setWindowTitle("Yamaha GO46 Control")
53
54                 # common
55                 self.VolumeControls = {
56                         'strmplbk12':   ['/Mixer/Feature_Volume_3', self.sldStrmPlbk12],
57                         'strmplbk34':   ['/Mixer/Feature_Volume_4', self.sldStrmPlbk34],
58                         'strmplbk56':   ['/Mixer/Feature_Volume_5', self.sldStrmPlbk56],
59                         'anain12':      ['/Mixer/Feature_Volume_6', self.sldAnaIn12],
60                         'digiin12':     ['/Mixer/Feature_Volume_7', self.sldDigiIn12],
61                 }
62                 self.JackSourceSelectors = {
63                         'anaout12':     ['/Mixer/Selector_1', self.cmbAnaOut12],
64                         'anaout34':     ['/Mixer/Selector_2', self.cmbAnaOut34],
65                         'digiout12':    ['/Mixer/Selector_3', self.cmbDigiOut12],
66                         'clksrc':       ['/Mixer/Selector_4', self.cmbClkSrc]
67                         }
68
69                 if (self.is46):
70                         # volume for mixer output
71                         self.VolumeControls['master'] = ['/Mixer/Feature_Volume_2', self.sldMaster]
72                         # volume for analog output
73                         self.OutputVolumeControls = {
74                                 'anaout12':     ['/Mixer/Feature_Volume_1', 1, self.sldAnaOut12],
75                                 'anaout34':     ['/Mixer/Feature_Volume_1', 3, self.sldAnaOut34]
76                         }
77                 else:
78                         # volume for mixer output
79                         self.VolumeControls['master'] = ['/Mixer/Feature_Volume_1', self.sldMaster]
80
81
82                 # mixer master volume
83                 self.sldMaster.setEnabled(True)
84
85                 # gain control for mixer input
86                 for name, ctrl in self.VolumeControls.iteritems():
87                         decibel = self.hw.getContignuous(ctrl[0])
88                         vol = pow(10, decibel / 16384 + 2)
89                         log.debug("%s volume is %d" % (name , vol))
90                         ctrl[1].setValue(vol)
91
92                 # source selector for jack output
93                 for name, ctrl in self.JackSourceSelectors.iteritems():
94                         state = self.hw.getDiscrete(ctrl[0])
95                         log.debug("%s state is %d" % (name , state))
96                         ctrl[1].setCurrentIndex(state)
97
98                 if (self.is46):
99                         # volume for output
100                         for name, ctrl in self.OutputVolumeControls.iteritems():
101                                 decibel = self.hw.getContignuous(ctrl[0], ctrl[1])
102                                 vol = pow(10, decibel / 16384 + 2)
103                                 log.debug("%s volume for %d is %d" % (name, ctrl[1], vol))
104                                 ctrl[2].setValue(vol)
105
106         def getDisplayTitle(self):
107                 if self.configrom.getModelId() == 0x0010000B:
108                         return "GO44"
109                 else:
110                         return "GO46"
111
112         # helper functions
113         def setVolume(self, name, vol):
114                 decibel = (log10(vol + 1) - 2) * 16384
115                 log.debug("setting %s volume to %d" % (name, decibel))
116                 self.hw.setContignuous(self.VolumeControls[name][0], decibel)
117         def setOutVolume(self, id, vol):
118                 decibel = (log10(vol + 1) - 2) * 16384
119                 self.hw.setContignuous('/Mixer/Feature_Volume_1', decibel, id)
120         def setSelector(self, a0, a1):
121                 name = a0
122                 state = a1
123                 log.debug("setting %s state to %d" % (name, state))
124                 self.hw.setDiscrete(self.JackSourceSelectors[name][0], state)
125         def setAnaInLevel(self, a0):
126                 if a0 == 0:
127                         level = 0
128                         string = 'high'
129                 elif a0 == 1:
130                         level = -1535
131                         string = 'middle'
132                 else:
133                         level = -3583
134                         string = 'low'
135                 log.debug("setting front level to %s, %d" % (string, level))
136                 self.hw.setContignuous('/Mixer/Feature_Volume_2', level)
137
138         # source control for mixer
139         def setGainStrmPlbk12(self, a0):
140                 self.setVolume('strmplbk12', a0)
141         def setGainStrmPlbk34(self, a0):
142                 self.setVolume('strmplbk34', a0)
143         def setGainAnaIn12(self, a0):
144                 self.setVolume('anain12', a0)
145         def setGainStrmPlbk56(self, a0):
146                 self.setVolume('strmplbk56', a0)
147         def setGainDigiIn(self,a0):
148                 self.setVolume('digiin12', a0)
149         def setVolumeMixer(self, a0):
150                 self.setVolume('master', a0)
151         def setVolumeAnaOut12(self, a0):
152                 self.setOutVolume(1, a0)
153                 self.setOutVolume(2, a0)
154         def setVolumeAnaOut34(self, a0):
155                 self.setOutVolume(3, a0)
156                 self.setOutVolume(4, a0)
157
158         # Source selector for output jack
159         def setAnaOut12(self, a0):
160                 self.setSelector('anaout12', a0)
161         def setAnaOut34(self, a0):
162                 self.setSelector('anaout34', a0)
163         def setDigiOut12(self, a0):
164                 self.setSelector('digiout12', a0)
165         def setClkSrc(self, a0):
166                 # if streaming, this operation break connection
167                 ss = self.streamingstatus.selected()
168                 ss_txt = self.streamingstatus.getEnumLabel(ss)
169                 if (ss_txt == 'Idle'):
170                         self.setSelector('clksrc', a0)
171                 else:
172                         msg = QMessageBox()
173                         msg.question( msg, "Error", \
174                                 "<qt>During streaming, this option is disable.</qt>", \
175                                 QMessageBox.Ok)
176                         ctrl = self.JackSourceSelectors['clksrc']
177                         state = self.hw.getDiscrete(ctrl[0])
178                         ctrl[1].setCurrentIndex(state)
179 # vim: et
Note: See TracBrowser for help on using the browser.