2 # Copyright (c) 2013 by Takashi Sakamoto
3 # Copyright (C) 2005-2008 by Pieter Palmers
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
8 # FFADO is based upon FreeBoB.
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.
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.
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/>.
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 *
30 log
= logging
.getLogger('YamahaGo')
32 class YamahaGo(QWidget
):
33 def __init__(self
, parent
=None):
34 QWidget
.__init
__(self
, parent
)
36 def getDisplayTitle(self
):
37 if self
.configrom
.getModelId() == 0x0010000B:
44 uicLoad("ffado/mixer/yamahago", self
)
46 self
.modelId
= self
.configrom
.getModelId()
48 if self
.modelId
== 0x0010000B:
49 self
.setWindowTitle("Yamaha GO44 Control")
50 self
.box_ana_out
.hide()
53 elif self
.modelId
== 0x0010000C:
54 self
.setWindowTitle("Yamaha GO46 Control")
55 self
.box_ana_in_12_level
.hide()
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
]
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'
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")
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
]
94 for ctl
, params
in self
.VolumeControls
.items():
98 db
= self
.hw
.getContignuous(path
, idx
)
106 pdb
= self
.hw
.getContignuous(path
, pidx
)
107 pvol
= self
.db2vol(db
)
110 link
.setChecked(True)
112 QObject
.connect(ctl
, SIGNAL('valueChanged(int)'), self
.updateVolume
)
114 # source selector for jack output
115 for ctl
, param
in self
.JackSourceSelectors
.items():
116 state
= self
.hw
.getDiscrete(param
)
117 ctl
.setCurrentIndex(state
)
119 QObject
.connect(ctl
, SIGNAL('activated(int)'), self
.updateSelector
)
122 QObject
.connect(self
.cmb_ana_in_12_level
, SIGNAL('activated(int)'), self
.updateMicLevel
)
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
130 def updateMicLevel(self
, state
):
137 self
.hw
.setContignuous('/Mixer/Feature_Volume_2', level
)
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]
147 db
= self
.vol2db(vol
)
148 self
.hw
.setContignuous(path
, db
, idx
)
153 def updateSelector(self
, state
):
154 sender
= self
.sender()
155 path
= self
.JackSourceSelectors
[sender
]
156 self
.hw
.setDiscrete(path
, state
)