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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 787 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 2195 by iliev, Tue Jun 28 22:44:39 2011 UTC
# Line 1  Line 1 
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-2011 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 22  Line 22 
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;
# Line 31  import org.linuxsampler.lscp.*; Line 31  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   * @author Grigor Iliev
38   */   */
39  public interface SamplerModel {  public interface SamplerModel {
# Line 49  public interface SamplerModel { Line 51  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.
# Line 73  public interface SamplerModel { Line 75  public interface SamplerModel {
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);
# Line 99  public interface SamplerModel { Line 113  public interface SamplerModel {
113           */           */
114          public AudioOutputDriver[] getAudioOutputDrivers();          public AudioOutputDriver[] getAudioOutputDrivers();
115                    
116            
117            
118          /**          /**
119           * Gets the model of the audio device with ID <code>deviceID</code>.           * Gets the model of the audio device at the specified position.
120           * @param deviceID The ID of the audio device whose model should be obtained.           * @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>           * @return The model of the specified audio device or <code>null</code>
130           * if there is no audio device with ID <code>deviceID</code>.           * if there is no audio device with ID <code>deviceId</code>.
131           */           */
132          public AudioDeviceModel getAudioDeviceModel(int deviceID);          public AudioDeviceModel getAudioDeviceById(int deviceId);
133                    
134          /**          /**
135           * Gets the current number of audio devices.           * Gets the current number of audio devices.
# Line 117  public interface SamplerModel { Line 141  public interface SamplerModel {
141           * Gets the current list of audio device models.           * Gets the current list of audio device models.
142           * @return The current list of audio device models.           * @return The current list of audio device models.
143           */           */
144          public AudioDeviceModel[] getAudioDeviceModels();          public AudioDeviceModel[] getAudioDevices();
145                    
146          /**          /**
147           * Adds the specified audio device.           * Adds the specified audio device.
# Line 127  public interface SamplerModel { Line 151  public interface SamplerModel {
151                    
152          /**          /**
153           * Removes the specified audio device.           * Removes the specified audio device.
154           * @param deviceID The ID of the audio device to be removed.           * @param deviceId The ID of the audio device to be removed.
155           * @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>
156           * 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>.
157           */           */
158          public boolean removeAudioDevice(int deviceID);          public boolean removeAudioDeviceById(int deviceId);
159            
160            /**
161             * 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           * Gets all MIDI input drivers currently available for the LinuxSampler instance.           * Gets all MIDI input drivers currently available for the LinuxSampler instance.
# Line 142  public interface SamplerModel { Line 172  public interface SamplerModel {
172          public MidiInputDriver[] getMidiInputDrivers();          public MidiInputDriver[] getMidiInputDrivers();
173                    
174          /**          /**
175           * Gets the model of the MIDI device with ID <code>deviceID</code>.           * Gets the model of the MIDI device at the specified position.
176           * @param deviceID The ID of the MIDI device whose model should be obtained.           * @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             * 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           * @return The model of the specified MIDI device or <code>null</code>           * @return The model of the specified MIDI device or <code>null</code>
185           * if there is no MIDI device with ID <code>deviceID</code>.           * if there is no MIDI device with ID <code>deviceId</code>.
186           */           */
187          public MidiDeviceModel getMidiDeviceModel(int deviceID);          public MidiDeviceModel getMidiDeviceById(int deviceId);
188                    
189          /**          /**
190           * Gets the current number of MIDI input devices.           * Gets the current number of MIDI input devices.
# Line 159  public interface SamplerModel { Line 196  public interface SamplerModel {
196           * Gets the current list of MIDI device models.           * Gets the current list of MIDI device models.
197           * @return The current list of MIDI device models.           * @return The current list of MIDI device models.
198           */           */
199          public MidiDeviceModel[] getMidiDeviceModels();          public MidiDeviceModel[] getMidiDevices();
200                    
201          /**          /**
202           * Adds the specified MIDI device.           * Adds the specified MIDI device.
# Line 168  public interface SamplerModel { Line 205  public interface SamplerModel {
205          public void addMidiDevice(MidiInputDevice device);          public void addMidiDevice(MidiInputDevice device);
206                    
207          /**          /**
208             * 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           * Removes the specified MIDI device.           * Removes the specified MIDI device.
216           * @param deviceID The ID of the MIDI device to be removed.           * @param deviceId The ID of the MIDI device to be removed.
217           * @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>
218           * 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>.
219             */
220            public boolean removeMidiDeviceById(int deviceId);
221            
222            /**
223             * 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 boolean removeMidiDevice(int deviceID);          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             * 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             * 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            public boolean removeMidiInstrumentMapById(int mapId);
285            
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           * Gets a list of all available engines.           * Gets a list of all available engines.
# Line 185  public interface SamplerModel { Line 337  public interface SamplerModel {
337           * Gets the current list of sampler channel models.           * Gets the current list of sampler channel models.
338           * @return The current list of sampler channel models.           * @return The current list of sampler channel models.
339           */           */
340          public SamplerChannelModel[] getChannelModels();          public SamplerChannelModel[] getChannels();
341                    
342          /**          /**
343           * Gets the model of the sampler channel with ID <code>channelID</code>.           * Gets the model of the sampler channel in the specified position.
344           * @param channelID The ID of the sampler channel whose model should be obtained.           * @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             * 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           * @return The model of the specified sampler channel or <code>null</code>           * @return The model of the specified sampler channel or <code>null</code>
354           * if there is no channel with ID <code>channelID</code>.           * if there is no channel with ID <code>channelId</code>.
355           */           */
356          public SamplerChannelModel getChannelModel(int channelID);          public SamplerChannelModel getChannelById(int channelId);
357            
358            /**
359             * Gets the position of the specified channel.
360             * @param channel The model of the channel.
361             * @return The position of the specified channel in the channel list or -1
362             * if the channel is not in the list.
363             */
364            public int getChannelIndex(SamplerChannelModel channel);
365                    
366          /**          /**
367           * Gets the current number of sampler channels.           * Gets the current number of sampler channels.
# Line 202  public interface SamplerModel { Line 370  public interface SamplerModel {
370          public int getChannelCount();          public int getChannelCount();
371                    
372          /**          /**
373           * 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
374           * when the back-end notifies for its creation.           * be actually added to this model when the backend notifies for its creation.
375           * @see #addChannel           * @see #addChannel
376           */           */
377          public void createChannel();          public void addBackendChannel();
378                    
379          /**          /**
380           * Adds the specified sampler channel.           * Adds the specified sampler channel.
# Line 216  public interface SamplerModel { Line 384  public interface SamplerModel {
384                    
385          /**          /**
386           * Removes the specified sampler channel.           * Removes the specified sampler channel.
387           * @param channelID The ID of the channel to be removed.           * Note that this method doesn't remove the channel in the backend,
388             * it is used to remove the channel from the model when those channel
389             * is removed in the backend.
390             * @param channelId The ID of the channel to be removed.
391           * @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>
392           * 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>.
393           */           */
394          public boolean removeChannel(int channelID);          public boolean removeChannelById(int channelId);
395            
396            /**
397             * Removes all sampler channels.
398             * Note that this method doesn't remove the channel in the backend.
399             */
400            public void removeAllChannels();
401            
402            /**
403             * Schedules a new task for removing the specified sampler channel on the backend side.
404             * @param channelId The ID of the channel to be removed.
405             */
406            public void removeBackendChannel(int channelId);
407                    
408          /**          /**
409           * Updates the settings of the specified channel.           * Updates the settings of the specified channel.
410           * @param channel A <code>SamplerChannel</code> instance containing the new settings           * @param channel A <code>SamplerChannel</code> instance containing the new settings
411           * for the channel.           * for the channel.
412           */           */
413          public void changeChannel(SamplerChannel channel);          public void updateChannel(SamplerChannel channel);
414            
415            /**
416             * Determines whether there are known upcoming changes to the
417             * channel list, which should be considered as part of a single action.
418             */
419            public boolean getChannelListIsAdjusting();
420            
421            /**
422             * Sets whether the upcoming changes to the
423             * channel list should be considered part of a single action.
424             */
425            public void setChannelListIsAdjusting(boolean b);
426            
427            /**
428             * Schedules a new task for starting an instrument editor for editing
429             * the loaded instrument on the specified sampler channel.
430             * @param channelId The sampler channel number.
431             */
432            public void editBackendInstrument(int channelId);
433                    
434          /**          /**
435           * 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
# Line 257  public interface SamplerModel { Line 459  public interface SamplerModel {
459          public int getMutedBySoloChannelCount();          public int getMutedBySoloChannelCount();
460                    
461          /**          /**
462             * Gets the total number of active streams.
463             * @return The total number of active streams.
464             */
465            public int getTotalStreamCount();
466            
467            /**
468           * Gets the total number of active voices.           * Gets the total number of active voices.
469           * @return The total number of active voices.           * @return The total number of active voices.
470           */           */
# Line 269  public interface SamplerModel { Line 477  public interface SamplerModel {
477          public int getTotalVoiceCountMax();          public int getTotalVoiceCountMax();
478                    
479          /**          /**
480             * Gets the golobal volume of the sampler.
481             * @return The golobal volume of the sampler.
482             */
483            public float getVolume();
484            
485            /**
486             * Sets the global volume.
487             * @param volume The new volume value.
488             */
489            public void setVolume(float volume);
490            
491            /**
492             * Sets the global volume on the backend side.
493             * @param volume The new volume value.
494             */
495            public void setBackendVolume(float volume);
496            
497            /** Gets the list of internal effects */
498            public EffectList getEffects();
499            
500            public EffectInstance getEffectInstanceById(int instanceId);
501            
502            public void updateEffectInstance(EffectInstanceInfo instance);
503            
504            /**
505             * Schedules a new task for resetting the sampler.
506             */
507            public void resetBackend();
508            
509            /**
510             * Updates the current number of active disk streams in the sampler.
511             * @param count The new number of active streams.
512             */
513            public void updateActiveStreamsInfo(int count);
514            
515            /**
516           * 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.
517           * @param count The new number of active voices.           * @param count The new number of active voices.
518           * @param countMax The maximum number of active voices.           * @param countMax The maximum number of active voices.
519           */           */
520          public void updateActiveVoiceInfo(int count, int countMax);          public void updateActiveVoiceInfo(int count, int countMax);
521            
522            /**
523             * Determines whether the sampler configuration is modified.
524             */
525            public boolean isModified();
526            
527            /**
528             * Sets whether the sampler configuration is modified.
529             */
530            public void setModified(boolean b);
531            
532            /** Resets the model. */
533            public void reset();
534  }  }

Legend:
Removed from v.787  
changed lines
  Added in v.2195

  ViewVC Help
Powered by ViewVC