/[svn]/jsampler/trunk/src/org/jsampler/SamplerModel.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/SamplerModel.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2200 - (show annotations) (download)
Sun Jul 3 22:01:16 2011 UTC (12 years, 9 months ago) by iliev
File size: 18314 byte(s)
* added support for exporting effects to LSCP script
* Sampler Browser (work in progress): initial
  implementation of sampler channels

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 package org.jsampler;
24
25 import org.jsampler.event.ListListener;
26 import org.jsampler.event.MidiDeviceListListener;
27 import org.jsampler.event.SamplerChannelListListener;
28 import org.jsampler.event.SamplerListener;
29
30 import org.linuxsampler.lscp.*;
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
38 */
39 public interface SamplerModel {
40 /**
41 * Registers the specified listener for receiving event messages.
42 * @param l The <code>SamplerListener</code> to register.
43 */
44 public void addSamplerListener(SamplerListener l);
45
46 /**
47 * Removes the specified listener.
48 * @param l The <code>SamplerListener</code> to remove.
49 */
50 public void removeSamplerListener(SamplerListener l);
51
52 /**
53 * Registers the specified listener for receiving event messages.
54 * @param listener The <code>ListListener</code> to register.
55 */
56 public void addAudioDeviceListListener(ListListener<AudioDeviceModel> listener);
57
58 /**
59 * Removes the specified listener.
60 * @param listener The <code>ListListener</code> to remove.
61 */
62 public void removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener);
63
64 /**
65 * Registers the specified listener for receiving event messages.
66 * @param listener The <code>MidiDeviceListListener</code> to register.
67 */
68 public void addMidiDeviceListListener(MidiDeviceListListener listener);
69
70 /**
71 * Removes the specified listener.
72 * @param listener The <code>MidiDeviceListListener</code> to remove.
73 */
74 public void removeMidiDeviceListListener(MidiDeviceListListener listener);
75
76 /**
77 * 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.
91 */
92 public void addSamplerChannelListListener(SamplerChannelListListener listener);
93
94 /**
95 * Removes the specified listener.
96 * @param listener The <code>SamplerChannelListListener</code> to remove.
97 */
98 public void removeSamplerChannelListListener(SamplerChannelListListener listener);
99
100 /**
101 * Gets information about the LinuxSampler instance the front-end is connected to.
102 *
103 * @return <code>ServerInfo</code> instance containing
104 * information about the LinuxSampler instance the front-end is connected to.
105 */
106 public ServerInfo getServerInfo();
107
108 /**
109 * Gets all audio output drivers currently available for the LinuxSampler instance.
110 *
111 * @return <code>AudioOutputDriver</code> array containing all audio output drivers
112 * currently available for the LinuxSampler instance.
113 */
114 public AudioOutputDriver[] getAudioOutputDrivers();
115
116
117
118 /**
119 * Gets the model of the audio device at the specified position.
120 * @param index The position of the audio device to return.
121 * @return The model of the audio device at the specified position.
122 * @see #getAudioDeviceCount
123 */
124 public AudioDeviceModel getAudioDevice(int index);
125
126 /**
127 * Gets the model of the audio device with ID <code>deviceId</code>.
128 * @param deviceId The ID of the audio device whose model should be obtained.
129 * @return The model of the specified audio device or <code>null</code>
130 * if there is no audio device with ID <code>deviceId</code>.
131 */
132 public AudioDeviceModel getAudioDeviceById(int deviceId);
133
134 /**
135 * Gets the index of the audio device with ID <code>deviceId</code>.
136 * @param deviceId The ID of the audio device whose
137 * position in the audio device list should be obtained.
138 * @return The zero-based position of the specified audio device
139 * in the audio device list or <code>-1</code>
140 * if there is no audio device with ID <code>deviceId</code>.
141 */
142 public int getAudioDeviceIndex(int deviceId);
143
144 /**
145 * Gets the current number of audio devices.
146 * @return The current number of audio devices.
147 */
148 public int getAudioDeviceCount();
149
150 /**
151 * Gets the current list of audio device models.
152 * @return The current list of audio device models.
153 */
154 public AudioDeviceModel[] getAudioDevices();
155
156 /**
157 * Adds the specified audio device.
158 * @param device The audio device to be added.
159 */
160 public void addAudioDevice(AudioOutputDevice device);
161
162 /**
163 * Removes the specified audio device.
164 * @param deviceId The ID of the audio device to be removed.
165 * @return <code>true</code> if the audio device is removed successfully, <code>false</code>
166 * if the device list does not contain audio device with ID <code>deviceId</code>.
167 */
168 public boolean removeAudioDeviceById(int deviceId);
169
170 /**
171 * Removes (on the backend side) the specified audio device.
172 * @param deviceId The ID of the audio device to be removed.
173 */
174 public void removeBackendAudioDevice(int deviceId);
175
176 /**
177 * Gets all MIDI input drivers currently available for the LinuxSampler instance.
178 *
179 * @return <code>MidiInputDriver</code> array containing all MIDI input drivers currently
180 * available for the LinuxSampler instance.
181 */
182 public MidiInputDriver[] getMidiInputDrivers();
183
184 /**
185 * Gets the model of the MIDI device at the specified position.
186 * @param index The position of the MIDI device to return.
187 * @return The model of the MIDI device at the specified position.
188 */
189 public MidiDeviceModel getMidiDevice(int index);
190
191 /**
192 * Gets the model of the MIDI device with ID <code>deviceId</code>.
193 * @param deviceId The ID of the MIDI device whose model should be obtained.
194 * @return The model of the specified MIDI device or <code>null</code>
195 * if there is no MIDI device with ID <code>deviceId</code>.
196 */
197 public MidiDeviceModel getMidiDeviceById(int deviceId);
198
199 /**
200 * Gets the current number of MIDI input devices.
201 * @return The current number of MIDI input devices.
202 */
203 public int getMidiDeviceCount();
204
205 /**
206 * Gets the current list of MIDI device models.
207 * @return The current list of MIDI device models.
208 */
209 public MidiDeviceModel[] getMidiDevices();
210
211 /**
212 * Adds the specified MIDI device.
213 * @param device The MIDI device to be added.
214 */
215 public void addMidiDevice(MidiInputDevice device);
216
217 /**
218 * Schedules a new task for adding new MIDI device.
219 * @param driver The desired MIDI input system.
220 * @param parameters An optional list of driver specific parameters.
221 */
222 public void addBackendMidiDevice(String driver, Parameter... parameters);
223
224 /**
225 * Removes the specified MIDI device.
226 * @param deviceId The ID of the MIDI device to be removed.
227 * @return <code>true</code> if the MIDI device is removed successfully, <code>false</code>
228 * if the device list does not contain MIDI device with ID <code>deviceId</code>.
229 */
230 public boolean removeMidiDeviceById(int deviceId);
231
232 /**
233 * Schedules a new task for removing the specified MIDI device.
234 * @param deviceId The ID of the MIDI input device to be destroyed.
235 */
236 public void removeBackendMidiDevice(int deviceId);
237
238 /**
239 * Gets the MIDI instrument map with ID <code>mapId</code>.
240 * @param mapId The ID of the MIDI instrument map to obtain.
241 * @return The MIDI instrument map with the specified ID or <code>null</code>
242 * if there is no MIDI instrument map with ID <code>mapId</code>.
243 */
244 public MidiInstrumentMap getMidiInstrumentMapById(int mapId);
245
246 /**
247 * Gets the MIDI instrument map at the specified position.
248 * @param index The position of the MIDI instrument map to return.
249 * @return The MIDI instrument map at the specified position.
250 */
251 public MidiInstrumentMap getMidiInstrumentMap(int index);
252
253 /**
254 * Gets the current number of MIDI instrument maps.
255 * @return The current number of MIDI instrument maps.
256 */
257 public int getMidiInstrumentMapCount();
258
259 /**
260 * Gets the current list of MIDI instrument maps.
261 * @return The current list of MIDI instrument maps.
262 */
263 public MidiInstrumentMap[] getMidiInstrumentMaps();
264
265 /**
266 * Gets the position of the specified MIDI instrument map in the list.
267 * @param map The map whose index should be returned.
268 * @return The position of the specified map in the list,
269 * or -1 if <code>map</code> is <code>null</code> or
270 * the map list does not contain the specified map.
271 */
272 public int getMidiInstrumentMapIndex(MidiInstrumentMap map);
273
274 /**
275 * Adds the specified MIDI instrument map.
276 * @param map The MIDI instrument map to be added.
277 */
278 public void addMidiInstrumentMap(MidiInstrumentMap map);
279
280 /**
281 * Schedules a new task for creating a new MIDI instrument map on the backend side.
282 * @param name The name of the MIDI instrument map.
283 * @throws IllegalArgumentException If <code>name</code> is <code>null</code>.
284 */
285 public void addBackendMidiInstrumentMap(String name);
286
287 /**
288 * Removes the specified MIDI instrument map.
289 * @param mapId The ID of the MIDI instrument map to be removed.
290 * @return <code>true</code> if the MIDI instrument map is removed successfully,
291 * <code>false</code> if the MIDI instrument map's list does not contain
292 * MIDI instrument map with ID <code>mapId</code>.
293 */
294 public boolean removeMidiInstrumentMapById(int mapId);
295
296 /** Removes all MIDI instrument maps. */
297 public void removeAllMidiInstrumentMaps();
298
299 /**
300 * Schedules a new task for removing the
301 * specified MIDI instrument map on the backend side.
302 * @param mapId The numerical ID of the MIDI instrument map to remove.
303 * @throws IllegalArgumentException If <code>mapId</code> is negative.
304 */
305 public void removeBackendMidiInstrumentMap(int mapId);
306
307 /**
308 * Schedules a new task for changing the name of
309 * the specified MIDI instrument map on the backend side.
310 * @param mapId The numerical ID of the MIDI instrument map.
311 * @param name The new name for the specified MIDI instrument map.
312 */
313 public void setBackendMidiInstrumentMapName(int mapId, String name);
314
315 /**
316 * Gets the default MIDI instrument map.
317 * @return The default MIDI instrument map or <code>null</code>
318 * if there are no maps created.
319 */
320 public MidiInstrumentMap getDefaultMidiInstrumentMap();
321
322 /**
323 * Schedules a new task for mapping a MIDI instrument on the backend side.
324 * @param mapId The id of the MIDI instrument map.
325 * @param bank The index of the MIDI bank, which shall contain the instrument.
326 * @param program The MIDI program number of the new instrument.
327 * @param instrInfo Provides the MIDI instrument settings.
328 */
329 public void
330 mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo);
331
332 /**
333 * Schedules a new task for removing a MIDI instrument on the backend side.
334 * @param mapId The id of the MIDI instrument map containing the instrument to be removed.
335 * @param bank The index of the MIDI bank containing the instrument to be removed.
336 * @param program The MIDI program number of the instrument to be removed.
337 */
338 public void unmapBackendMidiInstrument(int mapId, int bank, int program);
339
340 /**
341 * Gets a list of all available engines.
342 * @return A list of all available engines.
343 */
344 public SamplerEngine[] getEngines();
345
346 /**
347 * Gets the current list of sampler channel models.
348 * @return The current list of sampler channel models.
349 */
350 public SamplerChannelModel[] getChannels();
351
352 /**
353 * Gets the model of the sampler channel in the specified position.
354 * @param index The position of the channel to return.
355 * @return The model of the specified sampler channel.
356 * @see #getchannelCount
357 */
358 public SamplerChannelModel getChannel(int index);
359
360 /**
361 * Gets the model of the sampler channel with ID <code>channelId</code>.
362 * @param channelId The ID of the sampler channel whose model should be obtained.
363 * @return The model of the specified sampler channel or <code>null</code>
364 * if there is no channel with ID <code>channelId</code>.
365 */
366 public SamplerChannelModel getChannelById(int channelId);
367
368 /**
369 * Gets the position of the specified channel.
370 * @param channel The model of the channel.
371 * @return The position of the specified channel in the channel list or -1
372 * if the channel is not in the list.
373 */
374 public int getChannelIndex(SamplerChannelModel channel);
375
376 /**
377 * Gets the current number of sampler channels.
378 * @return The current number of sampler channels.
379 */
380 public int getChannelCount();
381
382 /**
383 * Adds a new sampler channel on the backend side. The channel will
384 * be actually added to this model when the backend notifies for its creation.
385 * @see #addChannel
386 */
387 public void addBackendChannel();
388
389 /**
390 * Adds the specified sampler channel.
391 * @param channel The channel to be added.
392 */
393 public void addChannel(SamplerChannel channel);
394
395 /**
396 * Removes the specified sampler channel.
397 * Note that this method doesn't remove the channel in the backend,
398 * it is used to remove the channel from the model when those channel
399 * is removed in the backend.
400 * @param channelId The ID of the channel to be removed.
401 * @return <code>true</code> if the channel is removed successfully, <code>false</code>
402 * if the channel's list does not contain channel with ID <code>channelId</code>.
403 */
404 public boolean removeChannelById(int channelId);
405
406 /**
407 * Removes all sampler channels.
408 * Note that this method doesn't remove the channel in the backend.
409 */
410 public void removeAllChannels();
411
412 /**
413 * Schedules a new task for removing the specified sampler channel on the backend side.
414 * @param channelId The ID of the channel to be removed.
415 */
416 public void removeBackendChannel(int channelId);
417
418 /**
419 * Updates the settings of the specified channel.
420 * @param channel A <code>SamplerChannel</code> instance containing the new settings
421 * for the channel.
422 */
423 public void updateChannel(SamplerChannel channel);
424
425 /**
426 * Determines whether there are known upcoming changes to the
427 * channel list, which should be considered as part of a single action.
428 */
429 public boolean getChannelListIsAdjusting();
430
431 /**
432 * Sets whether the upcoming changes to the
433 * channel list should be considered part of a single action.
434 */
435 public void setChannelListIsAdjusting(boolean b);
436
437 /**
438 * Schedules a new task for starting an instrument editor for editing
439 * the loaded instrument on the specified sampler channel.
440 * @param channelId The sampler channel number.
441 */
442 public void editBackendInstrument(int channelId);
443
444 /**
445 * Determines whether there is at least one solo channel in the current list
446 * of sampler channels.
447 * @return <code>true</code> if there is at least one solo channel in the current list of
448 * sampler channels, <code>false</code> otherwise.
449 */
450 public boolean hasSoloChannel();
451
452 /**
453 * Gets the number of solo channels in the current list of sampler channels.
454 * @return The number of solo channels in the current list of sampler channels.
455 */
456 public int getSoloChannelCount();
457
458 /**
459 * Gets the number of muted channels in the current list of sampler channels.
460 * This number includes the channels muted because of the presence of a solo channel.
461 * @return The number of muted channels in the current list of sampler channels.
462 */
463 public int getMutedChannelCount();
464
465 /**
466 * Gets the number of channels muted because of the presence of a solo channel.
467 * @return The number of channels muted because of the presence of a solo channel.
468 */
469 public int getMutedBySoloChannelCount();
470
471 /**
472 * Gets the total number of active streams.
473 * @return The total number of active streams.
474 */
475 public int getTotalStreamCount();
476
477 /**
478 * Gets the total number of active voices.
479 * @return The total number of active voices.
480 */
481 public int getTotalVoiceCount();
482
483 /**
484 * Gets the maximum number of active voices.
485 * @return The maximum number of active voices.
486 */
487 public int getTotalVoiceCountMax();
488
489 /**
490 * Gets the golobal volume of the sampler.
491 * @return The golobal volume of the sampler.
492 */
493 public float getVolume();
494
495 /**
496 * Sets the global volume.
497 * @param volume The new volume value.
498 */
499 public void setVolume(float volume);
500
501 /**
502 * Sets the global volume on the backend side.
503 * @param volume The new volume value.
504 */
505 public void setBackendVolume(float volume);
506
507 /** Gets the list of internal effects */
508 public EffectList getEffects();
509
510 public EffectInstance getEffectInstanceById(int instanceId);
511
512 public void updateEffectInstance(EffectInstanceInfo instance);
513
514 /**
515 * Schedules a new task for resetting the sampler.
516 */
517 public void resetBackend();
518
519 /**
520 * Updates the current number of active disk streams in the sampler.
521 * @param count The new number of active streams.
522 */
523 public void updateActiveStreamsInfo(int count);
524
525 /**
526 * Updates the current and the maximum number of active voices in the sampler.
527 * @param count The new number of active voices.
528 * @param countMax The maximum number of active voices.
529 */
530 public void updateActiveVoiceInfo(int count, int countMax);
531
532 /**
533 * Determines whether the sampler configuration is modified.
534 */
535 public boolean isModified();
536
537 /**
538 * Sets whether the sampler configuration is modified.
539 */
540 public void setModified(boolean b);
541
542 /** Resets the model. */
543 public void reset();
544 }

  ViewVC Help
Powered by ViewVC