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; |
236 |
|
|
237 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
238 |
|
|
239 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDeviceModels()) { |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
240 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
241 |
} |
} |
242 |
|
|
272 |
btnNewDevice.addActionListener(new ActionListener() { |
btnNewDevice.addActionListener(new ActionListener() { |
273 |
public void |
public void |
274 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
275 |
new NewMidiDeviceDlg(getWizardDialog()).setVisible(true); |
new JSNewMidiDeviceDlg(getWizardDialog()).setVisible(true); |
276 |
} |
} |
277 |
}); |
}); |
278 |
} |
} |
317 |
updateDeviceList(MidiInputDevice dev) { |
updateDeviceList(MidiInputDevice dev) { |
318 |
cbDevices.removeAllItems(); |
cbDevices.removeAllItems(); |
319 |
|
|
320 |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDeviceModels()) { |
for(MidiDeviceModel m : CC.getSamplerModel().getMidiDevices()) { |
321 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
322 |
} |
} |
323 |
|
|
355 |
} |
} |
356 |
|
|
357 |
public void |
public void |
358 |
initPage() { |
preinitPage() { |
359 |
updatePorts(((NewChannelWizardModel)getWizardModel()).getSelectedMidiDevice()); |
updatePorts(((NewChannelWizardModel)getWizardModel()).getSelectedMidiDevice()); |
360 |
} |
} |
361 |
|
|
437 |
|
|
438 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
439 |
|
|
440 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDeviceModels()) { |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
441 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
442 |
} |
} |
443 |
|
|
456 |
btnNewDevice.addActionListener(new ActionListener() { |
btnNewDevice.addActionListener(new ActionListener() { |
457 |
public void |
public void |
458 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
459 |
new NewAudioDeviceDlg(getWizardDialog()).setVisible(true); |
new JSNewAudioDeviceDlg(getWizardDialog()).setVisible(true); |
460 |
} |
} |
461 |
}); |
}); |
462 |
} |
} |
473 |
private Handler |
private Handler |
474 |
getHandler() { return handler; } |
getHandler() { return handler; } |
475 |
|
|
476 |
private class Handler implements AudioDeviceListListener { |
private class Handler implements ListListener<AudioDeviceModel> { |
477 |
public void |
public void |
478 |
deviceAdded(AudioDeviceListEvent e) { |
entryAdded(ListEvent<AudioDeviceModel> e) { |
479 |
updateDeviceList(e.getAudioDeviceModel().getDeviceInfo()); |
updateDeviceList(e.getEntry().getDeviceInfo()); |
480 |
} |
} |
481 |
|
|
482 |
public void |
public void |
483 |
deviceRemoved(AudioDeviceListEvent e) { updateDeviceList(null); } |
entryRemoved(ListEvent<AudioDeviceModel> e) { updateDeviceList(null); } |
484 |
|
|
485 |
private void |
private void |
486 |
updateDeviceList(AudioOutputDevice dev) { |
updateDeviceList(AudioOutputDevice dev) { |
487 |
cbDevices.removeAllItems(); |
cbDevices.removeAllItems(); |
488 |
|
|
489 |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDeviceModels()) { |
for(AudioDeviceModel m : CC.getSamplerModel().getAudioDevices()) { |
490 |
cbDevices.addItem(m.getDeviceInfo()); |
cbDevices.addItem(m.getDeviceInfo()); |
491 |
} |
} |
492 |
|
|
585 |
} |
} |
586 |
|
|
587 |
public void |
public void |
588 |
initPage() { |
preinitPage() { |
589 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
590 |
if(model.getSelectedAudioDevice() == null) { |
if(model.getSelectedAudioDevice() == null) { |
591 |
String s = i18n.getLabel("InstrumentWizardPage.additionalInstructions"); |
String s = i18n.getLabel("InstrumentWizardPage.additionalInstructions"); |
773 |
} |
} |
774 |
|
|
775 |
public void |
public void |
776 |
initPage() { |
preinitPage() { |
777 |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
NewChannelWizardModel model = (NewChannelWizardModel)getWizardModel(); |
778 |
setMidiDevice(model.getSelectedMidiDevice()); |
setMidiDevice(model.getSelectedMidiDevice()); |
779 |
|
|
803 |
*/ |
*/ |
804 |
public boolean |
public boolean |
805 |
mayFinish() { |
mayFinish() { |
806 |
final AddChannel ac = new AddChannel(); |
final org.jsampler.task.Channel.Add ac = new org.jsampler.task.Channel.Add(); |
807 |
|
|
808 |
ac.addTaskListener(new TaskListener() { |
ac.addTaskListener(new TaskListener() { |
809 |
public void |
public void |
829 |
|
|
830 |
MidiInputDevice d = getMidiDevice(); |
MidiInputDevice d = getMidiDevice(); |
831 |
if(d != null) { |
if(d != null) { |
832 |
CC.getTaskQueue().add(new SetChannelMidiInputDevice(chn, d.getDeviceID())); |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, d.getDeviceId())); |
833 |
|
|
834 |
if(getMidiPort() != null) { |
if(getMidiPort() != null) { |
835 |
int port = -1; |
int port = -1; |
841 |
} |
} |
842 |
|
|
843 |
if(port != -1) CC.getTaskQueue().add ( |
if(port != -1) CC.getTaskQueue().add ( |
844 |
new SetChannelMidiInputPort(chn, port) |
new SetMidiInputPort(chn, port) |
845 |
); |
); |
846 |
} |
} |
847 |
|
|
848 |
|
|
849 |
int mc = (getMidiChannel() == -1 ? -1 : getMidiChannel() - 1); |
int mc = (getMidiChannel() == -1 ? -1 : getMidiChannel() - 1); |
850 |
CC.getTaskQueue().add(new SetChannelMidiInputChannel(chn, mc)); |
CC.getTaskQueue().add(new SetMidiInputChannel(chn, mc)); |
851 |
} |
} |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
if(getAudioDevice() != null) CC.getTaskQueue().add ( |
if(getAudioDevice() != null) CC.getTaskQueue().add ( |
856 |
new SetChannelAudioOutputDevice(chn, getAudioDevice().getDeviceID()) |
new SetAudioOutputDevice(chn, getAudioDevice().getDeviceId()) |
857 |
); |
); |
858 |
|
|
859 |
if(getInstrumentFile().length() > 0) CC.getTaskQueue().add ( |
if(getInstrumentFile().length() > 0) CC.getTaskQueue().add ( |
878 |
if(dev == null) { |
if(dev == null) { |
879 |
tfAudioDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
tfAudioDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
880 |
} else { |
} else { |
881 |
tfAudioDevice.setText(dev.getDeviceID() + " (" + dev.getDriverName() + ")"); |
tfAudioDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
882 |
} |
} |
883 |
} |
} |
884 |
|
|
982 |
if(dev == null) { |
if(dev == null) { |
983 |
tfMidiDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
tfMidiDevice.setText(i18n.getLabel("ConfirmationWizardPage.notSpecified")); |
984 |
} else { |
} else { |
985 |
tfMidiDevice.setText(dev.getDeviceID() + " (" + dev.getDriverName() + ")"); |
tfMidiDevice.setText(dev.getDeviceId() + " (" + dev.getDriverName() + ")"); |
986 |
} |
} |
987 |
} |
} |
988 |
|
|