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 |
* |
* |
22 |
|
|
23 |
package org.jsampler; |
package org.jsampler; |
24 |
|
|
25 |
import org.jsampler.event.AudioDeviceListListener; |
import org.jsampler.event.ListListener; |
26 |
import org.jsampler.event.MidiDeviceListListener; |
import org.jsampler.event.MidiDeviceListListener; |
27 |
import org.jsampler.event.SamplerChannelListListener; |
import org.jsampler.event.SamplerChannelListListener; |
28 |
import org.jsampler.event.SamplerListener; |
import org.jsampler.event.SamplerListener; |
31 |
|
|
32 |
|
|
33 |
/** |
/** |
34 |
* |
* A data model representing a sampler. |
35 |
|
* Note that the setter methods does <b>not</b> alter any settings |
36 |
|
* on the backend side unless otherwise specified. |
37 |
* @author Grigor Iliev |
* @author Grigor Iliev |
38 |
*/ |
*/ |
39 |
public interface SamplerModel { |
public interface SamplerModel { |
51 |
|
|
52 |
/** |
/** |
53 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
54 |
* @param listener The <code>AudioDeviceListListener</code> to register. |
* @param listener The <code>ListListener</code> to register. |
55 |
*/ |
*/ |
56 |
public void addAudioDeviceListListener(AudioDeviceListListener listener); |
public void addAudioDeviceListListener(ListListener<AudioDeviceModel> listener); |
57 |
|
|
58 |
/** |
/** |
59 |
* Removes the specified listener. |
* Removes the specified listener. |
60 |
* @param listener The <code>AudioDeviceListListener</code> to remove. |
* @param listener The <code>ListListener</code> to remove. |
61 |
*/ |
*/ |
62 |
public void removeAudioDeviceListListener(AudioDeviceListListener listener); |
public void removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener); |
63 |
|
|
64 |
/** |
/** |
65 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
75 |
|
|
76 |
/** |
/** |
77 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
78 |
|
* @param listener The <code>ListListener</code> to register. |
79 |
|
*/ |
80 |
|
public void addMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener); |
81 |
|
|
82 |
|
/** |
83 |
|
* Removes the specified listener. |
84 |
|
* @param listener The <code>ListListener</code> to remove. |
85 |
|
*/ |
86 |
|
public void removeMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener); |
87 |
|
|
88 |
|
/** |
89 |
|
* Registers the specified listener for receiving event messages. |
90 |
* @param listener The <code>SamplerChannelListListener</code> to register. |
* @param listener The <code>SamplerChannelListListener</code> to register. |
91 |
*/ |
*/ |
92 |
public void addSamplerChannelListListener(SamplerChannelListListener listener); |
public void addSamplerChannelListListener(SamplerChannelListListener listener); |
114 |
public AudioOutputDriver[] getAudioOutputDrivers(); |
public AudioOutputDriver[] getAudioOutputDrivers(); |
115 |
|
|
116 |
/** |
/** |
117 |
* Gets the model of the audio device with ID <code>deviceID</code>. |
* Gets the model of the audio device with ID <code>deviceId</code>. |
118 |
* @param deviceID The ID of the audio device whose model should be obtained. |
* @param deviceId The ID of the audio device whose model should be obtained. |
119 |
* @return The model of the specified audio device or <code>null</code> |
* @return The model of the specified audio device or <code>null</code> |
120 |
* if there is no audio device with ID <code>deviceID</code>. |
* if there is no audio device with ID <code>deviceId</code>. |
121 |
*/ |
*/ |
122 |
public AudioDeviceModel getAudioDeviceModel(int deviceID); |
public AudioDeviceModel getAudioDeviceModel(int deviceId); |
123 |
|
|
124 |
/** |
/** |
125 |
* Gets the current number of audio devices. |
* Gets the current number of audio devices. |
141 |
|
|
142 |
/** |
/** |
143 |
* Removes the specified audio device. |
* Removes the specified audio device. |
144 |
* @param deviceID The ID of the audio device to be removed. |
* @param deviceId The ID of the audio device to be removed. |
145 |
* @return <code>true</code> if the audio device is removed successfully, <code>false</code> |
* @return <code>true</code> if the audio device is removed successfully, <code>false</code> |
146 |
* if the device list does not contain audio device with ID <code>deviceID</code>. |
* if the device list does not contain audio device with ID <code>deviceId</code>. |
147 |
*/ |
*/ |
148 |
public boolean removeAudioDevice(int deviceID); |
public boolean removeAudioDevice(int deviceId); |
149 |
|
|
150 |
|
/** |
151 |
|
* Removes (on the backend side) the specified audio device. |
152 |
|
* @param deviceId The ID of the audio device to be removed. |
153 |
|
*/ |
154 |
|
public void removeBackendAudioDevice(int deviceId); |
155 |
|
|
156 |
/** |
/** |
157 |
* Gets all MIDI input drivers currently available for the LinuxSampler instance. |
* Gets all MIDI input drivers currently available for the LinuxSampler instance. |
162 |
public MidiInputDriver[] getMidiInputDrivers(); |
public MidiInputDriver[] getMidiInputDrivers(); |
163 |
|
|
164 |
/** |
/** |
165 |
* Gets the model of the MIDI device with ID <code>deviceID</code>. |
* Gets the model of the MIDI device with ID <code>deviceId</code>. |
166 |
* @param deviceID The ID of the MIDI device whose model should be obtained. |
* @param deviceId The ID of the MIDI device whose model should be obtained. |
167 |
* @return The model of the specified MIDI device or <code>null</code> |
* @return The model of the specified MIDI device or <code>null</code> |
168 |
* if there is no MIDI device with ID <code>deviceID</code>. |
* if there is no MIDI device with ID <code>deviceId</code>. |
169 |
*/ |
*/ |
170 |
public MidiDeviceModel getMidiDeviceModel(int deviceID); |
public MidiDeviceModel getMidiDeviceModel(int deviceId); |
171 |
|
|
172 |
/** |
/** |
173 |
* Gets the current number of MIDI input devices. |
* Gets the current number of MIDI input devices. |
188 |
public void addMidiDevice(MidiInputDevice device); |
public void addMidiDevice(MidiInputDevice device); |
189 |
|
|
190 |
/** |
/** |
191 |
|
* Schedules a new task for adding new MIDI device. |
192 |
|
* @param driver The desired MIDI input system. |
193 |
|
* @param parameters An optional list of driver specific parameters. |
194 |
|
*/ |
195 |
|
public void addBackendMidiDevice(String driver, Parameter... parameters); |
196 |
|
|
197 |
|
/** |
198 |
* Removes the specified MIDI device. |
* Removes the specified MIDI device. |
199 |
* @param deviceID The ID of the MIDI device to be removed. |
* @param deviceId The ID of the MIDI device to be removed. |
200 |
* @return <code>true</code> if the MIDI device is removed successfully, <code>false</code> |
* @return <code>true</code> if the MIDI device is removed successfully, <code>false</code> |
201 |
* if the device list does not contain MIDI device with ID <code>deviceID</code>. |
* if the device list does not contain MIDI device with ID <code>deviceId</code>. |
202 |
|
*/ |
203 |
|
public boolean removeMidiDevice(int deviceId); |
204 |
|
|
205 |
|
/** |
206 |
|
* Schedules a new task for removing the specified MIDI device. |
207 |
|
* @param deviceId The ID of the MIDI input device to be destroyed. |
208 |
|
*/ |
209 |
|
public void removeBackendMidiDevice(int deviceId); |
210 |
|
|
211 |
|
/** |
212 |
|
* Gets the MIDI instrument map with ID <code>mapId</code>. |
213 |
|
* @param mapId The ID of the MIDI instrument map to obtain. |
214 |
|
* @return The MIDI instrument map with the specified ID or <code>null</code> |
215 |
|
* if there is no MIDI instrument map with ID <code>mapId</code>. |
216 |
|
*/ |
217 |
|
public MidiInstrumentMap getMidiInstrumentMapById(int mapId); |
218 |
|
|
219 |
|
/** |
220 |
|
* Gets the MIDI instrument map at the specified position. |
221 |
|
* @param index The position of the MIDI instrument map to return. |
222 |
|
* @return The MIDI instrument map at the specified position. |
223 |
|
*/ |
224 |
|
public MidiInstrumentMap getMidiInstrumentMap(int index); |
225 |
|
|
226 |
|
/** |
227 |
|
* Gets the current number of MIDI instrument maps. |
228 |
|
* @return The current number of MIDI instrument maps. |
229 |
|
*/ |
230 |
|
public int getMidiInstrumentMapCount(); |
231 |
|
|
232 |
|
/** |
233 |
|
* Gets the current list of MIDI instrument maps. |
234 |
|
* @return The current list of MIDI instrument maps. |
235 |
|
*/ |
236 |
|
public MidiInstrumentMap[] getMidiInstrumentMaps(); |
237 |
|
|
238 |
|
/** |
239 |
|
* Adds the specified MIDI instrument map. |
240 |
|
* @param map The MIDI instrument map to be added. |
241 |
|
*/ |
242 |
|
public void addMidiInstrumentMap(MidiInstrumentMap map); |
243 |
|
|
244 |
|
/** |
245 |
|
* Schedules a new task for creating a new MIDI instrument map on the backend side. |
246 |
|
* @param name The name of the MIDI instrument map. |
247 |
|
* @throws IllegalArgumentException If <code>name</code> is <code>null</code>. |
248 |
|
*/ |
249 |
|
public void addBackendMidiInstrumentMap(String name); |
250 |
|
|
251 |
|
/** |
252 |
|
* Removes the specified MIDI instrument map. |
253 |
|
* @param mapId The ID of the MIDI instrument map to be removed. |
254 |
|
* @return <code>true</code> if the MIDI instrument map is removed successfully, |
255 |
|
* <code>false</code> if the MIDI instrument map's list does not contain |
256 |
|
* MIDI instrument map with ID <code>mapId</code>. |
257 |
|
*/ |
258 |
|
public boolean removeMidiInstrumentMap(int mapId); |
259 |
|
|
260 |
|
/** Removes all MIDI instrument maps. */ |
261 |
|
public void removeAllMidiInstrumentMaps(); |
262 |
|
|
263 |
|
/** |
264 |
|
* Schedules a new task for removing the |
265 |
|
* specified MIDI instrument map on the backend side. |
266 |
|
* @param mapId The numerical ID of the MIDI instrument map to remove. |
267 |
|
* @throws IllegalArgumentException If <code>mapId</code> is negative. |
268 |
|
*/ |
269 |
|
public void removeBackendMidiInstrumentMap(int mapId); |
270 |
|
|
271 |
|
/** |
272 |
|
* Schedules a new task for changing the name of |
273 |
|
* the specified MIDI instrument map on the backend side. |
274 |
|
* @param mapId The numerical ID of the MIDI instrument map. |
275 |
|
* @param name The new name for the specified MIDI instrument map. |
276 |
|
*/ |
277 |
|
public void setBackendMidiInstrumentMapName(int mapId, String name); |
278 |
|
|
279 |
|
/** |
280 |
|
* Gets the default MIDI instrument map. |
281 |
|
* @return The default MIDI instrument map or <code>null</code> |
282 |
|
* if there are no maps created. |
283 |
*/ |
*/ |
284 |
public boolean removeMidiDevice(int deviceID); |
public MidiInstrumentMap getDefaultMidiInstrumentMap(); |
285 |
|
|
286 |
|
/** |
287 |
|
* Schedules a new task for mapping a MIDI instrument on the backend side. |
288 |
|
* @param mapId The id of the MIDI instrument map. |
289 |
|
* @param bank The index of the MIDI bank, which shall contain the instrument. |
290 |
|
* @param program The MIDI program number of the new instrument. |
291 |
|
* @param instrInfo Provides the MIDI instrument settings. |
292 |
|
*/ |
293 |
|
public void |
294 |
|
mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo); |
295 |
|
|
296 |
|
/** |
297 |
|
* Schedules a new task for removing a MIDI instrument on the backend side. |
298 |
|
* @param mapId The id of the MIDI instrument map containing the instrument to be removed. |
299 |
|
* @param bank The index of the MIDI bank containing the instrument to be removed. |
300 |
|
* @param program The MIDI program number of the instrument to be removed. |
301 |
|
*/ |
302 |
|
public void unmapBackendMidiInstrument(int mapId, int bank, int program); |
303 |
|
|
304 |
/** |
/** |
305 |
* Gets a list of all available engines. |
* Gets a list of all available engines. |
314 |
public SamplerChannelModel[] getChannelModels(); |
public SamplerChannelModel[] getChannelModels(); |
315 |
|
|
316 |
/** |
/** |
317 |
* Gets the model of the sampler channel with ID <code>channelID</code>. |
* Gets the model of the sampler channel with ID <code>channelId</code>. |
318 |
* @param channelID The ID of the sampler channel whose model should be obtained. |
* @param channelId The ID of the sampler channel whose model should be obtained. |
319 |
* @return The model of the specified sampler channel or <code>null</code> |
* @return The model of the specified sampler channel or <code>null</code> |
320 |
* if there is no channel with ID <code>channelID</code>. |
* if there is no channel with ID <code>channelId</code>. |
321 |
*/ |
*/ |
322 |
public SamplerChannelModel getChannelModel(int channelID); |
public SamplerChannelModel getChannelModel(int channelId); |
323 |
|
|
324 |
/** |
/** |
325 |
* Gets the current number of sampler channels. |
* Gets the current number of sampler channels. |
328 |
public int getChannelCount(); |
public int getChannelCount(); |
329 |
|
|
330 |
/** |
/** |
331 |
* Creates a new sampler channel. The channel will be actually added to this model |
* Adds a new sampler channel on the backend side. The channel will |
332 |
* when the back-end notifies for its creation. |
* be actually added to this model when the backend notifies for its creation. |
333 |
* @see #addChannel |
* @see #addChannel |
334 |
*/ |
*/ |
335 |
public void createChannel(); |
public void addBackendChannel(); |
336 |
|
|
337 |
/** |
/** |
338 |
* Adds the specified sampler channel. |
* Adds the specified sampler channel. |
342 |
|
|
343 |
/** |
/** |
344 |
* Removes the specified sampler channel. |
* Removes the specified sampler channel. |
345 |
* @param channelID The ID of the channel to be removed. |
* Note that this method doesn't remove the channel in the backend, |
346 |
|
* it is used to remove the channel from the model when those channel |
347 |
|
* is removed in the backend. |
348 |
|
* @param channelId The ID of the channel to be removed. |
349 |
* @return <code>true</code> if the channel is removed successfully, <code>false</code> |
* @return <code>true</code> if the channel is removed successfully, <code>false</code> |
350 |
* if the channel's list does not contain channel with ID <code>channelID</code>. |
* if the channel's list does not contain channel with ID <code>channelId</code>. |
351 |
|
*/ |
352 |
|
public boolean removeChannel(int channelId); |
353 |
|
|
354 |
|
/** |
355 |
|
* Schedules a new task for removing the specified sampler channel on the backend side. |
356 |
|
* @param channelId The ID of the channel to be removed. |
357 |
*/ |
*/ |
358 |
public boolean removeChannel(int channelID); |
public void removeBackendChannel(int channelId); |
359 |
|
|
360 |
/** |
/** |
361 |
* Updates the settings of the specified channel. |
* Updates the settings of the specified channel. |
362 |
* @param channel A <code>SamplerChannel</code> instance containing the new settings |
* @param channel A <code>SamplerChannel</code> instance containing the new settings |
363 |
* for the channel. |
* for the channel. |
364 |
*/ |
*/ |
365 |
public void changeChannel(SamplerChannel channel); |
public void updateChannel(SamplerChannel channel); |
366 |
|
|
367 |
/** |
/** |
368 |
* Determines whether there is at least one solo channel in the current list |
* Determines whether there is at least one solo channel in the current list |
404 |
public int getTotalVoiceCountMax(); |
public int getTotalVoiceCountMax(); |
405 |
|
|
406 |
/** |
/** |
407 |
|
* Gets the golobal volume of the sampler. |
408 |
|
* @return The golobal volume of the sampler. |
409 |
|
*/ |
410 |
|
public float getVolume(); |
411 |
|
|
412 |
|
/** |
413 |
|
* Sets the global volume. |
414 |
|
* @param volume The new volume value. |
415 |
|
*/ |
416 |
|
public void setVolume(float volume); |
417 |
|
|
418 |
|
/** |
419 |
|
* Sets the global volume on the backend side. |
420 |
|
* @param volume The new volume value. |
421 |
|
*/ |
422 |
|
public void setBackendVolume(float volume); |
423 |
|
|
424 |
|
/** |
425 |
|
* Schedules a new task for resetting the sampler. |
426 |
|
*/ |
427 |
|
public void resetBackend(); |
428 |
|
|
429 |
|
/** |
430 |
* Updates the current and the maximum number of active voices in the sampler. |
* Updates the current and the maximum number of active voices in the sampler. |
431 |
* @param count The new number of active voices. |
* @param count The new number of active voices. |
432 |
* @param countMax The maximum number of active voices. |
* @param countMax The maximum number of active voices. |