1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
24 |
|
|
25 |
import java.util.Vector; |
import java.util.Vector; |
26 |
|
|
27 |
import javax.swing.SwingUtilities; |
import net.sf.juife.PDUtils; |
28 |
|
|
29 |
import org.jsampler.event.MidiDeviceEvent; |
import org.jsampler.event.MidiDeviceEvent; |
30 |
import org.jsampler.event.MidiDeviceListener; |
import org.jsampler.event.MidiDeviceListener; |
31 |
|
|
32 |
import org.jsampler.task.Midi; |
import org.jsampler.task.Midi; |
33 |
|
|
|
import org.linuxsampler.lscp.BoolParameter; |
|
34 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
35 |
import org.linuxsampler.lscp.Parameter; |
import org.linuxsampler.lscp.Parameter; |
36 |
|
|
64 |
* the settings of the MIDI device are changed. |
* the settings of the MIDI device are changed. |
65 |
* @param l The <code>MidiDeviceListener</code> to register. |
* @param l The <code>MidiDeviceListener</code> to register. |
66 |
*/ |
*/ |
67 |
|
@Override |
68 |
public void |
public void |
69 |
addMidiDeviceListener(MidiDeviceListener l) { listeners.add(l); } |
addMidiDeviceListener(MidiDeviceListener l) { listeners.add(l); } |
70 |
|
|
72 |
* Removes the specified listener. |
* Removes the specified listener. |
73 |
* @param l The <code>MidiDeviceListener</code> to remove. |
* @param l The <code>MidiDeviceListener</code> to remove. |
74 |
*/ |
*/ |
75 |
|
@Override |
76 |
public void |
public void |
77 |
removeMidiDeviceListener(MidiDeviceListener l) { listeners.remove(l); } |
removeMidiDeviceListener(MidiDeviceListener l) { listeners.remove(l); } |
78 |
|
|
81 |
* @return The numerical ID of this MIDI device or |
* @return The numerical ID of this MIDI device or |
82 |
* -1 if the device number is not set. |
* -1 if the device number is not set. |
83 |
*/ |
*/ |
84 |
|
@Override |
85 |
public int |
public int |
86 |
getDeviceId() { return midiDevice.getDeviceId(); } |
getDeviceId() { return midiDevice.getDeviceId(); } |
87 |
|
|
90 |
* @return <code>MidiInputDevice</code> instance providing |
* @return <code>MidiInputDevice</code> instance providing |
91 |
* the current settings of the MIDI device represented by this model. |
* the current settings of the MIDI device represented by this model. |
92 |
*/ |
*/ |
93 |
|
@Override |
94 |
public MidiInputDevice |
public MidiInputDevice |
95 |
getDeviceInfo() { return midiDevice; } |
getDeviceInfo() { return midiDevice; } |
96 |
|
|
98 |
* Updates the settings of the MIDI device represented by this model. |
* Updates the settings of the MIDI device represented by this model. |
99 |
* @param device The new MIDI device settings. |
* @param device The new MIDI device settings. |
100 |
*/ |
*/ |
101 |
|
@Override |
102 |
public void |
public void |
103 |
setDeviceInfo(MidiInputDevice device) { |
setDeviceInfo(MidiInputDevice device) { |
104 |
midiDevice = device; |
midiDevice = device; |
110 |
* @param active If <code>true</code> the MIDI device is enabled, |
* @param active If <code>true</code> the MIDI device is enabled, |
111 |
* else the device is disabled. |
* else the device is disabled. |
112 |
*/ |
*/ |
113 |
|
@Override |
114 |
public void |
public void |
115 |
setActive(boolean active) { |
setActive(boolean active) { |
116 |
if(active == getDeviceInfo().isActive()) return; |
if(active == getDeviceInfo().isActive()) return; |
123 |
* Determines whether the MIDI device is active. |
* Determines whether the MIDI device is active. |
124 |
* @return <code>true</code> if the device is enabled and <code>false</code> otherwise. |
* @return <code>true</code> if the device is enabled and <code>false</code> otherwise. |
125 |
*/ |
*/ |
126 |
|
@Override |
127 |
public boolean |
public boolean |
128 |
isActive() { return midiDevice.isActive(); } |
isActive() { return midiDevice.isActive(); } |
129 |
|
|
132 |
* @param active If <code>true</code> the MIDI device is enabled, |
* @param active If <code>true</code> the MIDI device is enabled, |
133 |
* else the device is disabled. |
* else the device is disabled. |
134 |
*/ |
*/ |
135 |
|
@Override |
136 |
public void |
public void |
137 |
setBackendActive(boolean active) { |
setBackendActive(boolean active) { |
138 |
CC.getTaskQueue().add(new Midi.EnableDevice(getDeviceId(), active)); |
CC.getTaskQueue().add(new Midi.EnableDevice(getDeviceId(), active)); |
143 |
* a specific setting of the MIDI input device. |
* a specific setting of the MIDI input device. |
144 |
* @param prm The parameter to be set. |
* @param prm The parameter to be set. |
145 |
*/ |
*/ |
146 |
|
@Override |
147 |
public void |
public void |
148 |
setBackendDeviceParameter(Parameter prm) { |
setBackendDeviceParameter(Parameter prm) { |
149 |
CC.getTaskQueue().add(new Midi.SetDeviceParameter(getDeviceId(), prm)); |
CC.getTaskQueue().add(new Midi.SetDeviceParameter(getDeviceId(), prm)); |
153 |
* Schedules a new task for changing the port number of the MIDI device. |
* Schedules a new task for changing the port number of the MIDI device. |
154 |
* @param ports The new number of ports. |
* @param ports The new number of ports. |
155 |
*/ |
*/ |
156 |
|
@Override |
157 |
public void |
public void |
158 |
setBackendPortCount(int ports) { |
setBackendPortCount(int ports) { |
159 |
CC.getTaskQueue().add(new Midi.SetPortCount(getDeviceId(), ports)); |
CC.getTaskQueue().add(new Midi.SetPortCount(getDeviceId(), ports)); |
165 |
* @param port The port number. |
* @param port The port number. |
166 |
* @param prm The parameter to be set. |
* @param prm The parameter to be set. |
167 |
*/ |
*/ |
168 |
|
@Override |
169 |
public void |
public void |
170 |
setBackendPortParameter(int port, Parameter prm) { |
setBackendPortParameter(int port, Parameter prm) { |
171 |
CC.getTaskQueue().add(new Midi.SetPortParameter(getDeviceId(), port, prm)); |
CC.getTaskQueue().add(new Midi.SetPortParameter(getDeviceId(), port, prm)); |
176 |
*/ |
*/ |
177 |
private void |
private void |
178 |
fireSettingsChanged() { |
fireSettingsChanged() { |
179 |
SwingUtilities.invokeLater(new Runnable() { |
PDUtils.runOnUiThread(new Runnable() { |
180 |
public void |
public void |
181 |
run() { |
run() { |
182 |
MidiDeviceModel model = DefaultMidiDeviceModel.this; |
MidiDeviceModel model = DefaultMidiDeviceModel.this; |