1 |
iliev |
787 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2288 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
787 |
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.classic; |
24 |
|
|
|
25 |
|
|
import java.awt.Dimension; |
26 |
iliev |
842 |
import java.awt.GridBagConstraints; |
27 |
|
|
import java.awt.GridBagLayout; |
28 |
|
|
import java.awt.Insets; |
29 |
iliev |
787 |
|
30 |
iliev |
842 |
import java.awt.event.ActionEvent; |
31 |
|
|
import java.awt.event.ActionListener; |
32 |
|
|
|
33 |
iliev |
787 |
import javax.swing.BorderFactory; |
34 |
|
|
import javax.swing.Box; |
35 |
|
|
import javax.swing.BoxLayout; |
36 |
iliev |
842 |
import javax.swing.JButton; |
37 |
iliev |
787 |
import javax.swing.JComboBox; |
38 |
iliev |
842 |
import javax.swing.JFileChooser; |
39 |
iliev |
787 |
import javax.swing.JLabel; |
40 |
|
|
import javax.swing.JPanel; |
41 |
iliev |
842 |
import javax.swing.JRadioButton; |
42 |
|
|
import javax.swing.ButtonGroup; |
43 |
|
|
import javax.swing.JSpinner; |
44 |
|
|
import javax.swing.JTextField; |
45 |
|
|
import javax.swing.SpinnerNumberModel; |
46 |
iliev |
787 |
|
47 |
iliev |
2288 |
import net.sf.juife.swing.JuifeUtils; |
48 |
|
|
import net.sf.juife.swing.Wizard; |
49 |
iliev |
787 |
|
50 |
iliev |
842 |
import net.sf.juife.event.TaskEvent; |
51 |
|
|
import net.sf.juife.event.TaskListener; |
52 |
|
|
|
53 |
iliev |
787 |
import net.sf.juife.wizard.DefaultWizardModel; |
54 |
|
|
import net.sf.juife.wizard.UserInputPage; |
55 |
|
|
import net.sf.juife.wizard.WizardPage; |
56 |
|
|
|
57 |
|
|
import org.jsampler.AudioDeviceModel; |
58 |
|
|
import org.jsampler.CC; |
59 |
|
|
import org.jsampler.MidiDeviceModel; |
60 |
|
|
|
61 |
iliev |
1143 |
import org.jsampler.event.ListEvent; |
62 |
|
|
import org.jsampler.event.ListListener; |
63 |
iliev |
842 |
import org.jsampler.event.MidiDeviceListEvent; |
64 |
|
|
import org.jsampler.event.MidiDeviceListListener; |
65 |
|
|
|
66 |
iliev |
1204 |
import org.jsampler.task.Channel.LoadEngine; |
67 |
|
|
import org.jsampler.task.Channel.LoadInstrument; |
68 |
iliev |
1143 |
import org.jsampler.task.Channel.SetAudioOutputDevice; |
69 |
|
|
import org.jsampler.task.Channel.SetMidiInputChannel; |
70 |
|
|
import org.jsampler.task.Channel.SetMidiInputDevice; |
71 |
|
|
import org.jsampler.task.Channel.SetMidiInputPort; |
72 |
iliev |
787 |
|
73 |
iliev |
1285 |
import org.jsampler.view.std.JSNewMidiDeviceDlg; |
74 |
|
|
import org.jsampler.view.std.JSNewAudioDeviceDlg; |
75 |
iliev |
2288 |
import org.jsampler.view.swing.SHF; |
76 |
iliev |
1285 |
|
77 |
iliev |
842 |
import org.linuxsampler.lscp.AudioOutputDevice; |
78 |
|
|
import org.linuxsampler.lscp.MidiInputDevice; |
79 |
|
|
import org.linuxsampler.lscp.MidiPort; |
80 |
|
|
import org.linuxsampler.lscp.SamplerEngine; |
81 |
|
|
|
82 |
iliev |
787 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
83 |
iliev |
1352 |
import static org.linuxsampler.lscp.Parser.*; |
84 |
iliev |
787 |
|
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
* |
88 |
|
|
* @author Grigor Iliev |
89 |
|
|
*/ |
90 |
|
|
public class NewChannelWizard extends Wizard { |
91 |
|
|
|
92 |
|
|
/** Creates a new instance of <code>NewChannelWizard</code>. */ |
93 |
|
|
public |
94 |
|
|
NewChannelWizard() { |
95 |
iliev |
2288 |
super(SHF.getMainFrame(), i18n.getLabel("NewChannelWizard.title")); |
96 |
iliev |
787 |
|
97 |
|
|
setModel(new NewChannelWizardModel()); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
class NewChannelWizardModel extends DefaultWizardModel { |
103 |
iliev |
842 |
private final MidiDeviceWizardPage midiDevicePage = new MidiDeviceWizardPage(); |
104 |
|
|
private final MidiPortWizardPage midiPortPage = new MidiPortWizardPage(); |
105 |
|
|
private final MidiChannelWizardPage midiChannelPage = new MidiChannelWizardPage(); |
106 |
|
|
private final AudioDeviceWizardPage audioDevicePage = new AudioDeviceWizardPage(); |
107 |
|
|
private final EngineWizardPage enginePage = new EngineWizardPage(); |
108 |
|
|
private final InstrumentWizardPage instrumentPage = new InstrumentWizardPage(); |
109 |
|
|
private final ConfirmationWizardPage confirmationPage = new ConfirmationWizardPage(); |
110 |
iliev |
787 |
|
111 |
|
|
NewChannelWizardModel() { |
112 |
|
|
addPage(midiDevicePage); |
113 |
|
|
addPage(midiPortPage); |
114 |
iliev |
842 |
addPage(midiChannelPage); |
115 |
|
|
addStep(i18n.getLabel("NewChannelWizard.step1"), 3); |
116 |
iliev |
787 |
|
117 |
|
|
addPage(audioDevicePage); |
118 |
|
|
addStep(i18n.getLabel("NewChannelWizard.step2")); |
119 |
|
|
|
120 |
|
|
addPage(enginePage); |
121 |
|
|
addStep(i18n.getLabel("NewChannelWizard.step3")); |
122 |
|
|
|
123 |
|
|
addPage(instrumentPage); |
124 |
|
|
addStep(i18n.getLabel("NewChannelWizard.step4")); |
125 |
|
|
|
126 |
|
|
addPage(confirmationPage); |
127 |
|
|
addStep(i18n.getLabel("NewChannelWizard.step5")); |
128 |
|
|
|
129 |
|
|
setLast(confirmationPage); |
130 |
|
|
} |
131 |
iliev |
842 |
|
132 |
|
|
/** |
133 |
|
|
* Moves to the next page in the wizard. |
134 |
|
|
* @return The next page in the wizard. |
135 |
|
|
*/ |
136 |
|
|
public WizardPage |
137 |
|
|
next() { |
138 |
|
|
if(getCurrentPage() == midiDevicePage && !midiDevicePage.getCustomSettings()) { |
139 |
|
|
super.next(); super.next(); |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
return super.next(); |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
/** |
146 |
|
|
* Moves to the previous page in the wizard. |
147 |
|
|
* @return The previous page in the wizard. |
148 |
|
|
* @see #hasPrevious |
149 |
|
|
*/ |
150 |
|
|
public WizardPage |
151 |
|
|
previous() { |
152 |
|
|
if(getCurrentPage() == audioDevicePage && !midiDevicePage.getCustomSettings()) { |
153 |
|
|
super.previous(); super.previous(); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
return super.previous(); |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
/** |
160 |
|
|
* Gets the selected MIDI device. |
161 |
|
|
* @return The selected MIDI device or <code>null</code> |
162 |
|
|
* if there is no MIDI device selected. |
163 |
|
|
*/ |
164 |
|
|
public MidiInputDevice |
165 |
|
|
getSelectedMidiDevice() { return midiDevicePage.getSelectedDevice(); } |
166 |
|
|
|
167 |
|
|
/** |
168 |
|
|
* Determines whether the user chooses to specify custom MIDI device settings. |
169 |
|
|
* @return <code>true</code> if the user chooses to specify custom MIDI device settings, |
170 |
|
|
* <code>false</code> otherwise. |
171 |
|
|
*/ |
172 |
|
|
public boolean |
173 |
|
|
getCustomMidiSettings() { return midiDevicePage.getCustomSettings(); } |
174 |
|
|
|
175 |
|
|
/** |
176 |
|
|
* Gets the selected MIDI input port. |
177 |
|
|
* @return The selected MIDI input port. |
178 |
|
|
*/ |
179 |
|
|
public MidiPort |
180 |
|
|
getSelectedMidiPort() { return midiPortPage.getSelectedPort(); } |
181 |
|
|
|
182 |
|
|
/** |
183 |
|
|
* Gets the selected MIDI channel. |
184 |
|
|
* @return The number of the selected MIDI channel or -1 which means all channels. |
185 |
|
|
*/ |
186 |
|
|
public int |
187 |
|
|
getSelectedMidiChannel() { return midiChannelPage.getSelectedChannel(); } |
188 |
|
|
|
189 |
|
|
/** |
190 |
|
|
* Gets the selected audio device. |
191 |
|
|
* @return The selected audio device or <code>null</code> if there is no device selected. |
192 |
|
|
*/ |
193 |
|
|
public AudioOutputDevice |
194 |
|
|
getSelectedAudioDevice() { return audioDevicePage.getSelectedDevice(); } |
195 |
|
|
|
196 |
|
|
/** |
197 |
|
|
* Gets the selected sampler engine to be used. |
198 |
|
|
* @return The selected sampler engine to be used. |
199 |
|
|
*/ |
200 |
|
|
public SamplerEngine |
201 |
|
|
getSelectedEngine() { return enginePage.getSelectedEngine(); } |
202 |
|
|
|
203 |
|
|
/** |
204 |
|
|
* Gets the name of the selected instrument file. |
205 |
|
|
* @return The name of the selected instrument file. |
206 |
|
|
*/ |
207 |
|
|
public String |
208 |
|
|
getSelectedFile() { return instrumentPage.getSelectedFile(); } |
209 |
|
|
|
210 |
|
|
/** |
211 |
|
|
* Gets the index of the instrument in the instrument file. |
212 |
|
|
* @return The index of the instrument in the instrument file. |
213 |
|
|
*/ |
214 |
|
|
public int |
215 |
|
|
getInstrumentIndex() { return instrumentPage.getInstrumentIndex(); } |
216 |
iliev |
787 |
} |
217 |
|
|
|
218 |
|
|
class MidiDeviceWizardPage extends UserInputPage { |
219 |
|
|
private final JLabel lDevice = new JLabel(i18n.getLabel("MidiDeviceWizardPage.lDevice")); |
220 |
|
|
private final JComboBox cbDevices = new JComboBox(); |
221 |
iliev |
842 |
private final JButton btnNewDevice = |
222 |
|
|
new JButton(i18n.getButtonLabel("MidiDeviceWizardPage.btnNewDevice")); |
223 |
|
|
private final JRadioButton rbDefaultSettings = |
224 |
|
|
new JRadioButton(i18n.getButtonLabel("MidiDeviceWizardPage.rbDefaultSettings")); |
225 |
|
|
private final JRadioButton rbCustomSettings = |
226 |
|
|
new JRadioButton(i18n.getButtonLabel("MidiDeviceWizardPage.rbCustomSettings")); |
227 |
iliev |
787 |
|
228 |
|
|
MidiDeviceWizardPage() { |
229 |
|
|
super(i18n.getLabel("MidiDeviceWizardPage.subtitle")); |
230 |
|
|
|
231 |
|
|
setMainInstructions(i18n.getLabel("MidiDeviceWizardPage.mainInstructions")); |
232 |
|
|
|
233 |
|
|
JPanel p = new JPanel(); |
234 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
235 |
|
|
|
236 |
|
|
p.add(lDevice); |
237 |
|
|
|
238 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
239 |
|
|
|
240 |
iliev |
1204 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
241 |
iliev |
787 |
cbDevices.addItem(m.getDeviceInfo()); |
242 |
|
|
} |
243 |
|
|
|
244 |
|
|
cbDevices.setMaximumSize(cbDevices.getPreferredSize()); |
245 |
iliev |
842 |
if(cbDevices.getItemCount() == 0) enableDevComp(false); |
246 |
iliev |
787 |
|
247 |
|
|
p.add(cbDevices); |
248 |
|
|
|
249 |
iliev |
842 |
CC.getSamplerModel().addMidiDeviceListListener(getHandler()); |
250 |
|
|
|
251 |
|
|
p.add(Box.createRigidArea(new Dimension(12, 0))); |
252 |
|
|
p.add(btnNewDevice); |
253 |
|
|
p.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
254 |
|
|
|
255 |
|
|
JPanel mainPane = new JPanel(); |
256 |
|
|
mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
257 |
|
|
mainPane.add(p); |
258 |
|
|
|
259 |
|
|
mainPane.add(Box.createRigidArea(new Dimension(0, 6))); |
260 |
|
|
|
261 |
|
|
rbDefaultSettings.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
262 |
|
|
mainPane.add(rbDefaultSettings); |
263 |
|
|
rbCustomSettings.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
264 |
|
|
mainPane.add(rbCustomSettings); |
265 |
|
|
|
266 |
|
|
ButtonGroup btnGroup = new ButtonGroup(); |
267 |
|
|
btnGroup.add(rbDefaultSettings); |
268 |
|
|
btnGroup.add(rbCustomSettings); |
269 |
|
|
rbDefaultSettings.setSelected(true); |
270 |
|
|
|
271 |
|
|
setMainPane(mainPane); |
272 |
|
|
|
273 |
|
|
btnNewDevice.addActionListener(new ActionListener() { |
274 |
|
|
public void |
275 |
|
|
actionPerformed(ActionEvent e) { |
276 |
iliev |
1285 |
new JSNewMidiDeviceDlg(getWizardDialog()).setVisible(true); |
277 |
iliev |
842 |
} |
278 |
|
|
}); |
279 |
iliev |
787 |
} |
280 |
iliev |
842 |
|
281 |
|
|
/** |
282 |
|
|
* Gets the selected device. |
283 |
|
|
* @return The selected device or <code>null</code> if there is no device selected. |
284 |
|
|
*/ |
285 |
|
|
public MidiInputDevice |
286 |
|
|
getSelectedDevice() { return (MidiInputDevice)cbDevices.getSelectedItem(); } |
287 |
|
|
|
288 |
|
|
private void |
289 |
|
|
enableDevComp(boolean b) { |
290 |
|
|
cbDevices.setEnabled(b); |
291 |
|
|
rbDefaultSettings.setEnabled(b); |
292 |
|
|
rbCustomSettings.setEnabled(b); |
293 |
|
|
} |
294 |
|
|
|
295 |
|
|
/** |
296 |
|
|
* Determines whether the user chooses to specify custom device settings. |
297 |
|
|
* @return <code>true</code> if the user chooses to specify custom device settings, |
298 |
|
|
* <code>false</code> otherwise. |
299 |
|
|
*/ |
300 |
|
|
public boolean |
301 |
|
|
getCustomSettings() { return rbCustomSettings.isSelected(); } |
302 |
|
|
|
303 |
|
|
private final Handler handler = new Handler(); |
304 |
|
|
|
305 |
|
|
private Handler |
306 |
|
|
getHandler() { return handler; } |
307 |
|
|
|
308 |
|
|
private class Handler implements MidiDeviceListListener { |
309 |
|
|
public void |
310 |
|
|
deviceAdded(MidiDeviceListEvent e) { |
311 |
|
|
updateDeviceList(e.getMidiDeviceModel().getDeviceInfo()); |
312 |
|
|
} |
313 |
|
|
|
314 |
|
|
public void |
315 |
|
|
deviceRemoved(MidiDeviceListEvent e) { updateDeviceList(null); } |
316 |
|
|
|
317 |
|
|
private void |
318 |
|
|
updateDeviceList(MidiInputDevice dev) { |
319 |
|
|
cbDevices.removeAllItems(); |
320 |
|
|
|
321 |
iliev |
1204 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
322 |
iliev |
842 |
cbDevices.addItem(m.getDeviceInfo()); |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
if(cbDevices.getItemCount() == 0) enableDevComp(false); |
326 |
|
|
else { |
327 |
|
|
enableDevComp(true); |
328 |
|
|
cbDevices.setSelectedItem(dev); |
329 |
|
|
} |
330 |
|
|
cbDevices.setMaximumSize(cbDevices.getPreferredSize()); |
331 |
|
|
} |
332 |
|
|
} |
333 |
iliev |
787 |
} |
334 |
|
|
|
335 |
|
|
class MidiPortWizardPage extends UserInputPage { |
336 |
|
|
private final JLabel lPort = new JLabel(i18n.getLabel("MidiPortWizardPage.lPort")); |
337 |
|
|
private final JComboBox cbPorts = new JComboBox(); |
338 |
|
|
|
339 |
|
|
MidiPortWizardPage() { |
340 |
|
|
super(i18n.getLabel("MidiPortWizardPage.subtitle")); |
341 |
|
|
|
342 |
|
|
setMainInstructions(i18n.getLabel("MidiPortWizardPage.mainInstructions")); |
343 |
|
|
|
344 |
|
|
JPanel p = new JPanel(); |
345 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
346 |
|
|
|
347 |
|
|
p.add(lPort); |
348 |
|
|
|
349 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
350 |
|
|
|
351 |
|
|
cbPorts.setMaximumSize(cbPorts.getPreferredSize()); |
352 |
|
|
|
353 |
|
|
p.add(cbPorts); |
354 |
|
|
|
355 |
|
|
setMainPane(p); |
356 |
|
|
} |
357 |
iliev |
842 |
|
358 |
|
|
public void |
359 |
iliev |
1143 |
preinitPage() { |
360 |
iliev |
842 |
updatePorts(((NewChannelWizardModel)getWizardModel()).getSelectedMidiDevice()); |
361 |
|
|
} |
362 |
|
|
|
363 |
|
|
/** |
364 |
|
|
* Gets the selected MIDI input port. |
365 |
|
|
* @return The selected MIDI input port. |
366 |
|
|
*/ |
367 |
|
|
public MidiPort |
368 |
|
|
getSelectedPort() { return (MidiPort)cbPorts.getSelectedItem(); } |
369 |
|
|
|
370 |
|
|
public void |
371 |
|
|
updatePorts(MidiInputDevice dev) { |
372 |
|
|
Object current = cbPorts.getSelectedItem(); |
373 |
|
|
cbPorts.removeAllItems(); |
374 |
|
|
|
375 |
|
|
if(dev != null) for(MidiPort p : dev.getMidiPorts()) cbPorts.addItem(p); |
376 |
|
|
if(current != null) cbPorts.setSelectedItem(current); |
377 |
|
|
cbPorts.setEnabled(cbPorts.getItemCount() > 0); |
378 |
|
|
cbPorts.setMaximumSize(cbPorts.getPreferredSize()); |
379 |
|
|
} |
380 |
iliev |
787 |
} |
381 |
|
|
|
382 |
iliev |
842 |
class MidiChannelWizardPage extends UserInputPage { |
383 |
|
|
private final JLabel lChannel = new JLabel(i18n.getLabel("MidiChannelWizardPage.lChannel")); |
384 |
|
|
private final JComboBox cbChannels = new JComboBox(); |
385 |
|
|
|
386 |
|
|
MidiChannelWizardPage() { |
387 |
|
|
super(i18n.getLabel("MidiChannelWizardPage.subtitle")); |
388 |
|
|
|
389 |
|
|
setMainInstructions(i18n.getLabel("MidiChannelWizardPage.mainInstructions")); |
390 |
|
|
|
391 |
|
|
JPanel p = new JPanel(); |
392 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
393 |
|
|
|
394 |
|
|
p.add(lChannel); |
395 |
|
|
|
396 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
397 |
|
|
|
398 |
|
|
cbChannels.addItem("All"); |
399 |
|
|
for(int i = 1; i <= 16; i++) cbChannels.addItem(String.valueOf(i)); |
400 |
|
|
cbChannels.setMaximumSize(cbChannels.getPreferredSize()); |
401 |
|
|
|
402 |
|
|
p.add(cbChannels); |
403 |
|
|
|
404 |
|
|
setMainPane(p); |
405 |
|
|
} |
406 |
|
|
|
407 |
|
|
/** |
408 |
|
|
* Gets the selected MIDI channel. |
409 |
|
|
* @return The number of the selected MIDI channel or -1 which means all channels. |
410 |
|
|
*/ |
411 |
|
|
public int |
412 |
|
|
getSelectedChannel() { |
413 |
|
|
Object o = cbChannels.getSelectedItem(); |
414 |
|
|
if(o == null) return -1; |
415 |
|
|
|
416 |
|
|
return o.toString().equals("All") ? -1 : Integer.parseInt(o.toString()); |
417 |
|
|
} |
418 |
|
|
} |
419 |
|
|
|
420 |
iliev |
787 |
class AudioDeviceWizardPage extends UserInputPage { |
421 |
|
|
private final JLabel lDevice = new JLabel(i18n.getLabel("AudioDeviceWizardPage.lDevice")); |
422 |
|
|
private final JComboBox cbDevices = new JComboBox(); |
423 |
iliev |
842 |
private final JButton btnNewDevice = |
424 |
|
|
new JButton(i18n.getButtonLabel("AudioDeviceWizardPage.btnNewDevice")); |
425 |
iliev |
787 |
|
426 |
|
|
AudioDeviceWizardPage() { |
427 |
|
|
super(i18n.getLabel("AudioDeviceWizardPage.subtitle")); |
428 |
|
|
|
429 |
|
|
setMainInstructions(i18n.getLabel("AudioDeviceWizardPage.mainInstructions")); |
430 |
iliev |
842 |
setAdditionalInstructions ( |
431 |
|
|
i18n.getLabel("AudioDeviceWizardPage.additionalInstructions") |
432 |
|
|
); |
433 |
iliev |
787 |
|
434 |
|
|
JPanel p = new JPanel(); |
435 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
436 |
|
|
|
437 |
|
|
p.add(lDevice); |
438 |
|
|
|
439 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
440 |
|
|
|
441 |
iliev |
1204 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
442 |
iliev |
787 |
cbDevices.addItem(m.getDeviceInfo()); |
443 |
|
|
} |
444 |
|
|
|
445 |
|
|
cbDevices.setMaximumSize(cbDevices.getPreferredSize()); |
446 |
iliev |
842 |
if(cbDevices.getItemCount() == 0) cbDevices.setEnabled(false); |
447 |
iliev |
787 |
|
448 |
|
|
p.add(cbDevices); |
449 |
|
|
|
450 |
iliev |
842 |
CC.getSamplerModel().addAudioDeviceListListener(getHandler()); |
451 |
|
|
|
452 |
|
|
p.add(Box.createRigidArea(new Dimension(12, 0))); |
453 |
|
|
p.add(btnNewDevice); |
454 |
|
|
|
455 |
iliev |
787 |
setMainPane(p); |
456 |
iliev |
842 |
|
457 |
|
|
btnNewDevice.addActionListener(new ActionListener() { |
458 |
|
|
public void |
459 |
|
|
actionPerformed(ActionEvent e) { |
460 |
iliev |
1285 |
new JSNewAudioDeviceDlg(getWizardDialog()).setVisible(true); |
461 |
iliev |
842 |
} |
462 |
|
|
}); |
463 |
iliev |
787 |
} |
464 |
iliev |
842 |
|
465 |
|
|
/** |
466 |
|
|
* Gets the selected device. |
467 |
|
|
* @return The selected device or <code>null</code> if there is no device selected. |
468 |
|
|
*/ |
469 |
|
|
public AudioOutputDevice |
470 |
|
|
getSelectedDevice() { return (AudioOutputDevice)cbDevices.getSelectedItem(); } |
471 |
|
|
|
472 |
|
|
private final Handler handler = new Handler(); |
473 |
|
|
|
474 |
|
|
private Handler |
475 |
|
|
getHandler() { return handler; } |
476 |
|
|
|
477 |
iliev |
1143 |
private class Handler implements ListListener<AudioDeviceModel> { |
478 |
iliev |
842 |
public void |
479 |
iliev |
1143 |
entryAdded(ListEvent<AudioDeviceModel> e) { |
480 |
|
|
updateDeviceList(e.getEntry().getDeviceInfo()); |
481 |
iliev |
842 |
} |
482 |
|
|
|
483 |
|
|
public void |
484 |
iliev |
1143 |
entryRemoved(ListEvent<AudioDeviceModel> e) { updateDeviceList(null); } |
485 |
iliev |
842 |
|
486 |
|
|
private void |
487 |
|
|
updateDeviceList(AudioOutputDevice dev) { |
488 |
|
|
cbDevices.removeAllItems(); |
489 |
|
|
|
490 |
iliev |
1204 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
491 |
iliev |
842 |
cbDevices.addItem(m.getDeviceInfo()); |
492 |
|
|
} |
493 |
|
|
|
494 |
|
|
if(cbDevices.getItemCount() == 0) cbDevices.setEnabled(false); |
495 |
|
|
else { |
496 |
|
|
cbDevices.setEnabled(true); |
497 |
|
|
cbDevices.setSelectedItem(dev); |
498 |
|
|
} |
499 |
|
|
cbDevices.setMaximumSize(cbDevices.getPreferredSize()); |
500 |
|
|
} |
501 |
|
|
} |
502 |
iliev |
787 |
} |
503 |
|
|
|
504 |
|
|
class EngineWizardPage extends UserInputPage { |
505 |
|
|
private final JLabel lEngine = new JLabel(i18n.getLabel("EngineWizardPage.lEngine")); |
506 |
|
|
private final JComboBox cbEngines = new JComboBox(); |
507 |
|
|
|
508 |
|
|
EngineWizardPage() { |
509 |
|
|
super(i18n.getLabel("EngineWizardPage.subtitle")); |
510 |
|
|
|
511 |
|
|
setMainInstructions(i18n.getLabel("EngineWizardPage.mainInstructions")); |
512 |
|
|
|
513 |
|
|
JPanel p = new JPanel(); |
514 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
515 |
|
|
|
516 |
|
|
p.add(lEngine); |
517 |
|
|
|
518 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
519 |
|
|
|
520 |
|
|
for(Object o : CC.getSamplerModel().getEngines()) { |
521 |
|
|
cbEngines.addItem(o); |
522 |
|
|
} |
523 |
|
|
|
524 |
|
|
cbEngines.setMaximumSize(cbEngines.getPreferredSize()); |
525 |
|
|
|
526 |
|
|
p.add(cbEngines); |
527 |
|
|
|
528 |
|
|
setMainPane(p); |
529 |
|
|
} |
530 |
iliev |
842 |
|
531 |
|
|
/** |
532 |
|
|
* Gets the selected sampler engine to be used. |
533 |
|
|
* @return The selected sampler engine to be used. |
534 |
|
|
*/ |
535 |
|
|
public SamplerEngine |
536 |
|
|
getSelectedEngine() { return (SamplerEngine)cbEngines.getSelectedItem(); } |
537 |
iliev |
787 |
} |
538 |
|
|
|
539 |
|
|
class InstrumentWizardPage extends UserInputPage { |
540 |
iliev |
842 |
private final JLabel lFilename = new JLabel(i18n.getLabel("InstrumentChooser.lFilename")); |
541 |
|
|
private final JLabel lIndex = new JLabel(i18n.getLabel("InstrumentChooser.lIndex")); |
542 |
iliev |
787 |
|
543 |
iliev |
842 |
private final JTextField tfFilename = new JTextField(); |
544 |
|
|
private final JSpinner spinnerIndex = new JSpinner(new SpinnerNumberModel(0, 0, 500, 1)); |
545 |
|
|
|
546 |
|
|
private final JButton btnBrowse = |
547 |
|
|
new JButton(i18n.getLabel("InstrumentChooser.btnBrowse")); |
548 |
|
|
|
549 |
|
|
|
550 |
iliev |
787 |
InstrumentWizardPage() { |
551 |
|
|
super(i18n.getLabel("InstrumentWizardPage.subtitle")); |
552 |
|
|
|
553 |
|
|
setMainInstructions(i18n.getLabel("InstrumentWizardPage.mainInstructions")); |
554 |
iliev |
842 |
|
555 |
|
|
JPanel p = new JPanel(); |
556 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
557 |
|
|
|
558 |
|
|
p.add(lFilename); |
559 |
|
|
|
560 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
561 |
|
|
|
562 |
|
|
tfFilename.setPreferredSize ( |
563 |
|
|
new Dimension(200, tfFilename.getPreferredSize().height) |
564 |
|
|
); |
565 |
|
|
tfFilename.setMaximumSize(tfFilename.getPreferredSize()); |
566 |
|
|
p.add(tfFilename); |
567 |
|
|
|
568 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
569 |
|
|
|
570 |
|
|
spinnerIndex.setMaximumSize(spinnerIndex.getPreferredSize()); |
571 |
|
|
p.add(spinnerIndex); |
572 |
|
|
|
573 |
|
|
p.add(Box.createRigidArea(new Dimension(6, 0))); |
574 |
|
|
|
575 |
|
|
p.add(btnBrowse); |
576 |
|
|
|
577 |
|
|
p.setMaximumSize(p.getPreferredSize()); |
578 |
|
|
setMainPane(p); |
579 |
|
|
|
580 |
|
|
btnBrowse.addActionListener(new ActionListener() { |
581 |
|
|
public void |
582 |
|
|
actionPerformed(ActionEvent e) { onBrowse(); } |
583 |
|
|
}); |
584 |
|
|
|
585 |
|
|
btnBrowse.requestFocusInWindow(); |
586 |
iliev |
787 |
} |
587 |
iliev |
842 |
|
588 |
|
|
public void |
589 |
iliev |
1143 |
preinitPage() { |
590 |
iliev |
842 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
591 |
|
|
if(model.getSelectedAudioDevice() == null) { |
592 |
|
|
String s = i18n.getLabel("InstrumentWizardPage.additionalInstructions"); |
593 |
|
|
setAdditionalInstructions(s); |
594 |
iliev |
911 |
} else { setAdditionalInstructions(""); } |
595 |
iliev |
842 |
} |
596 |
|
|
|
597 |
|
|
public boolean |
598 |
|
|
mayGoToNext() { |
599 |
|
|
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
600 |
|
|
if(model.getSelectedAudioDevice() == null && getSelectedFile().length() > 0) { |
601 |
|
|
String s = i18n.getError("InstrumentWizardPage.selectAODevice!"); |
602 |
iliev |
2288 |
SHF.showErrorMessage(s, getWizardDialog()); |
603 |
iliev |
842 |
return false; |
604 |
|
|
} else { |
605 |
|
|
return true; |
606 |
|
|
} |
607 |
|
|
} |
608 |
|
|
|
609 |
|
|
/** |
610 |
|
|
* Gets the name of the instrument file. |
611 |
|
|
* @return The name of the instrument file. |
612 |
|
|
*/ |
613 |
|
|
public String |
614 |
|
|
getSelectedFile() { return tfFilename.getText(); } |
615 |
|
|
|
616 |
|
|
/** |
617 |
|
|
* Gets the index of the instrument in the instrument file. |
618 |
|
|
* @return The index of the instrument in the instrument file. |
619 |
|
|
*/ |
620 |
|
|
public int |
621 |
|
|
getInstrumentIndex() { return Integer.parseInt(spinnerIndex.getValue().toString()); } |
622 |
|
|
|
623 |
|
|
private void |
624 |
|
|
onBrowse() { |
625 |
|
|
JFileChooser fc = new JFileChooser(); |
626 |
|
|
int result = fc.showOpenDialog(this); |
627 |
|
|
if(result == JFileChooser.APPROVE_OPTION) { |
628 |
iliev |
1480 |
String path = fc.getSelectedFile().getPath(); |
629 |
|
|
if(java.io.File.separatorChar == '\\') { |
630 |
iliev |
1483 |
path = path.replace('\\', '/'); |
631 |
iliev |
1480 |
} |
632 |
|
|
tfFilename.setText(toEscapedString(path)); |
633 |
iliev |
842 |
} |
634 |
|
|
} |
635 |
iliev |
787 |
} |
636 |
|
|
|
637 |
iliev |
842 |
class ConfirmationWizardPage extends WizardPage { |
638 |
|
|
private MidiInputDevice midiDev = null; |
639 |
|
|
private MidiPort midiPort = null; |
640 |
|
|
private int midiChannel = -1; |
641 |
|
|
private AudioOutputDevice audioDev = null; |
642 |
|
|
private SamplerEngine engine = null; |
643 |
|
|
private String instrFile = null; |
644 |
|
|
private int instrIndex; |
645 |
iliev |
787 |
|
646 |
iliev |
842 |
private final JLabel lInfo = new JLabel(i18n.getLabel("ConfirmationWizardPage.lInfo")); |
647 |
|
|
|
648 |
|
|
private final JLabel lMidiDevice = |
649 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lMidiDevice")); |
650 |
|
|
private final JLabel lMidiPort = |
651 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lMidiPort")); |
652 |
|
|
private final JLabel lMidiChannel = |
653 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lMidiChannel")); |
654 |
|
|
private final JLabel lEngine = |
655 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lEngine")); |
656 |
|
|
private final JLabel lInstrFile = |
657 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lInstrFile")); |
658 |
|
|
private final JLabel lInstrIndex = |
659 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lInstrIndex")); |
660 |
|
|
private final JLabel lAudioDevice = |
661 |
|
|
new JLabel(i18n.getLabel("ConfirmationWizardPage.lAudioDevice")); |
662 |
|
|
|
663 |
|
|
private final JTextField tfMidiDevice = new EnhancedTextField(); |
664 |
|
|
private final JTextField tfMidiPort = new EnhancedTextField(); |
665 |
|
|
private final JTextField tfMidiChannel = new EnhancedTextField(); |
666 |
|
|
private final JTextField tfEngine = new EnhancedTextField(); |
667 |
|
|
private final JTextField tfInstrFile = new EnhancedTextField(); |
668 |
|
|
private final JTextField tfInstrIndex = new EnhancedTextField(); |
669 |
|
|
private final JTextField tfAudioDevice = new EnhancedTextField(); |
670 |
|
|
|
671 |
iliev |
787 |
ConfirmationWizardPage() { |
672 |
iliev |
842 |
super(i18n.getLabel("ConfirmationWizardPage.subtitle"), "", Type.CONFIRMATION_PAGE); |
673 |
iliev |
787 |
|
674 |
iliev |
842 |
GridBagLayout gridbag = new GridBagLayout(); |
675 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
676 |
|
|
|
677 |
|
|
//JPanel mainPane = new JPanel(); |
678 |
|
|
|
679 |
|
|
setLayout(gridbag); |
680 |
|
|
|
681 |
|
|
c.fill = GridBagConstraints.NONE; |
682 |
|
|
|
683 |
|
|
c.gridx = 0; |
684 |
|
|
c.gridy = 1; |
685 |
|
|
c.anchor = GridBagConstraints.EAST; |
686 |
|
|
c.insets = new Insets(3, 3, 3, 3); |
687 |
|
|
gridbag.setConstraints(lMidiDevice, c); |
688 |
|
|
add(lMidiDevice); |
689 |
|
|
|
690 |
|
|
c.gridx = 0; |
691 |
|
|
c.gridy = 2; |
692 |
|
|
gridbag.setConstraints(lMidiPort, c); |
693 |
|
|
add(lMidiPort); |
694 |
|
|
|
695 |
|
|
c.gridx = 0; |
696 |
|
|
c.gridy = 3; |
697 |
|
|
gridbag.setConstraints(lMidiChannel, c); |
698 |
|
|
add(lMidiChannel); |
699 |
|
|
|
700 |
|
|
c.gridx = 0; |
701 |
|
|
c.gridy = 4; |
702 |
|
|
gridbag.setConstraints(lEngine, c); |
703 |
|
|
add(lEngine); |
704 |
|
|
|
705 |
|
|
c.gridx = 0; |
706 |
|
|
c.gridy = 5; |
707 |
|
|
gridbag.setConstraints(lInstrFile, c); |
708 |
|
|
add(lInstrFile); |
709 |
|
|
|
710 |
|
|
c.gridx = 0; |
711 |
|
|
c.gridy = 6; |
712 |
|
|
gridbag.setConstraints(lInstrIndex, c); |
713 |
|
|
add(lInstrIndex); |
714 |
|
|
|
715 |
|
|
c.gridx = 0; |
716 |
|
|
c.gridy = 7; |
717 |
|
|
gridbag.setConstraints(lAudioDevice, c); |
718 |
|
|
add(lAudioDevice); |
719 |
|
|
|
720 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
721 |
|
|
c.gridx = 1; |
722 |
|
|
c.gridy = 1; |
723 |
|
|
c.weightx = 1.0; |
724 |
|
|
c.anchor = GridBagConstraints.WEST; |
725 |
|
|
gridbag.setConstraints(tfMidiDevice, c); |
726 |
|
|
add(tfMidiDevice); |
727 |
|
|
|
728 |
|
|
c.gridx = 1; |
729 |
|
|
c.gridy = 2; |
730 |
|
|
gridbag.setConstraints(tfMidiPort, c); |
731 |
|
|
add(tfMidiPort); |
732 |
|
|
|
733 |
|
|
c.gridx = 1; |
734 |
|
|
c.gridy = 3; |
735 |
|
|
gridbag.setConstraints(tfMidiChannel, c); |
736 |
|
|
add(tfMidiChannel); |
737 |
|
|
|
738 |
|
|
c.gridx = 1; |
739 |
|
|
c.gridy = 4; |
740 |
|
|
gridbag.setConstraints(tfEngine, c); |
741 |
|
|
add(tfEngine); |
742 |
|
|
|
743 |
|
|
c.gridx = 1; |
744 |
|
|
c.gridy = 5; |
745 |
|
|
gridbag.setConstraints(tfInstrFile, c); |
746 |
|
|
add(tfInstrFile); |
747 |
|
|
|
748 |
|
|
c.gridx = 1; |
749 |
|
|
c.gridy = 6; |
750 |
|
|
gridbag.setConstraints(tfInstrIndex, c); |
751 |
|
|
add(tfInstrIndex); |
752 |
|
|
|
753 |
|
|
c.gridx = 1; |
754 |
|
|
c.gridy = 7; |
755 |
|
|
gridbag.setConstraints(tfAudioDevice, c); |
756 |
|
|
add(tfAudioDevice); |
757 |
|
|
|
758 |
|
|
lInfo.setFont(lInfo.getFont().deriveFont(java.awt.Font.PLAIN)); |
759 |
|
|
|
760 |
|
|
c.gridx = 0; |
761 |
|
|
c.gridy = 0; |
762 |
|
|
c.gridwidth = 2; |
763 |
|
|
c.insets = new Insets(12, 3, 17, 3); |
764 |
|
|
c.anchor = GridBagConstraints.NORTH; |
765 |
|
|
gridbag.setConstraints(lInfo, c); |
766 |
|
|
add(lInfo); |
767 |
|
|
|
768 |
|
|
JPanel p = new JPanel(); |
769 |
|
|
p.setOpaque(false); |
770 |
|
|
c.gridx = 0; |
771 |
|
|
c.gridy = 8; |
772 |
|
|
c.weightx = 1.0; |
773 |
|
|
c.weighty = 1.0; |
774 |
|
|
c.insets = new Insets(0, 0, 0, 0); |
775 |
|
|
gridbag.setConstraints(p, c); |
776 |
|
|
add(p); |
777 |
|
|
|
778 |
iliev |
787 |
} |
779 |
|
|
|
780 |
iliev |
842 |
public void |
781 |
iliev |
1143 |
preinitPage() { |
782 |
iliev |
842 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
783 |
|
|
setMidiDevice(model.getSelectedMidiDevice()); |
784 |
|
|
|
785 |
|
|
|
786 |
|
|
if(model.getCustomMidiSettings()) { |
787 |
|
|
setMidiPort(model.getSelectedMidiPort()); |
788 |
|
|
setMidiChannel(model.getSelectedMidiChannel()); |
789 |
|
|
} else { |
790 |
|
|
MidiInputDevice mdev = model.getSelectedMidiDevice(); |
791 |
|
|
if(mdev == null) setMidiPort(null); |
792 |
|
|
else if(mdev.getMidiPorts().length < 1) setMidiPort(null); |
793 |
|
|
else setMidiPort(mdev.getMidiPort(0)); |
794 |
|
|
|
795 |
|
|
setMidiChannel(-1); |
796 |
|
|
} |
797 |
|
|
|
798 |
|
|
setEngine(model.getSelectedEngine()); |
799 |
|
|
setAudioDevice(model.getSelectedAudioDevice()); |
800 |
|
|
setInstrumentFile(model.getSelectedFile()); |
801 |
|
|
setInstrumentIndex(model.getInstrumentIndex()); |
802 |
|
|
} |
803 |
|
|
|
804 |
iliev |
787 |
/** |
805 |
|
|
* Invoked when the user clicks the 'Finish' button |
806 |
|
|
* while this page is the current page of the wizard. |
807 |
|
|
* @return <code>true</code> |
808 |
|
|
*/ |
809 |
|
|
public boolean |
810 |
|
|
mayFinish() { |
811 |
iliev |
1143 |
final org.jsampler.task.Channel.Add ac = new org.jsampler.task.Channel.Add(); |
812 |
iliev |
787 |
|
813 |
iliev |
842 |
ac.addTaskListener(new TaskListener() { |
814 |
|
|
public void |
815 |
|
|
taskPerformed(TaskEvent e) { |
816 |
|
|
if(ac.doneWithErrors()) return; |
817 |
|
|
doIt(ac.getResult()); |
818 |
|
|
} |
819 |
|
|
}); |
820 |
|
|
|
821 |
|
|
CC.getTaskQueue().add(ac); |
822 |
|
|
|
823 |
iliev |
787 |
return true; |
824 |
|
|
} |
825 |
iliev |
842 |
|
826 |
|
|
private void |
827 |
|
|
doIt(int chn) { |
828 |
|
|
if(getEngine() != null) |
829 |
|
|
CC.getTaskQueue().add(new LoadEngine(getEngine().getName(), chn)); |
830 |
|
|
|
831 |
|
|
/*if(getMidiDPort() != null) CC.getTaskQueue().add ( |
832 |
|
|
new SetChannelMidiInputPort(chn, getMidiPort().) |
833 |
|
|
);*/ |
834 |
|
|
|
835 |
|
|
MidiInputDevice d = getMidiDevice(); |
836 |
|
|
if(d != null) { |
837 |
iliev |
1143 |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, d.getDeviceId())); |
838 |
iliev |
842 |
|
839 |
|
|
if(getMidiPort() != null) { |
840 |
|
|
int port = -1; |
841 |
|
|
for(int i = 0; i < d.getMidiPortCount(); i++) { |
842 |
|
|
if(d.getMidiPort(i) == getMidiPort()) { |
843 |
|
|
port = i; |
844 |
|
|
break; |
845 |
|
|
} |
846 |
|
|
} |
847 |
|
|
|
848 |
|
|
if(port != -1) CC.getTaskQueue().add ( |
849 |
iliev |
1143 |
new SetMidiInputPort(chn, port) |
850 |
iliev |
842 |
); |
851 |
|
|
} |
852 |
|
|
|
853 |
|
|
|
854 |
|
|
int mc = (getMidiChannel() == -1 ? -1 : getMidiChannel() - 1); |
855 |
iliev |
1143 |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, mc)); |
856 |
iliev |
842 |
} |
857 |
|
|
|
858 |
|
|
|
859 |
|
|
|
860 |
|
|
if(getAudioDevice() != null) CC.getTaskQueue().add ( |
861 |
iliev |
1143 |
new SetAudioOutputDevice(chn, getAudioDevice().getDeviceId()) |
862 |
iliev |
842 |
); |
863 |
|
|
|
864 |
|
|
if(getInstrumentFile().length() > 0) CC.getTaskQueue().add ( |
865 |
|
|
new LoadInstrument(getInstrumentFile(), getInstrumentIndex(), chn) |
866 |
|
|
); |
867 |
|
|
} |
868 |
|
|
|
869 |
|
|
/** |
870 |
|
|
* Gets the audio output device to be used by this sampler channel. |
871 |
|
|
* @return The audio output device to be used by this sampler channel. |
872 |
|
|
*/ |
873 |
|
|
public AudioOutputDevice |
874 |
|
|
getAudioDevice() { return audioDev; } |
875 |
|
|
|
876 |
|
|
/** |
877 |
|
|
* Sets the audio output device to be used by this sampler channel. |
878 |
|
|
* @param dev The audio output device to be used by this sampler channel. |
879 |
|
|
*/ |
880 |
|
|
public void |
881 |
|
|
setAudioDevice(AudioOutputDevice dev) { |
882 |
|
|
audioDev = dev; |
883 |
|
|
if(dev == null) { |
884 |
|
|
tfAudioDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
885 |
|
|
} else { |
886 |
iliev |
1143 |
tfAudioDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
887 |
iliev |
842 |
} |
888 |
|
|
} |
889 |
|
|
|
890 |
|
|
/** |
891 |
|
|
* Gets the sampler engine to be used. |
892 |
|
|
* @return The sampler engine to be used. |
893 |
|
|
*/ |
894 |
|
|
public SamplerEngine |
895 |
|
|
getEngine() { return engine; } |
896 |
|
|
|
897 |
|
|
/** |
898 |
|
|
* Sets the sampler engine to be used. |
899 |
|
|
* @param engine The sampler engine to be used. |
900 |
|
|
*/ |
901 |
|
|
public void |
902 |
|
|
setEngine(SamplerEngine engine) { |
903 |
|
|
this.engine = engine; |
904 |
|
|
if(engine == null) { |
905 |
|
|
tfEngine.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
906 |
|
|
} else { |
907 |
|
|
tfEngine.setText(engine.getName() + " (" + engine.getDescription() + ")"); |
908 |
|
|
} |
909 |
|
|
} |
910 |
|
|
|
911 |
|
|
/** |
912 |
|
|
* Gets the name of the instrument file. |
913 |
|
|
* @return The name of the instrument file. |
914 |
|
|
*/ |
915 |
|
|
public String |
916 |
|
|
getInstrumentFile() { return instrFile; } |
917 |
|
|
|
918 |
|
|
/** |
919 |
|
|
* Sets the name of the instrument file. |
920 |
|
|
* @param file The name of the instrument file. |
921 |
|
|
*/ |
922 |
|
|
public void |
923 |
|
|
setInstrumentFile(String file) { |
924 |
|
|
instrFile = file; |
925 |
|
|
|
926 |
|
|
if(file.length() == 0) { |
927 |
|
|
tfInstrFile.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
928 |
|
|
} else { |
929 |
|
|
tfInstrFile.setText(file); |
930 |
|
|
} |
931 |
|
|
} |
932 |
|
|
|
933 |
|
|
/** |
934 |
|
|
* Gets the index of the instrument in the instrument file. |
935 |
|
|
* @return The index of the instrument in the instrument file. |
936 |
|
|
*/ |
937 |
|
|
public int |
938 |
|
|
getInstrumentIndex() { return instrIndex; } |
939 |
|
|
|
940 |
|
|
/** |
941 |
|
|
* Sets the index of the instrument in the instrument file. |
942 |
|
|
* @param idx The index of the instrument in the instrument file. |
943 |
|
|
*/ |
944 |
|
|
public void |
945 |
|
|
setInstrumentIndex(int idx) { |
946 |
|
|
instrIndex = idx; |
947 |
|
|
tfInstrIndex.setText(String.valueOf(idx)); |
948 |
|
|
} |
949 |
|
|
|
950 |
|
|
/** |
951 |
|
|
* Gets the MIDI channel to which this sampler channel will listen to. |
952 |
|
|
* @return The MIDI channel to which this sampler channel will listen to |
953 |
|
|
* (-1 means all channels). |
954 |
|
|
* . |
955 |
|
|
*/ |
956 |
|
|
public int |
957 |
|
|
getMidiChannel() { return midiChannel; } |
958 |
|
|
|
959 |
|
|
/** |
960 |
|
|
* Sets the MIDI channel to which this sampler channel will listen to. |
961 |
|
|
* @param chn The MIDI channel to which this sampler channel will listen to |
962 |
|
|
* (-1 means all channels). |
963 |
|
|
* . |
964 |
|
|
*/ |
965 |
|
|
public void |
966 |
|
|
setMidiChannel(int chn) { |
967 |
|
|
midiChannel = chn; |
968 |
|
|
tfMidiChannel.setText(chn == -1 ? "All" : String.valueOf(chn)); |
969 |
|
|
} |
970 |
|
|
|
971 |
|
|
/** |
972 |
|
|
* Gets the MIDI input device to which this sampler channel will be connected to. |
973 |
|
|
* @return The MIDI input device to which this sampler channel will be connected to. |
974 |
|
|
*/ |
975 |
|
|
public MidiInputDevice |
976 |
|
|
getMidiDevice() { return midiDev; } |
977 |
|
|
|
978 |
|
|
/** |
979 |
|
|
* Sets the MIDI input device to which this sampler channel will be connected to. |
980 |
|
|
* @param dev The numerical id of the MIDI input device to which |
981 |
|
|
* this sampler channel will be connected to. |
982 |
|
|
*/ |
983 |
|
|
public void |
984 |
|
|
setMidiDevice(MidiInputDevice dev) { |
985 |
|
|
midiDev = dev; |
986 |
|
|
|
987 |
|
|
if(dev == null) { |
988 |
|
|
tfMidiDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
989 |
|
|
} else { |
990 |
iliev |
1143 |
tfMidiDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
991 |
iliev |
842 |
} |
992 |
|
|
} |
993 |
|
|
|
994 |
|
|
/** |
995 |
|
|
* Gets the MIDI input port. |
996 |
|
|
* @return The MIDI input port. |
997 |
|
|
*/ |
998 |
|
|
public MidiPort |
999 |
|
|
getMidiPort() { return midiPort; } |
1000 |
|
|
|
1001 |
|
|
/** |
1002 |
|
|
* Sets the MIDI input port. |
1003 |
|
|
* @param port The MIDI input port. |
1004 |
|
|
*/ |
1005 |
|
|
public void |
1006 |
|
|
setMidiPort(MidiPort port) { |
1007 |
|
|
midiPort = port; |
1008 |
|
|
|
1009 |
|
|
if(port == null) { |
1010 |
|
|
tfMidiPort.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
1011 |
|
|
} else { |
1012 |
|
|
tfMidiPort.setText(port.getName()); |
1013 |
|
|
} |
1014 |
|
|
} |
1015 |
|
|
|
1016 |
|
|
private class EnhancedTextField extends JTextField { |
1017 |
|
|
EnhancedTextField() { |
1018 |
|
|
setEditable(false); |
1019 |
|
|
setBorder(BorderFactory.createEmptyBorder()); |
1020 |
|
|
} |
1021 |
|
|
} |
1022 |
iliev |
787 |
} |