1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
59 |
import org.jsampler.HF; |
import org.jsampler.HF; |
60 |
import org.jsampler.MidiDeviceModel; |
import org.jsampler.MidiDeviceModel; |
61 |
|
|
62 |
import org.jsampler.event.AudioDeviceListEvent; |
import org.jsampler.event.ListEvent; |
63 |
import org.jsampler.event.AudioDeviceListListener; |
import org.jsampler.event.ListListener; |
64 |
import org.jsampler.event.MidiDeviceListEvent; |
import org.jsampler.event.MidiDeviceListEvent; |
65 |
import org.jsampler.event.MidiDeviceListListener; |
import org.jsampler.event.MidiDeviceListListener; |
66 |
|
|
67 |
import org.jsampler.task.AddChannel; |
import org.jsampler.task.Channel.LoadEngine; |
68 |
import org.jsampler.task.LoadEngine; |
import org.jsampler.task.Channel.LoadInstrument; |
69 |
import org.jsampler.task.LoadInstrument; |
import org.jsampler.task.Channel.SetAudioOutputDevice; |
70 |
import org.jsampler.task.SetChannelAudioOutputDevice; |
import org.jsampler.task.Channel.SetMidiInputChannel; |
71 |
import org.jsampler.task.SetChannelMidiInputChannel; |
import org.jsampler.task.Channel.SetMidiInputDevice; |
72 |
import org.jsampler.task.SetChannelMidiInputDevice; |
import org.jsampler.task.Channel.SetMidiInputPort; |
73 |
import org.jsampler.task.SetChannelMidiInputPort; |
|
74 |
|
import org.jsampler.view.std.JSNewMidiDeviceDlg; |
75 |
|
import org.jsampler.view.std.JSNewAudioDeviceDlg; |
76 |
|
|
77 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
78 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
80 |
import org.linuxsampler.lscp.SamplerEngine; |
import org.linuxsampler.lscp.SamplerEngine; |
81 |
|
|
82 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
83 |
|
import static org.linuxsampler.lscp.Parser.*; |
84 |
|
|
85 |
|
|
86 |
/** |
/** |
237 |
|
|
238 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
239 |
|
|
240 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDeviceModels()) { |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
241 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
242 |
} |
} |
243 |
|
|
273 |
btnNewDevice.addActionListener(new ActionListener() { |
btnNewDevice.addActionListener(new ActionListener() { |
274 |
public void |
public void |
275 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
276 |
new NewMidiDeviceDlg(getWizardDialog()).setVisible(true); |
new JSNewMidiDeviceDlg(getWizardDialog()).setVisible(true); |
277 |
} |
} |
278 |
}); |
}); |
279 |
} |
} |
318 |
updateDeviceList(MidiInputDevice dev) { |
updateDeviceList(MidiInputDevice dev) { |
319 |
cbDevices.removeAllItems(); |
cbDevices.removeAllItems(); |
320 |
|
|
321 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDeviceModels()) { |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
322 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
323 |
} |
} |
324 |
|
|
356 |
} |
} |
357 |
|
|
358 |
public void |
public void |
359 |
initPage() { |
preinitPage() { |
360 |
updatePorts(((NewChannelWizardModel)getWizardModel()).getSelectedMidiDevice()); |
updatePorts(((NewChannelWizardModel)getWizardModel()).getSelectedMidiDevice()); |
361 |
} |
} |
362 |
|
|
438 |
|
|
439 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
440 |
|
|
441 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDeviceModels()) { |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
442 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
443 |
} |
} |
444 |
|
|
457 |
btnNewDevice.addActionListener(new ActionListener() { |
btnNewDevice.addActionListener(new ActionListener() { |
458 |
public void |
public void |
459 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
460 |
new NewAudioDeviceDlg(getWizardDialog()).setVisible(true); |
new JSNewAudioDeviceDlg(getWizardDialog()).setVisible(true); |
461 |
} |
} |
462 |
}); |
}); |
463 |
} |
} |
474 |
private Handler |
private Handler |
475 |
getHandler() { return handler; } |
getHandler() { return handler; } |
476 |
|
|
477 |
private class Handler implements AudioDeviceListListener { |
private class Handler implements ListListener<AudioDeviceModel> { |
478 |
public void |
public void |
479 |
deviceAdded(AudioDeviceListEvent e) { |
entryAdded(ListEvent<AudioDeviceModel> e) { |
480 |
updateDeviceList(e.getAudioDeviceModel().getDeviceInfo()); |
updateDeviceList(e.getEntry().getDeviceInfo()); |
481 |
} |
} |
482 |
|
|
483 |
public void |
public void |
484 |
deviceRemoved(AudioDeviceListEvent e) { updateDeviceList(null); } |
entryRemoved(ListEvent<AudioDeviceModel> e) { updateDeviceList(null); } |
485 |
|
|
486 |
private void |
private void |
487 |
updateDeviceList(AudioOutputDevice dev) { |
updateDeviceList(AudioOutputDevice dev) { |
488 |
cbDevices.removeAllItems(); |
cbDevices.removeAllItems(); |
489 |
|
|
490 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDeviceModels()) { |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
491 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
492 |
} |
} |
493 |
|
|
586 |
} |
} |
587 |
|
|
588 |
public void |
public void |
589 |
initPage() { |
preinitPage() { |
590 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
591 |
if(model.getSelectedAudioDevice() == null) { |
if(model.getSelectedAudioDevice() == null) { |
592 |
String s = i18n.getLabel("InstrumentWizardPage.additionalInstructions"); |
String s = i18n.getLabel("InstrumentWizardPage.additionalInstructions"); |
625 |
JFileChooser fc = new JFileChooser(); |
JFileChooser fc = new JFileChooser(); |
626 |
int result = fc.showOpenDialog(this); |
int result = fc.showOpenDialog(this); |
627 |
if(result == JFileChooser.APPROVE_OPTION) { |
if(result == JFileChooser.APPROVE_OPTION) { |
628 |
tfFilename.setText(fc.getSelectedFile().getPath()); |
tfFilename.setText(toEscapedString(fc.getSelectedFile().getPath())); |
629 |
} |
} |
630 |
} |
} |
631 |
} |
} |
774 |
} |
} |
775 |
|
|
776 |
public void |
public void |
777 |
initPage() { |
preinitPage() { |
778 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
779 |
setMidiDevice(model.getSelectedMidiDevice()); |
setMidiDevice(model.getSelectedMidiDevice()); |
780 |
|
|
804 |
*/ |
*/ |
805 |
public boolean |
public boolean |
806 |
mayFinish() { |
mayFinish() { |
807 |
final AddChannel ac = new AddChannel(); |
final org.jsampler.task.Channel.Add ac = new org.jsampler.task.Channel.Add(); |
808 |
|
|
809 |
ac.addTaskListener(new TaskListener() { |
ac.addTaskListener(new TaskListener() { |
810 |
public void |
public void |
830 |
|
|
831 |
MidiInputDevice d = getMidiDevice(); |
MidiInputDevice d = getMidiDevice(); |
832 |
if(d != null) { |
if(d != null) { |
833 |
CC.getTaskQueue().add(new SetChannelMidiInputDevice(chn, d.getDeviceID())); |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, d.getDeviceId())); |
834 |
|
|
835 |
if(getMidiPort() != null) { |
if(getMidiPort() != null) { |
836 |
int port = -1; |
int port = -1; |
842 |
} |
} |
843 |
|
|
844 |
if(port != -1) CC.getTaskQueue().add ( |
if(port != -1) CC.getTaskQueue().add ( |
845 |
new SetChannelMidiInputPort(chn, port) |
new SetMidiInputPort(chn, port) |
846 |
); |
); |
847 |
} |
} |
848 |
|
|
849 |
|
|
850 |
int mc = (getMidiChannel() == -1 ? -1 : getMidiChannel() - 1); |
int mc = (getMidiChannel() == -1 ? -1 : getMidiChannel() - 1); |
851 |
CC.getTaskQueue().add(new SetChannelMidiInputChannel(chn, mc)); |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, mc)); |
852 |
} |
} |
853 |
|
|
854 |
|
|
855 |
|
|
856 |
if(getAudioDevice() != null) CC.getTaskQueue().add ( |
if(getAudioDevice() != null) CC.getTaskQueue().add ( |
857 |
new SetChannelAudioOutputDevice(chn, getAudioDevice().getDeviceID()) |
new SetAudioOutputDevice(chn, getAudioDevice().getDeviceId()) |
858 |
); |
); |
859 |
|
|
860 |
if(getInstrumentFile().length() > 0) CC.getTaskQueue().add ( |
if(getInstrumentFile().length() > 0) CC.getTaskQueue().add ( |
879 |
if(dev == null) { |
if(dev == null) { |
880 |
tfAudioDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
tfAudioDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
881 |
} else { |
} else { |
882 |
tfAudioDevice.setText(dev.getDeviceID() + " (" + dev.getDriverName() + ")"); |
tfAudioDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
883 |
} |
} |
884 |
} |
} |
885 |
|
|
983 |
if(dev == null) { |
if(dev == null) { |
984 |
tfMidiDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
tfMidiDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
985 |
} else { |
} else { |
986 |
tfMidiDevice.setText(dev.getDeviceID() + " (" + dev.getDriverName() + ")"); |
tfMidiDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
987 |
} |
} |
988 |
} |
} |
989 |
|
|