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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1688 - (hide annotations) (download)
Thu Feb 14 16:52:36 2008 UTC (16 years, 2 months ago) by iliev
File size: 16896 byte(s)
* Implemented a backend list with option to manually choose a backend
  to connect on startup(Edit/Preferences, then click the `Backend' tab)
  and option to change the backend without restarting JSampler
  (Actions/Change Backend or Ctrl + B)

* Added confirmation messages for removing sampler channels and
  audio/MIDI devices (Edit/Preferences, then click the `View' tab)

1 iliev 787 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 1204 * Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5 iliev 787 *
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 iliev 1143 import org.jsampler.event.ListListener;
26 iliev 787 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 iliev 911 * A data model representing a sampler.
35 iliev 1143 * Note that the setter methods does <b>not</b> alter any settings
36     * on the backend side unless otherwise specified.
37 iliev 787 * @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 iliev 1143 * @param listener The <code>ListListener</code> to register.
55 iliev 787 */
56 iliev 1143 public void addAudioDeviceListListener(ListListener<AudioDeviceModel> listener);
57 iliev 787
58     /**
59     * Removes the specified listener.
60 iliev 1143 * @param listener The <code>ListListener</code> to remove.
61 iliev 787 */
62 iliev 1143 public void removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener);
63 iliev 787
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 iliev 1143 * @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 iliev 787 * @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 iliev 1467
117    
118 iliev 787 /**
119 iliev 1467 * 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 iliev 1143 * 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 iliev 787 * @return The model of the specified audio device or <code>null</code>
130 iliev 1143 * if there is no audio device with ID <code>deviceId</code>.
131 iliev 787 */
132 iliev 1204 public AudioDeviceModel getAudioDeviceById(int deviceId);
133 iliev 787
134     /**
135     * Gets the current number of audio devices.
136     * @return The current number of audio devices.
137     */
138     public int getAudioDeviceCount();
139    
140     /**
141     * Gets the current list of audio device models.
142     * @return The current list of audio device models.
143     */
144 iliev 1204 public AudioDeviceModel[] getAudioDevices();
145 iliev 787
146     /**
147     * Adds the specified audio device.
148     * @param device The audio device to be added.
149     */
150     public void addAudioDevice(AudioOutputDevice device);
151    
152     /**
153     * Removes the specified audio device.
154 iliev 1143 * @param deviceId The ID of the audio device to be removed.
155 iliev 787 * @return <code>true</code> if the audio device is removed successfully, <code>false</code>
156 iliev 1143 * if the device list does not contain audio device with ID <code>deviceId</code>.
157 iliev 787 */
158 iliev 1204 public boolean removeAudioDeviceById(int deviceId);
159 iliev 787
160     /**
161 iliev 1143 * Removes (on the backend side) the specified audio device.
162     * @param deviceId The ID of the audio device to be removed.
163     */
164     public void removeBackendAudioDevice(int deviceId);
165    
166     /**
167 iliev 787 * Gets all MIDI input drivers currently available for the LinuxSampler instance.
168     *
169     * @return <code>MidiInputDriver</code> array containing all MIDI input drivers currently
170     * available for the LinuxSampler instance.
171     */
172     public MidiInputDriver[] getMidiInputDrivers();
173    
174     /**
175 iliev 1467 * Gets the model of the MIDI device at the specified position.
176     * @param index The position of the MIDI device to return.
177     * @return The model of the MIDI device at the specified position.
178     */
179     public MidiDeviceModel getMidiDevice(int index);
180    
181     /**
182 iliev 1143 * Gets the model of the MIDI device with ID <code>deviceId</code>.
183     * @param deviceId The ID of the MIDI device whose model should be obtained.
184 iliev 787 * @return The model of the specified MIDI device or <code>null</code>
185 iliev 1143 * if there is no MIDI device with ID <code>deviceId</code>.
186 iliev 787 */
187 iliev 1204 public MidiDeviceModel getMidiDeviceById(int deviceId);
188 iliev 787
189     /**
190     * Gets the current number of MIDI input devices.
191     * @return The current number of MIDI input devices.
192     */
193     public int getMidiDeviceCount();
194    
195     /**
196     * Gets the current list of MIDI device models.
197     * @return The current list of MIDI device models.
198     */
199 iliev 1204 public MidiDeviceModel[] getMidiDevices();
200 iliev 787
201     /**
202     * Adds the specified MIDI device.
203     * @param device The MIDI device to be added.
204     */
205     public void addMidiDevice(MidiInputDevice device);
206    
207     /**
208 iliev 1143 * Schedules a new task for adding new MIDI device.
209     * @param driver The desired MIDI input system.
210     * @param parameters An optional list of driver specific parameters.
211     */
212     public void addBackendMidiDevice(String driver, Parameter... parameters);
213    
214     /**
215 iliev 787 * Removes the specified MIDI device.
216 iliev 1143 * @param deviceId The ID of the MIDI device to be removed.
217 iliev 787 * @return <code>true</code> if the MIDI device is removed successfully, <code>false</code>
218 iliev 1143 * if the device list does not contain MIDI device with ID <code>deviceId</code>.
219 iliev 787 */
220 iliev 1204 public boolean removeMidiDeviceById(int deviceId);
221 iliev 787
222     /**
223 iliev 1143 * Schedules a new task for removing the specified MIDI device.
224     * @param deviceId The ID of the MIDI input device to be destroyed.
225     */
226     public void removeBackendMidiDevice(int deviceId);
227    
228     /**
229     * Gets the MIDI instrument map with ID <code>mapId</code>.
230     * @param mapId The ID of the MIDI instrument map to obtain.
231     * @return The MIDI instrument map with the specified ID or <code>null</code>
232     * if there is no MIDI instrument map with ID <code>mapId</code>.
233     */
234     public MidiInstrumentMap getMidiInstrumentMapById(int mapId);
235    
236     /**
237     * Gets the MIDI instrument map at the specified position.
238     * @param index The position of the MIDI instrument map to return.
239     * @return The MIDI instrument map at the specified position.
240     */
241     public MidiInstrumentMap getMidiInstrumentMap(int index);
242    
243     /**
244     * Gets the current number of MIDI instrument maps.
245     * @return The current number of MIDI instrument maps.
246     */
247     public int getMidiInstrumentMapCount();
248    
249     /**
250     * Gets the current list of MIDI instrument maps.
251     * @return The current list of MIDI instrument maps.
252     */
253     public MidiInstrumentMap[] getMidiInstrumentMaps();
254    
255     /**
256 iliev 1285 * Gets the position of the specified MIDI instrument map in the list.
257     * @param map The map whose index should be returned.
258     * @return The position of the specified map in the list,
259     * or -1 if <code>map</code> is <code>null</code> or
260     * the map list does not contain the specified map.
261     */
262     public int getMidiInstrumentMapIndex(MidiInstrumentMap map);
263    
264     /**
265 iliev 1143 * Adds the specified MIDI instrument map.
266     * @param map The MIDI instrument map to be added.
267     */
268     public void addMidiInstrumentMap(MidiInstrumentMap map);
269    
270     /**
271     * Schedules a new task for creating a new MIDI instrument map on the backend side.
272     * @param name The name of the MIDI instrument map.
273     * @throws IllegalArgumentException If <code>name</code> is <code>null</code>.
274     */
275     public void addBackendMidiInstrumentMap(String name);
276    
277     /**
278     * Removes the specified MIDI instrument map.
279     * @param mapId The ID of the MIDI instrument map to be removed.
280     * @return <code>true</code> if the MIDI instrument map is removed successfully,
281     * <code>false</code> if the MIDI instrument map's list does not contain
282     * MIDI instrument map with ID <code>mapId</code>.
283     */
284 iliev 1204 public boolean removeMidiInstrumentMapById(int mapId);
285 iliev 1143
286     /** Removes all MIDI instrument maps. */
287     public void removeAllMidiInstrumentMaps();
288    
289     /**
290     * Schedules a new task for removing the
291     * specified MIDI instrument map on the backend side.
292     * @param mapId The numerical ID of the MIDI instrument map to remove.
293     * @throws IllegalArgumentException If <code>mapId</code> is negative.
294     */
295     public void removeBackendMidiInstrumentMap(int mapId);
296    
297     /**
298     * Schedules a new task for changing the name of
299     * the specified MIDI instrument map on the backend side.
300     * @param mapId The numerical ID of the MIDI instrument map.
301     * @param name The new name for the specified MIDI instrument map.
302     */
303     public void setBackendMidiInstrumentMapName(int mapId, String name);
304    
305     /**
306     * Gets the default MIDI instrument map.
307     * @return The default MIDI instrument map or <code>null</code>
308     * if there are no maps created.
309     */
310     public MidiInstrumentMap getDefaultMidiInstrumentMap();
311    
312     /**
313     * Schedules a new task for mapping a MIDI instrument on the backend side.
314     * @param mapId The id of the MIDI instrument map.
315     * @param bank The index of the MIDI bank, which shall contain the instrument.
316     * @param program The MIDI program number of the new instrument.
317     * @param instrInfo Provides the MIDI instrument settings.
318     */
319     public void
320     mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo);
321    
322     /**
323     * Schedules a new task for removing a MIDI instrument on the backend side.
324     * @param mapId The id of the MIDI instrument map containing the instrument to be removed.
325     * @param bank The index of the MIDI bank containing the instrument to be removed.
326     * @param program The MIDI program number of the instrument to be removed.
327     */
328     public void unmapBackendMidiInstrument(int mapId, int bank, int program);
329    
330     /**
331 iliev 787 * Gets a list of all available engines.
332     * @return A list of all available engines.
333     */
334     public SamplerEngine[] getEngines();
335    
336     /**
337     * Gets the current list of sampler channel models.
338     * @return The current list of sampler channel models.
339     */
340 iliev 1204 public SamplerChannelModel[] getChannels();
341 iliev 787
342     /**
343 iliev 1467 * Gets the model of the sampler channel in the specified position.
344     * @param index The position of the channel to return.
345     * @return The model of the specified sampler channel.
346     * @see #getchannelCount
347     */
348     public SamplerChannelModel getChannel(int index);
349    
350     /**
351 iliev 1143 * Gets the model of the sampler channel with ID <code>channelId</code>.
352     * @param channelId The ID of the sampler channel whose model should be obtained.
353 iliev 787 * @return The model of the specified sampler channel or <code>null</code>
354 iliev 1143 * if there is no channel with ID <code>channelId</code>.
355 iliev 787 */
356 iliev 1204 public SamplerChannelModel getChannelById(int channelId);
357 iliev 787
358     /**
359     * Gets the current number of sampler channels.
360     * @return The current number of sampler channels.
361     */
362     public int getChannelCount();
363    
364     /**
365 iliev 1143 * Adds a new sampler channel on the backend side. The channel will
366     * be actually added to this model when the backend notifies for its creation.
367 iliev 787 * @see #addChannel
368     */
369 iliev 1143 public void addBackendChannel();
370 iliev 787
371     /**
372     * Adds the specified sampler channel.
373     * @param channel The channel to be added.
374     */
375     public void addChannel(SamplerChannel channel);
376    
377     /**
378     * Removes the specified sampler channel.
379 iliev 911 * Note that this method doesn't remove the channel in the backend,
380     * it is used to remove the channel from the model when those channel
381     * is removed in the backend.
382 iliev 1143 * @param channelId The ID of the channel to be removed.
383 iliev 787 * @return <code>true</code> if the channel is removed successfully, <code>false</code>
384 iliev 1143 * if the channel's list does not contain channel with ID <code>channelId</code>.
385 iliev 787 */
386 iliev 1204 public boolean removeChannelById(int channelId);
387 iliev 787
388     /**
389 iliev 1143 * Schedules a new task for removing the specified sampler channel on the backend side.
390     * @param channelId The ID of the channel to be removed.
391     */
392     public void removeBackendChannel(int channelId);
393    
394     /**
395 iliev 787 * Updates the settings of the specified channel.
396     * @param channel A <code>SamplerChannel</code> instance containing the new settings
397     * for the channel.
398     */
399 iliev 1143 public void updateChannel(SamplerChannel channel);
400 iliev 787
401     /**
402 iliev 1341 * Schedules a new task for starting an instrument editor for editing
403     * the loaded instrument on the specified sampler channel.
404     * @param channelId The sampler channel number.
405     */
406     public void editBackendInstrument(int channelId);
407    
408     /**
409 iliev 787 * Determines whether there is at least one solo channel in the current list
410     * of sampler channels.
411     * @return <code>true</code> if there is at least one solo channel in the current list of
412     * sampler channels, <code>false</code> otherwise.
413     */
414     public boolean hasSoloChannel();
415    
416     /**
417     * Gets the number of solo channels in the current list of sampler channels.
418     * @return The number of solo channels in the current list of sampler channels.
419     */
420     public int getSoloChannelCount();
421    
422     /**
423     * Gets the number of muted channels in the current list of sampler channels.
424     * This number includes the channels muted because of the presence of a solo channel.
425     * @return The number of muted channels in the current list of sampler channels.
426     */
427     public int getMutedChannelCount();
428    
429     /**
430     * Gets the number of channels muted because of the presence of a solo channel.
431     * @return The number of channels muted because of the presence of a solo channel.
432     */
433     public int getMutedBySoloChannelCount();
434    
435     /**
436 iliev 1545 * Gets the total number of active streams.
437     * @return The total number of active streams.
438     */
439     public int getTotalStreamCount();
440    
441     /**
442 iliev 787 * Gets the total number of active voices.
443     * @return The total number of active voices.
444     */
445     public int getTotalVoiceCount();
446    
447     /**
448     * Gets the maximum number of active voices.
449     * @return The maximum number of active voices.
450     */
451     public int getTotalVoiceCountMax();
452    
453     /**
454 iliev 1143 * Gets the golobal volume of the sampler.
455     * @return The golobal volume of the sampler.
456     */
457     public float getVolume();
458    
459     /**
460     * Sets the global volume.
461     * @param volume The new volume value.
462     */
463     public void setVolume(float volume);
464    
465     /**
466     * Sets the global volume on the backend side.
467     * @param volume The new volume value.
468     */
469     public void setBackendVolume(float volume);
470    
471     /**
472     * Schedules a new task for resetting the sampler.
473     */
474     public void resetBackend();
475    
476     /**
477 iliev 1545 * Updates the current number of active disk streams in the sampler.
478     * @param count The new number of active streams.
479     */
480     public void updateActiveStreamsInfo(int count);
481    
482     /**
483 iliev 787 * Updates the current and the maximum number of active voices in the sampler.
484     * @param count The new number of active voices.
485     * @param countMax The maximum number of active voices.
486     */
487     public void updateActiveVoiceInfo(int count, int countMax);
488 iliev 1567
489     /**
490     * Determines whether the sampler configuration is modified.
491     */
492     public boolean isModified();
493    
494     /**
495     * Sets whether the sampler configuration is modified.
496     */
497     public void setModified(boolean b);
498 iliev 1688
499     /** Resets the model. */
500     public void reset();
501 iliev 787 }

  ViewVC Help
Powered by ViewVC