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

Revision 2441, 5.8 kB (checked in by mocchi, 4 years ago)

[BeBoB/Yamaha?] unify and improve mixer GUI for Yamaha's GO series

With r2404, I committed mixer GUI for 'GO 44' and 'GO 46'. But these are mostly common for its functionality. And the functionality to change its clock source should be in common clock source interface.

Line 
1 #
2 # Copyright (c) 2013      by Takashi Sakamoto
3 # Copyright (C) 2005-2008 by Pieter Palmers
4 #
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
7 #
8 # FFADO is based upon FreeBoB.
9 #
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 2 of the License, or
13 # (at your option) version 3 of the License.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 #
23
24 from PyQt4.QtCore import SIGNAL, SLOT, QObject
25 from PyQt4.QtGui import QWidget, QMessageBox
26 from math import log10
27 from ffado.config import *
28
29 import logging
30 log = logging.getLogger('YamahaGo')
31
32 class YamahaGo(QWidget):
33         def __init__(self,parent = None):
34                 QWidget.__init__(self,parent)
35
36         def getDisplayTitle(self):
37                 if self.configrom.getModelId() == 0x0010000B:
38                         return "GO44"
39                 else:
40                         return "GO46"
41
42         # startup
43         def initValues(self):
44                 uicLoad("ffado/mixer/yamahago", self)
45                
46                 self.modelId = self.configrom.getModelId()
47                 # GO44
48                 if self.modelId == 0x0010000B:
49                         self.setWindowTitle("Yamaha GO44 Control")
50                         self.box_ana_out.hide()
51                         self.is46 = False
52                 # GO46
53                 elif self.modelId == 0x0010000C:
54                         self.setWindowTitle("Yamaha GO46 Control")
55                         self.box_ana_in_12_level.hide()
56                         self.is46 = True
57
58                 # common
59                 self.VolumeControls = {
60                         self.sld_mixer_strm_in_1:       ['/Mixer/Feature_Volume_3', 1, self.sld_mixer_strm_in_2, 2, self.link_mixer_strm_in_12],
61                         self.sld_mixer_strm_in_2:       ['/Mixer/Feature_Volume_3', 2, self.sld_mixer_strm_in_1, 1, self.link_mixer_strm_in_12],
62                         self.sld_mixer_strm_in_3:       ['/Mixer/Feature_Volume_4', 1, self.sld_mixer_strm_in_4, 2, self.link_mixer_strm_in_34],
63                         self.sld_mixer_strm_in_4:       ['/Mixer/Feature_Volume_4', 2, self.sld_mixer_strm_in_3, 1, self.link_mixer_strm_in_34],
64                         self.sld_mixer_strm_in_5:       ['/Mixer/Feature_Volume_5', 1, self.sld_mixer_strm_in_6, 2, self.link_mixer_strm_in_56],
65                         self.sld_mixer_strm_in_6:       ['/Mixer/Feature_Volume_5', 2, self.sld_mixer_strm_in_5, 1, self.link_mixer_strm_in_56],
66                         self.sld_mixer_ana_in_1:        ['/Mixer/Feature_Volume_6', 1, self.sld_mixer_ana_in_2,  2, self.link_mixer_ana_in_12],
67                         self.sld_mixer_ana_in_2:        ['/Mixer/Feature_Volume_6', 2, self.sld_mixer_ana_in_1,  1, self.link_mixer_ana_in_12],
68                         self.sld_mixer_dig_in_1:        ['/Mixer/Feature_Volume_7', 1, self.sld_mixer_dig_in_2,  2, self.link_mixer_dig_in_12],
69                         self.sld_mixer_dig_in_2:        ['/Mixer/Feature_Volume_7', 2, self.sld_mixer_dig_in_1,  1, self.link_mixer_dig_in_12]
70                 }
71                 self.JackSourceSelectors = {
72                         self.cmb_ana_out_12_route:      '/Mixer/Selector_1',
73                         self.cmb_ana_out_34_route:      '/Mixer/Selector_2',
74                         self.cmb_dig_out_12_route:      '/Mixer/Selector_3'
75                         }
76
77                 if not self.is46:
78                         # volume for mixer output
79                         self.VolumeControls[self.sld_mixer_out_1] = ['/Mixer/Feature_Volume_1', 1, self.sld_mixer_out_2, 2, self.link_mixer_out_12]
80                         self.VolumeControls[self.sld_mixer_out_2] = ['/Mixer/Feature_Volume_1', 2, self.sld_mixer_out_1, 1, self.link_mixer_out_12]
81                         # analog out 3/4 is headphone out 1/2
82                         self.label_ana_out_34_route.setText("Headphone out 1/2")
83                 else:
84                         # volume for mixer output
85                         self.VolumeControls[self.sld_mixer_out_1]       = ['/Mixer/Feature_Volume_2', 1, self.sld_mixer_out_2, 2, self.link_mixer_out_12]
86                         self.VolumeControls[self.sld_mixer_out_2]       = ['/Mixer/Feature_Volume_2', 2, self.sld_mixer_out_1, 1, self.link_mixer_out_12]
87                         # volume for analog output
88                         self.VolumeControls[self.sld_ana_out_1] = ['/Mixer/Feature_Volume_1', 1, self.sld_ana_out_2, 2, self.link_ana_out_12]
89                         self.VolumeControls[self.sld_ana_out_2] = ['/Mixer/Feature_Volume_1', 2, self.sld_ana_out_1, 1, self.link_ana_out_12]
90                         self.VolumeControls[self.sld_ana_out_3] = ['/Mixer/Feature_Volume_1', 3, self.sld_ana_out_4, 4, self.link_ana_out_34]
91                         self.VolumeControls[self.sld_ana_out_4] = ['/Mixer/Feature_Volume_1', 4, self.sld_ana_out_3, 3, self.link_ana_out_34]
92
93                 # gain control
94                 for ctl, params in self.VolumeControls.items():
95                         path    = params[0]
96                         idx     = params[1]
97                        
98                         db = self.hw.getContignuous(path, idx)
99                         vol = self.db2vol(db)
100                         ctl.setValue(vol)
101                        
102                         pair    = params[2]
103                         pidx    = params[3]
104                         link    = params[4]
105                        
106                         pdb = self.hw.getContignuous(path, pidx)
107                         pvol = self.db2vol(db)
108                        
109                         if pvol == vol:
110                                 link.setChecked(True)
111                        
112                         QObject.connect(ctl, SIGNAL('valueChanged(int)'), self.updateVolume)
113
114                 # source selector for jack output
115                 for ctl, param in self.JackSourceSelectors.items():
116                         state = self.hw.getDiscrete(param)
117                         ctl.setCurrentIndex(state)
118                        
119                         QObject.connect(ctl, SIGNAL('activated(int)'), self.updateSelector)
120                        
121                 if not self.is46:
122                         QObject.connect(self.cmb_ana_in_12_level, SIGNAL('activated(int)'), self.updateMicLevel)
123
124         # helper functions
125         def vol2db(self, vol):
126                 return (log10(vol + 1) - 2) * 16384
127         def db2vol(self, db):
128                 return pow(10, db / 16384 + 2) - 1
129        
130         def updateMicLevel(self, state):
131                 if state == 0:
132                         level = 0
133                 elif state == 1:
134                         level = -1535
135                 else:
136                         level = -3583
137                 self.hw.setContignuous('/Mixer/Feature_Volume_2', level)
138
139         def updateVolume(self, vol):
140                 sender  = self.sender()
141                 path    = self.VolumeControls[sender][0]
142                 idx     = self.VolumeControls[sender][1]
143                 pair    = self.VolumeControls[sender][2]
144                 p_idx   = self.VolumeControls[sender][3]
145                 link    = self.VolumeControls[sender][4]
146
147                 db = self.vol2db(vol)
148                 self.hw.setContignuous(path, db, idx)
149                
150                 if link.isChecked():
151                         pair.setValue(vol)
152
153         def updateSelector(self, state):
154                 sender  = self.sender()
155                 path    = self.JackSourceSelectors[sender]
156                 self.hw.setDiscrete(path, state)
Note: See TracBrowser for help on using the browser.