Show
Ignore:
Timestamp:
10/27/13 20:23:46 (10 years ago)
Author:
mocchi
Message:

[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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/mixer/yamahago.py

    r2404 r2441  
    11# 
     2# Copyright (c) 2013      by Takashi Sakamoto 
    23# Copyright (C) 2005-2008 by Pieter Palmers 
    34# 
     
    3334                QWidget.__init__(self,parent) 
    3435 
    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  
    10636        def getDisplayTitle(self): 
    10737                if self.configrom.getModelId() == 0x0010000B: 
     
    11040                        return "GO46" 
    11141 
     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 
    112124        # 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: 
     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: 
    127132                        level = 0 
    128                         string = 'high' 
    129                 elif a0 == 1: 
     133                elif state == 1: 
    130134                        level = -1535 
    131                         string = 'middle' 
    132135                else: 
    133136                        level = -3583 
    134                         string = 'low' 
    135                 log.debug("setting front level to %s, %d" % (string, level)) 
    136137                self.hw.setContignuous('/Mixer/Feature_Volume_2', level) 
    137138 
    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) 
     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] 
    157146 
    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 
     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)