1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 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 |
* |
* |
57 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
58 |
import org.jsampler.SamplerModel; |
import org.jsampler.SamplerModel; |
59 |
|
|
60 |
import org.jsampler.event.AudioDeviceListEvent; |
import org.jsampler.event.ListEvent; |
61 |
import org.jsampler.event.AudioDeviceListListener; |
import org.jsampler.event.ListListener; |
62 |
import org.jsampler.event.MidiDeviceListEvent; |
import org.jsampler.event.MidiDeviceListEvent; |
63 |
import org.jsampler.event.MidiDeviceListListener; |
import org.jsampler.event.MidiDeviceListListener; |
64 |
import org.jsampler.event.SamplerChannelAdapter; |
import org.jsampler.event.SamplerChannelAdapter; |
65 |
import org.jsampler.event.SamplerChannelEvent; |
import org.jsampler.event.SamplerChannelEvent; |
66 |
import org.jsampler.event.SamplerChannelListener; |
import org.jsampler.event.SamplerChannelListener; |
67 |
|
|
|
import org.jsampler.task.RemoveChannel; |
|
|
|
|
68 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
69 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
70 |
import org.linuxsampler.lscp.MidiPort; |
import org.linuxsampler.lscp.MidiPort; |
255 |
*/ |
*/ |
256 |
float volume = dialVolume.getValue(); |
float volume = dialVolume.getValue(); |
257 |
volume /= 100; |
volume /= 100; |
258 |
getModel().setVolume(volume); |
getModel().setBackendVolume(volume); |
259 |
} |
} |
260 |
|
|
261 |
/** |
/** |
367 |
|
|
368 |
public void |
public void |
369 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
370 |
CC.getTaskQueue().add(new RemoveChannel(getChannelID())); |
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
371 |
} |
} |
372 |
|
|
373 |
public boolean |
public boolean |
377 |
private class MuteButton extends PixmapButton implements ActionListener { |
private class MuteButton extends PixmapButton implements ActionListener { |
378 |
MuteButton() { |
MuteButton() { |
379 |
super(Res.iconMuteOff); |
super(Res.iconMuteOff); |
380 |
|
setDisabledIcon(Res.iconMuteSoloDisabled); |
381 |
addActionListener(this); |
addActionListener(this); |
382 |
} |
} |
383 |
|
|
398 |
else setIcon(Res.iconMutedBySolo); |
else setIcon(Res.iconMutedBySolo); |
399 |
} else setIcon(Res.iconMuteOn); |
} else setIcon(Res.iconMuteOn); |
400 |
|
|
401 |
Channel.this.getModel().setMute(b); |
Channel.this.getModel().setBackendMute(b); |
402 |
} |
} |
403 |
|
|
404 |
public boolean |
public boolean |
408 |
private class SoloButton extends PixmapButton implements ActionListener { |
private class SoloButton extends PixmapButton implements ActionListener { |
409 |
SoloButton() { |
SoloButton() { |
410 |
super(Res.iconSoloOff); |
super(Res.iconSoloOff); |
411 |
|
setDisabledIcon(Res.iconMuteSoloDisabled); |
412 |
addActionListener(this); |
addActionListener(this); |
413 |
} |
} |
414 |
|
|
430 |
btnMute.setIcon(Res.iconMutedBySolo); |
btnMute.setIcon(Res.iconMutedBySolo); |
431 |
} |
} |
432 |
|
|
433 |
Channel.this.getModel().setSolo(b); |
Channel.this.getModel().setBackendSolo(b); |
434 |
} |
} |
435 |
|
|
436 |
public boolean |
public boolean |
440 |
private class OptionsButton extends PixmapToggleButton implements ActionListener { |
private class OptionsButton extends PixmapToggleButton implements ActionListener { |
441 |
OptionsButton() { |
OptionsButton() { |
442 |
super(Res.iconOptionsOff, Res.iconOptionsOn); |
super(Res.iconOptionsOff, Res.iconOptionsOn); |
443 |
|
setRolloverIcon(Res.iconOptionsOffRO); |
444 |
|
this.setRolloverSelectedIcon(Res.iconOptionsOnRO); |
445 |
addActionListener(this); |
addActionListener(this); |
446 |
} |
} |
447 |
|
|
463 |
} |
} |
464 |
|
|
465 |
public boolean |
public boolean |
466 |
contains(int x, int y) { return y < 13; } |
contains(int x, int y) { return super.contains(x, y) & y < 13; } |
467 |
} |
} |
468 |
} |
} |
469 |
|
|
541 |
|
|
542 |
btnReset.addActionListener(new ActionListener() { |
btnReset.addActionListener(new ActionListener() { |
543 |
public void |
public void |
544 |
actionPerformed(ActionEvent e) { channel.getModel().resetChannel(); } |
actionPerformed(ActionEvent e) { channel.getModel().resetBackendChannel(); } |
545 |
}); |
}); |
546 |
|
|
547 |
btnDuplicate.addActionListener(new ActionListener() { |
btnDuplicate.addActionListener(new ActionListener() { |
548 |
public void |
public void |
549 |
actionPerformed(ActionEvent e) { channel.getModel().duplicateChannel(); } |
actionPerformed(ActionEvent e) { |
550 |
|
channel.getModel().duplicateBackendChannel(); |
551 |
|
} |
552 |
}); |
}); |
553 |
} |
} |
554 |
|
|
559 |
|
|
560 |
if(!dlg.isCancelled()) { |
if(!dlg.isCancelled()) { |
561 |
SamplerChannelModel m = channel.getModel(); |
SamplerChannelModel m = channel.getModel(); |
562 |
m.loadInstrument(dlg.getFileName(), dlg.getInstrumentIndex()); |
m.loadBackendInstrument(dlg.getFileName(), dlg.getInstrumentIndex()); |
563 |
} |
} |
564 |
} |
} |
565 |
|
|
768 |
|
|
769 |
cbAudioDevice.addActionListener(new ActionListener() { |
cbAudioDevice.addActionListener(new ActionListener() { |
770 |
public void |
public void |
771 |
actionPerformed(ActionEvent e) { setAudioDevice(); } |
actionPerformed(ActionEvent e) { setBackendAudioDevice(); } |
772 |
}); |
}); |
773 |
|
|
774 |
channel.getModel().addSamplerChannelListener(new SamplerChannelAdapter() { |
channel.getModel().addSamplerChannelListener(new SamplerChannelAdapter() { |
868 |
MidiInputDevice mid = (MidiInputDevice)cbMidiDevice.getSelectedItem(); |
MidiInputDevice mid = (MidiInputDevice)cbMidiDevice.getSelectedItem(); |
869 |
|
|
870 |
if(!isUpdate()) { |
if(!isUpdate()) { |
871 |
if(mid != null) channel.getModel().setMidiInputDevice(mid.getDeviceID()); |
if(mid != null) { |
872 |
|
channel.getModel().setBackendMidiInputDevice(mid.getDeviceId()); |
873 |
|
} |
874 |
|
|
875 |
return; |
return; |
876 |
} |
} |
877 |
|
|
901 |
setMidiPort() { |
setMidiPort() { |
902 |
if(isUpdate()) return; |
if(isUpdate()) return; |
903 |
|
|
904 |
channel.getModel().setMidiInputPort(cbMidiPort.getSelectedIndex()); |
channel.getModel().setBackendMidiInputPort(cbMidiPort.getSelectedIndex()); |
905 |
} |
} |
906 |
|
|
907 |
private void |
private void |
914 |
|
|
915 |
int c = s.equals("All") ? -1 : Integer.parseInt(s.substring(8)) - 1; |
int c = s.equals("All") ? -1 : Integer.parseInt(s.substring(8)) - 1; |
916 |
|
|
917 |
channel.getModel().setMidiInputChannel(c); |
channel.getModel().setBackendMidiInputChannel(c); |
918 |
} |
} |
919 |
|
|
920 |
/** Invoked when the user selects an engine. */ |
/** Invoked when the user selects an engine. */ |
926 |
if(oldEngine != null) { if(oldEngine.equals(newEngine)) return; } |
if(oldEngine != null) { if(oldEngine.equals(newEngine)) return; } |
927 |
else if(newEngine == null) return; |
else if(newEngine == null) return; |
928 |
|
|
929 |
channel.getModel().setEngineType(newEngine.getName()); |
channel.getModel().setBackendEngineType(newEngine.getName()); |
930 |
|
|
931 |
} |
} |
932 |
|
|
933 |
private void |
private void |
934 |
setAudioDevice() { |
setBackendAudioDevice() { |
935 |
if(isUpdate()) return; |
if(isUpdate()) return; |
936 |
AudioOutputDevice dev = (AudioOutputDevice)cbAudioDevice.getSelectedItem(); |
AudioOutputDevice dev = (AudioOutputDevice)cbAudioDevice.getSelectedItem(); |
937 |
if(dev != null) channel.getModel().setAudioOutputDevice(dev.getDeviceID()); |
if(dev != null) channel.getModel().setBackendAudioOutputDevice(dev.getDeviceId()); |
938 |
} |
} |
939 |
|
|
940 |
/** |
/** |
959 |
private Handler |
private Handler |
960 |
getHandler() { return handler; } |
getHandler() { return handler; } |
961 |
|
|
962 |
private class Handler implements MidiDeviceListListener, AudioDeviceListListener { |
private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel> { |
963 |
/** |
/** |
964 |
* Invoked when a new MIDI device is created. |
* Invoked when a new MIDI device is created. |
965 |
* @param e A <code>MidiDeviceListEvent</code> |
* @param e A <code>MidiDeviceListEvent</code> |
986 |
* instance providing the event information. |
* instance providing the event information. |
987 |
*/ |
*/ |
988 |
public void |
public void |
989 |
deviceAdded(AudioDeviceListEvent e) { |
entryAdded(ListEvent<AudioDeviceModel> e) { |
990 |
cbAudioDevice.addItem(e.getAudioDeviceModel().getDeviceInfo()); |
cbAudioDevice.addItem(e.getEntry().getDeviceInfo()); |
991 |
} |
} |
992 |
|
|
993 |
/** |
/** |
996 |
* instance providing the event information. |
* instance providing the event information. |
997 |
*/ |
*/ |
998 |
public void |
public void |
999 |
deviceRemoved(AudioDeviceListEvent e) { |
entryRemoved(ListEvent<AudioDeviceModel> e) { |
1000 |
cbAudioDevice.removeItem(e.getAudioDeviceModel().getDeviceInfo()); |
cbAudioDevice.removeItem(e.getEntry().getDeviceInfo()); |
1001 |
} |
} |
1002 |
} |
} |
1003 |
} |
} |