30 |
import java.awt.event.ItemEvent; |
import java.awt.event.ItemEvent; |
31 |
import java.awt.event.ItemListener; |
import java.awt.event.ItemListener; |
32 |
|
|
33 |
|
import java.beans.PropertyChangeEvent; |
34 |
|
import java.beans.PropertyChangeListener; |
35 |
|
|
36 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
37 |
import javax.swing.Box; |
import javax.swing.Box; |
38 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
65 |
import org.linuxsampler.lscp.AudioOutputChannel; |
import org.linuxsampler.lscp.AudioOutputChannel; |
66 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
67 |
import org.linuxsampler.lscp.Parameter; |
import org.linuxsampler.lscp.Parameter; |
68 |
|
import org.linuxsampler.lscp.ParameterFactory; |
69 |
|
|
70 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
71 |
|
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
72 |
|
|
73 |
/** |
/** |
74 |
* |
* |
90 |
setOptionsPane(optionsPane); |
setOptionsPane(optionsPane); |
91 |
|
|
92 |
int id = model.getDeviceId(); |
int id = model.getDeviceId(); |
93 |
setDeviceName(i18n.getLabel("AudioDevicePane.lDevName", id)); |
String s = model.getDeviceInfo().getDriverName(); |
94 |
|
setDeviceName(i18n.getLabel("AudioDevicePane.lDevName", id, s)); |
95 |
} |
} |
96 |
|
|
97 |
protected void |
protected void |
119 |
private final JLabel lChannels |
private final JLabel lChannels |
120 |
= new JLabel(i18n.getLabel("AudioDevicePane.lChannels")); |
= new JLabel(i18n.getLabel("AudioDevicePane.lChannels")); |
121 |
|
|
122 |
private final JSpinner spinnerChannels |
private final JSpinner spinnerChannels; |
|
= new JSpinner(new SpinnerNumberModel(1, 1, 50, 1)); |
|
123 |
|
|
124 |
private final JLabel lChannel = |
private final JLabel lChannel = |
125 |
new JLabel(i18n.getLabel("AudioDevicePane.lChannel")); |
new JLabel(i18n.getLabel("AudioDevicePane.lChannel")); |
126 |
|
|
127 |
private final JComboBox cbChannel = new JComboBox(); |
private final JComboBox cbChannel = new JComboBox(); |
128 |
|
|
129 |
|
private final ParameterTable additionalParamsTable = new ParameterTable(); |
130 |
|
private final JPanel additionalParamsPane = new JPanel(); |
131 |
|
|
132 |
OptionsPane() { |
OptionsPane() { |
133 |
super(Res.gfxChannelOptions); |
super(Res.gfxChannelOptions); |
134 |
|
|
154 |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
155 |
p.add(lChannels); |
p.add(lChannels); |
156 |
p.add(Box.createRigidArea(new Dimension(5, 0))); |
p.add(Box.createRigidArea(new Dimension(5, 0))); |
157 |
|
|
158 |
|
Parameter<Integer> prm = |
159 |
|
audioDeviceModel.getDeviceInfo().getChannelsParameter(); |
160 |
|
int min = 1; |
161 |
|
if(prm.getRangeMin() != null) min = prm.getRangeMin().intValue(); |
162 |
|
int max = 10000; |
163 |
|
if(prm.getRangeMax() != null) max = prm.getRangeMax().intValue(); |
164 |
|
|
165 |
|
spinnerChannels = new JSpinner(new SpinnerNumberModel(1, min, max, 1)); |
166 |
|
if(prm.isFixed()) spinnerChannels.setEnabled(false); |
167 |
p.add(spinnerChannels); |
p.add(spinnerChannels); |
168 |
p.setOpaque(false); |
p.setOpaque(false); |
169 |
|
|
170 |
mainPane.add(p); |
mainPane.add(p); |
171 |
mainPane.add(Box.createRigidArea(new Dimension(0, 5))); |
mainPane.add(Box.createRigidArea(new Dimension(0, 5))); |
172 |
|
|
173 |
|
JPanel p2 = additionalParamsPane; |
174 |
|
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
175 |
|
p2.setOpaque(false); |
176 |
|
|
177 |
|
p2.add(createHSeparator()); |
178 |
|
p2.add(Box.createRigidArea(new Dimension(0, 5))); |
179 |
|
|
180 |
|
JScrollPane sp = new JScrollPane(additionalParamsTable); |
181 |
|
|
182 |
|
sp.setPreferredSize(new Dimension(77, 90)); |
183 |
|
p2.add(sp); |
184 |
|
mainPane.add(p2); |
185 |
|
|
186 |
|
mainPane.add(Box.createRigidArea(new Dimension(0, 5))); |
187 |
|
|
188 |
mainPane.add(createHSeparator()); |
mainPane.add(createHSeparator()); |
189 |
mainPane.add(Box.createRigidArea(new Dimension(0, 5))); |
mainPane.add(Box.createRigidArea(new Dimension(0, 5))); |
190 |
|
|
192 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
193 |
p.setOpaque(false); |
p.setOpaque(false); |
194 |
|
|
195 |
JPanel p2 = new JPanel(); |
p2 = new JPanel(); |
196 |
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS)); |
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS)); |
197 |
p2.add(lChannel); |
p2.add(lChannel); |
198 |
p2.add(Box.createRigidArea(new Dimension(5, 0))); |
p2.add(Box.createRigidArea(new Dimension(5, 0))); |
202 |
|
|
203 |
p.add(Box.createRigidArea(new Dimension(0, 5))); |
p.add(Box.createRigidArea(new Dimension(0, 5))); |
204 |
|
|
205 |
JScrollPane sp = new JScrollPane(channelParamTable); |
sp = new JScrollPane(channelParamTable); |
206 |
sp.setPreferredSize(new Dimension(77, 90)); |
sp.setPreferredSize(new Dimension(77, 90)); |
207 |
p.add(sp); |
p.add(sp); |
208 |
|
|
222 |
for(AudioOutputChannel chn : m.getDeviceInfo().getAudioChannels()) { |
for(AudioOutputChannel chn : m.getDeviceInfo().getAudioChannels()) { |
223 |
cbChannel.addItem(chn); |
cbChannel.addItem(chn); |
224 |
} |
} |
225 |
|
|
226 |
|
updateParams(audioDeviceModel.getDeviceInfo()); |
227 |
|
additionalParamsTable.getModel().addParameterListener(new ParameterListener() { |
228 |
|
public void |
229 |
|
parameterChanged(ParameterEvent e) { |
230 |
|
audioDeviceModel.setBackendDeviceParameter(e.getParameter()); |
231 |
|
} |
232 |
|
}); |
233 |
|
|
234 |
|
updateAdditionalParamsViewState(); |
235 |
|
String s = "AudioDevice.showAdditionalParameters"; |
236 |
|
preferences().addPropertyChangeListener(s, new PropertyChangeListener() { |
237 |
|
public void |
238 |
|
propertyChange(PropertyChangeEvent e) { |
239 |
|
updateAdditionalParamsViewState(); |
240 |
|
} |
241 |
|
}); |
242 |
|
} |
243 |
|
|
244 |
|
private void |
245 |
|
updateAdditionalParamsViewState() { |
246 |
|
String s = "AudioDevice.showAdditionalParameters"; |
247 |
|
additionalParamsPane.setVisible(preferences().getBoolProperty(s)); |
248 |
|
validate(); |
249 |
} |
} |
250 |
|
|
251 |
public void |
public void |
286 |
if(a != na) checkActive.setSelected(na); |
if(a != na) checkActive.setSelected(na); |
287 |
|
|
288 |
AudioOutputDevice d = e.getAudioDeviceModel().getDeviceInfo(); |
AudioOutputDevice d = e.getAudioDeviceModel().getDeviceInfo(); |
289 |
|
updateParams(d); |
290 |
|
|
291 |
int idx = cbChannel.getSelectedIndex(); |
int idx = cbChannel.getSelectedIndex(); |
292 |
cbChannel.removeAllItems(); |
cbChannel.removeAllItems(); |
307 |
|
|
308 |
audioDeviceModel.setBackendChannelParameter(c, e.getParameter()); |
audioDeviceModel.setBackendChannelParameter(c, e.getParameter()); |
309 |
} |
} |
310 |
|
|
311 |
|
private void |
312 |
|
updateParams(AudioOutputDevice d) { |
313 |
|
Parameter p = d.getSampleRateParameter(); |
314 |
|
boolean b = p == null || p.getName() == null || p.getValue() == null; |
315 |
|
Parameter[] params = d.getAdditionalParameters(); |
316 |
|
Parameter[] p2s; |
317 |
|
if(b) p2s = new Parameter[params.length]; |
318 |
|
else p2s = new Parameter[params.length + 1]; |
319 |
|
|
320 |
|
for(int i = 0; i < params.length; i++) p2s[i] = params[i]; |
321 |
|
|
322 |
|
if(!b) p2s[params.length] = p; |
323 |
|
|
324 |
|
additionalParamsTable.getModel().setParameters(p2s); |
325 |
|
} |
326 |
} |
} |
327 |
|
|
328 |
} |
} |