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

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

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

revision 1341 by iliev, Mon Sep 10 22:29:09 2007 UTC revision 2192 by iliev, Fri Jun 24 21:34:51 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-2007 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   *   *
# Line 63  public class DefaultSamplerModel impleme Line 63  public class DefaultSamplerModel impleme
63          private MidiInputDriver[] miDrvS = null;          private MidiInputDriver[] miDrvS = null;
64          private SamplerEngine[] engines = null;          private SamplerEngine[] engines = null;
65                    
66            private int totalStreamCount = 0;
67          private int totalVoiceCount = 0;          private int totalVoiceCount = 0;
68          private int totalVoiceCountMax = 0;          private int totalVoiceCountMax = 0;
69                    
# Line 74  public class DefaultSamplerModel impleme Line 75  public class DefaultSamplerModel impleme
75          private final Vector<MidiDeviceModel> midiDeviceModels = new Vector<MidiDeviceModel>();          private final Vector<MidiDeviceModel> midiDeviceModels = new Vector<MidiDeviceModel>();
76          private final Vector<MidiInstrumentMap> midiInstrMaps = new Vector<MidiInstrumentMap>();          private final Vector<MidiInstrumentMap> midiInstrMaps = new Vector<MidiInstrumentMap>();
77                    
78            private final EffectList effects = new EffectList();
79            
80          private final Vector<SamplerListener> listeners = new Vector<SamplerListener>();          private final Vector<SamplerListener> listeners = new Vector<SamplerListener>();
81          private final Vector<ListListener<MidiInstrumentMap>> mapsListeners =          private final Vector<ListListener<MidiInstrumentMap>> mapsListeners =
82                  new Vector<ListListener<MidiInstrumentMap>>();                  new Vector<ListListener<MidiInstrumentMap>>();
83                    
84          private final EventListenerList listenerList = new EventListenerList();          private final EventListenerList listenerList = new EventListenerList();
85                    
86            private boolean channelListIsAdjusting = false;
87            
88            private boolean modified = false;
89            
90                    
91          /** Creates a new instance of DefaultSamplerModel */          /** Creates a new instance of DefaultSamplerModel */
92          public          public
# Line 91  public class DefaultSamplerModel impleme Line 98  public class DefaultSamplerModel impleme
98           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
99           * @param l The <code>SamplerListener</code> to register.           * @param l The <code>SamplerListener</code> to register.
100           */           */
101            @Override
102          public void          public void
103          addSamplerListener(SamplerListener l) { listeners.add(l); }          addSamplerListener(SamplerListener l) { listeners.add(l); }
104                    
# Line 98  public class DefaultSamplerModel impleme Line 106  public class DefaultSamplerModel impleme
106           * Removes the specified listener.           * Removes the specified listener.
107           * @param l The <code>SamplerListener</code> to remove.           * @param l The <code>SamplerListener</code> to remove.
108           */           */
109            @Override
110          public void          public void
111          removeSamplerListener(SamplerListener l) { listeners.remove(l); }          removeSamplerListener(SamplerListener l) { listeners.remove(l); }
112                    
# Line 105  public class DefaultSamplerModel impleme Line 114  public class DefaultSamplerModel impleme
114           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
115           * @param listener The <code>AudioDeviceListListener</code> to register.           * @param listener The <code>AudioDeviceListListener</code> to register.
116           */           */
117            @Override
118          public void          public void
119          addAudioDeviceListListener(ListListener<AudioDeviceModel> listener) {          addAudioDeviceListListener(ListListener<AudioDeviceModel> listener) {
120                  listenerList.add(ListListener.class, listener);                  listenerList.add(ListListener.class, listener);
# Line 114  public class DefaultSamplerModel impleme Line 124  public class DefaultSamplerModel impleme
124           * Removes the specified listener.           * Removes the specified listener.
125           * @param listener The <code>AudioDeviceListListener</code> to remove.           * @param listener The <code>AudioDeviceListListener</code> to remove.
126           */           */
127            @Override
128          public void          public void
129          removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener) {          removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener) {
130                  listenerList.remove(ListListener.class, listener);                  listenerList.remove(ListListener.class, listener);
# Line 123  public class DefaultSamplerModel impleme Line 134  public class DefaultSamplerModel impleme
134           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
135           * @param listener The <code>MidiDeviceListListener</code> to register.           * @param listener The <code>MidiDeviceListListener</code> to register.
136           */           */
137            @Override
138          public void          public void
139          addMidiDeviceListListener(MidiDeviceListListener listener) {          addMidiDeviceListListener(MidiDeviceListListener listener) {
140                  listenerList.add(MidiDeviceListListener.class, listener);                  listenerList.add(MidiDeviceListListener.class, listener);
# Line 132  public class DefaultSamplerModel impleme Line 144  public class DefaultSamplerModel impleme
144           * Removes the specified listener.           * Removes the specified listener.
145           * @param listener The <code>MidiDeviceListListener</code> to remove.           * @param listener The <code>MidiDeviceListListener</code> to remove.
146           */           */
147            @Override
148          public void          public void
149          removeMidiDeviceListListener(MidiDeviceListListener listener) {          removeMidiDeviceListListener(MidiDeviceListListener listener) {
150                  listenerList.remove(MidiDeviceListListener.class, listener);                  listenerList.remove(MidiDeviceListListener.class, listener);
# Line 141  public class DefaultSamplerModel impleme Line 154  public class DefaultSamplerModel impleme
154           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
155           * @param listener The <code>ListListener</code> to register.           * @param listener The <code>ListListener</code> to register.
156           */           */
157            @Override
158          public void          public void
159          addMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener) {          addMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener) {
160                  mapsListeners.add(listener);                  mapsListeners.add(listener);
# Line 150  public class DefaultSamplerModel impleme Line 164  public class DefaultSamplerModel impleme
164           * Removes the specified listener.           * Removes the specified listener.
165           * @param listener The <code>ListListener</code> to remove.           * @param listener The <code>ListListener</code> to remove.
166           */           */
167            @Override
168          public void          public void
169          removeMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener) {          removeMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener) {
170                  mapsListeners.remove(listener);                  mapsListeners.remove(listener);
# Line 159  public class DefaultSamplerModel impleme Line 174  public class DefaultSamplerModel impleme
174           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
175           * @param listener The <code>SamplerChannelListListener</code> to register.           * @param listener The <code>SamplerChannelListListener</code> to register.
176           */           */
177            @Override
178          public void          public void
179          addSamplerChannelListListener(SamplerChannelListListener listener) {          addSamplerChannelListListener(SamplerChannelListListener listener) {
180                  listenerList.add(SamplerChannelListListener.class, listener);                  listenerList.add(SamplerChannelListListener.class, listener);
# Line 168  public class DefaultSamplerModel impleme Line 184  public class DefaultSamplerModel impleme
184           * Removes the specified listener.           * Removes the specified listener.
185           * @param listener The <code>SamplerChannelListListener</code> to remove.           * @param listener The <code>SamplerChannelListListener</code> to remove.
186           */           */
187            @Override
188          public void          public void
189          removeSamplerChannelListListener(SamplerChannelListListener listener) {          removeSamplerChannelListListener(SamplerChannelListListener listener) {
190                  listenerList.remove(SamplerChannelListListener.class, listener);                  listenerList.remove(SamplerChannelListListener.class, listener);
# Line 179  public class DefaultSamplerModel impleme Line 196  public class DefaultSamplerModel impleme
196           * @return <code>ServerInfo</code> instance containing           * @return <code>ServerInfo</code> instance containing
197           * information about the LinuxSampler instance the front-end is connected to.           * information about the LinuxSampler instance the front-end is connected to.
198           */           */
199            @Override
200          public ServerInfo          public ServerInfo
201          getServerInfo() { return serverInfo; }          getServerInfo() { return serverInfo; }
202                    
# Line 197  public class DefaultSamplerModel impleme Line 215  public class DefaultSamplerModel impleme
215           * @return <code>AudioOutputDriver</code> array containing all audio output drivers           * @return <code>AudioOutputDriver</code> array containing all audio output drivers
216           * currently available for the LinuxSampler instance.           * currently available for the LinuxSampler instance.
217           */           */
218            @Override
219          public AudioOutputDriver[]          public AudioOutputDriver[]
220          getAudioOutputDrivers() { return aoDrvS; }          getAudioOutputDrivers() { return aoDrvS; }
221                    
# Line 210  public class DefaultSamplerModel impleme Line 229  public class DefaultSamplerModel impleme
229          setAudioOutputDrivers(AudioOutputDriver[] drivers) { aoDrvS = drivers; }          setAudioOutputDrivers(AudioOutputDriver[] drivers) { aoDrvS = drivers; }
230                    
231          /**          /**
232             * Gets the model of the audio device at the specified position.
233             * @param index The position of the audio device to return.
234             * @return The model of the audio device at the specified position.
235             * @see #getAudioDeviceCount
236             */
237            @Override
238            public AudioDeviceModel
239            getAudioDevice(int index) {
240                    return audioDeviceModels.get(index);
241            }
242            
243            /**
244           * Gets the model of the audio device with ID <code>deviceId</code>.           * Gets the model of the audio device with ID <code>deviceId</code>.
245           * @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.
246           * @return The model of the specified audio device or <code>null</code>           * @return The model of the specified audio device or <code>null</code>
247           * if there is no audio device with ID <code>deviceId</code>.           * if there is no audio device with ID <code>deviceId</code>.
248           */           */
249            @Override
250          public AudioDeviceModel          public AudioDeviceModel
251          getAudioDeviceById(int deviceId) {          getAudioDeviceById(int deviceId) {
252                  for(AudioDeviceModel m : audioDeviceModels)                  for(AudioDeviceModel m : audioDeviceModels)
# Line 227  public class DefaultSamplerModel impleme Line 259  public class DefaultSamplerModel impleme
259           * Gets the current number of audio devices.           * Gets the current number of audio devices.
260           * @return The current number of audio devices.           * @return The current number of audio devices.
261           */           */
262            @Override
263          public int          public int
264          getAudioDeviceCount() { return audioDeviceModels.size(); }          getAudioDeviceCount() { return audioDeviceModels.size(); }
265                    
# Line 234  public class DefaultSamplerModel impleme Line 267  public class DefaultSamplerModel impleme
267           * Gets the current list of audio device models.           * Gets the current list of audio device models.
268           * @return The current list of audio device models.           * @return The current list of audio device models.
269           */           */
270            @Override
271          public AudioDeviceModel[]          public AudioDeviceModel[]
272          getAudioDevices() {          getAudioDevices() {
273                  return audioDeviceModels.toArray(new AudioDeviceModel[audioDeviceModels.size()]);                  return audioDeviceModels.toArray(new AudioDeviceModel[audioDeviceModels.size()]);
# Line 243  public class DefaultSamplerModel impleme Line 277  public class DefaultSamplerModel impleme
277           * Adds the specified audio device.           * Adds the specified audio device.
278           * @param device The audio device to be added.           * @param device The audio device to be added.
279           */           */
280            @Override
281          public void          public void
282          addAudioDevice(AudioOutputDevice device) {          addAudioDevice(AudioOutputDevice device) {
283                  DefaultAudioDeviceModel model = new DefaultAudioDeviceModel(device);                  DefaultAudioDeviceModel model = new DefaultAudioDeviceModel(device);
# Line 256  public class DefaultSamplerModel impleme Line 291  public class DefaultSamplerModel impleme
291           * @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>
292           * 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>.
293           */           */
294            @Override
295          public boolean          public boolean
296          removeAudioDeviceById(int deviceId) {          removeAudioDeviceById(int deviceId) {
297                  for(int i = 0; i < audioDeviceModels.size(); i++) {                  for(int i = 0; i < audioDeviceModels.size(); i++) {
# Line 274  public class DefaultSamplerModel impleme Line 310  public class DefaultSamplerModel impleme
310           * Schedules a new task for removing the specified audio device on the backend side.           * Schedules a new task for removing the specified audio device on the backend side.
311           * @param deviceId The ID of the audio device to be removed.           * @param deviceId The ID of the audio device to be removed.
312           */           */
313            @Override
314          public void          public void
315          removeBackendAudioDevice(int deviceId) {          removeBackendAudioDevice(int deviceId) {
316                  CC.getTaskQueue().add(new Audio.DestroyDevice(deviceId));                  CC.getTaskQueue().add(new Audio.DestroyDevice(deviceId));
# Line 285  public class DefaultSamplerModel impleme Line 322  public class DefaultSamplerModel impleme
322           * @return <code>MidiInputDriver</code> array containing all MIDI input drivers currently           * @return <code>MidiInputDriver</code> array containing all MIDI input drivers currently
323           * available for the LinuxSampler instance.           * available for the LinuxSampler instance.
324           */           */
325            @Override
326          public MidiInputDriver[]          public MidiInputDriver[]
327          getMidiInputDrivers() { return miDrvS; }          getMidiInputDrivers() { return miDrvS; }
328                    
# Line 298  public class DefaultSamplerModel impleme Line 336  public class DefaultSamplerModel impleme
336          setMidiInputDrivers(MidiInputDriver[] drivers) { miDrvS = drivers; }          setMidiInputDrivers(MidiInputDriver[] drivers) { miDrvS = drivers; }
337                    
338          /**          /**
339             * Gets the model of the MIDI device at the specified position.
340             * @param index The position of the MIDI device to return.
341             * @return The model of the MIDI device at the specified position.
342             */
343            @Override
344            public MidiDeviceModel
345            getMidiDevice(int index) {
346                    return midiDeviceModels.get(index);
347            }
348            
349            /**
350           * Gets the model of the MIDI device with ID <code>deviceId</code>.           * Gets the model of the MIDI device with ID <code>deviceId</code>.
351           * @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.
352           * @return The model of the specified MIDI device or <code>null</code>           * @return The model of the specified MIDI device or <code>null</code>
353           * if there is no MIDI device with ID <code>deviceId</code>.           * if there is no MIDI device with ID <code>deviceId</code>.
354           */           */
355            @Override
356          public MidiDeviceModel          public MidiDeviceModel
357          getMidiDeviceById(int deviceId) {          getMidiDeviceById(int deviceId) {
358                  for(MidiDeviceModel m : midiDeviceModels)                  for(MidiDeviceModel m : midiDeviceModels)
# Line 315  public class DefaultSamplerModel impleme Line 365  public class DefaultSamplerModel impleme
365           * Gets the current number of MIDI input devices.           * Gets the current number of MIDI input devices.
366           * @return The current number of MIDI input devices.           * @return The current number of MIDI input devices.
367           */           */
368            @Override
369          public int          public int
370          getMidiDeviceCount() { return midiDeviceModels.size(); }          getMidiDeviceCount() { return midiDeviceModels.size(); }
371                    
# Line 322  public class DefaultSamplerModel impleme Line 373  public class DefaultSamplerModel impleme
373           * Gets the current list of MIDI device models.           * Gets the current list of MIDI device models.
374           * @return The current list of MIDI device models.           * @return The current list of MIDI device models.
375           */           */
376            @Override
377          public MidiDeviceModel[]          public MidiDeviceModel[]
378          getMidiDevices() {          getMidiDevices() {
379                  return midiDeviceModels.toArray(new MidiDeviceModel[midiDeviceModels.size()]);                  return midiDeviceModels.toArray(new MidiDeviceModel[midiDeviceModels.size()]);
# Line 331  public class DefaultSamplerModel impleme Line 383  public class DefaultSamplerModel impleme
383           * Adds the specified MIDI device.           * Adds the specified MIDI device.
384           * @param device The MIDI device to be added.           * @param device The MIDI device to be added.
385           */           */
386            @Override
387          public void          public void
388          addMidiDevice(MidiInputDevice device) {          addMidiDevice(MidiInputDevice device) {
389                  DefaultMidiDeviceModel model = new DefaultMidiDeviceModel(device);                  DefaultMidiDeviceModel model = new DefaultMidiDeviceModel(device);
# Line 343  public class DefaultSamplerModel impleme Line 396  public class DefaultSamplerModel impleme
396           * @param driver The desired MIDI input system.           * @param driver The desired MIDI input system.
397           * @param parameters An optional list of driver specific parameters.           * @param parameters An optional list of driver specific parameters.
398           */           */
399            @Override
400          public void          public void
401          addBackendMidiDevice(String driver, Parameter... parameters) {          addBackendMidiDevice(String driver, Parameter... parameters) {
402                  CC.getTaskQueue().add(new Midi.CreateDevice(driver, parameters));                  CC.getTaskQueue().add(new Midi.CreateDevice(driver, parameters));
# Line 354  public class DefaultSamplerModel impleme Line 408  public class DefaultSamplerModel impleme
408           * @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>
409           * 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>.
410           */           */
411            @Override
412          public boolean          public boolean
413          removeMidiDeviceById(int deviceId) {          removeMidiDeviceById(int deviceId) {
414                  for(int i = 0; i < midiDeviceModels.size(); i++) {                  for(int i = 0; i < midiDeviceModels.size(); i++) {
# Line 372  public class DefaultSamplerModel impleme Line 427  public class DefaultSamplerModel impleme
427           * Schedules a new task for removing the specified MIDI device.           * Schedules a new task for removing the specified MIDI device.
428           * @param deviceId The ID of the MIDI input device to be destroyed.           * @param deviceId The ID of the MIDI input device to be destroyed.
429           */           */
430            @Override
431          public void          public void
432          removeBackendMidiDevice(int deviceId) {          removeBackendMidiDevice(int deviceId) {
433                  CC.getTaskQueue().add(new Midi.DestroyDevice(deviceId));                  CC.getTaskQueue().add(new Midi.DestroyDevice(deviceId));
# Line 383  public class DefaultSamplerModel impleme Line 439  public class DefaultSamplerModel impleme
439           * @return The MIDI instrument map with the specified ID or <code>null</code>           * @return The MIDI instrument map with the specified ID or <code>null</code>
440           * if there is no MIDI instrument map with ID <code>mapId</code>.           * if there is no MIDI instrument map with ID <code>mapId</code>.
441           */           */
442            @Override
443          public MidiInstrumentMap          public MidiInstrumentMap
444          getMidiInstrumentMapById(int mapId) {          getMidiInstrumentMapById(int mapId) {
445                  for(MidiInstrumentMap m : midiInstrMaps)                  for(MidiInstrumentMap m : midiInstrMaps)
# Line 396  public class DefaultSamplerModel impleme Line 453  public class DefaultSamplerModel impleme
453           * @param index The position of the MIDI instrument map to return.           * @param index The position of the MIDI instrument map to return.
454           * @return The MIDI instrument map at the specified position.           * @return The MIDI instrument map at the specified position.
455           */           */
456            @Override
457          public MidiInstrumentMap          public MidiInstrumentMap
458          getMidiInstrumentMap(int index) {          getMidiInstrumentMap(int index) {
459                  return midiInstrMaps.get(index);                  return midiInstrMaps.get(index);
# Line 405  public class DefaultSamplerModel impleme Line 463  public class DefaultSamplerModel impleme
463           * Gets the current number of MIDI instrument maps.           * Gets the current number of MIDI instrument maps.
464           * @return The current number of MIDI instrument maps.           * @return The current number of MIDI instrument maps.
465           */           */
466            @Override
467          public int          public int
468          getMidiInstrumentMapCount() { return midiInstrMaps.size(); }          getMidiInstrumentMapCount() { return midiInstrMaps.size(); }
469                    
# Line 412  public class DefaultSamplerModel impleme Line 471  public class DefaultSamplerModel impleme
471           * Gets the current list of MIDI instrument maps.           * Gets the current list of MIDI instrument maps.
472           * @return The current list of MIDI instrument maps.           * @return The current list of MIDI instrument maps.
473           */           */
474            @Override
475          public MidiInstrumentMap[]          public MidiInstrumentMap[]
476          getMidiInstrumentMaps() {          getMidiInstrumentMaps() {
477                  return midiInstrMaps.toArray(new MidiInstrumentMap[midiInstrMaps.size()]);                  return midiInstrMaps.toArray(new MidiInstrumentMap[midiInstrMaps.size()]);
# Line 424  public class DefaultSamplerModel impleme Line 484  public class DefaultSamplerModel impleme
484           * or -1 if <code>map</code> is <code>null</code> or           * or -1 if <code>map</code> is <code>null</code> or
485           * the map list does not contain the specified map.           * the map list does not contain the specified map.
486           */           */
487            @Override
488          public int          public int
489          getMidiInstrumentMapIndex(MidiInstrumentMap map) {          getMidiInstrumentMapIndex(MidiInstrumentMap map) {
490                  if(map == null) return -1;                  if(map == null) return -1;
# Line 440  public class DefaultSamplerModel impleme Line 501  public class DefaultSamplerModel impleme
501           * @param map The MIDI instrument map to be added.           * @param map The MIDI instrument map to be added.
502           * @throws IllegalArgumentException If <code>map</code> is <code>null</code>.           * @throws IllegalArgumentException If <code>map</code> is <code>null</code>.
503           */           */
504            @Override
505          public void          public void
506          addMidiInstrumentMap(MidiInstrumentMap map) {          addMidiInstrumentMap(MidiInstrumentMap map) {
507                  if(map == null) throw new IllegalArgumentException("map should be non-null!");                  if(map == null) throw new IllegalArgumentException("map should be non-null!");
# Line 453  public class DefaultSamplerModel impleme Line 515  public class DefaultSamplerModel impleme
515           * @param name The name of the MIDI instrument map.           * @param name The name of the MIDI instrument map.
516           * @throws IllegalArgumentException If <code>name</code> is <code>null</code>.           * @throws IllegalArgumentException If <code>name</code> is <code>null</code>.
517           */           */
518            @Override
519          public void          public void
520          addBackendMidiInstrumentMap(String name) {          addBackendMidiInstrumentMap(String name) {
521                  if(name == null) throw new IllegalArgumentException("name should be non-null!");                  if(name == null) throw new IllegalArgumentException("name should be non-null!");
# Line 467  public class DefaultSamplerModel impleme Line 530  public class DefaultSamplerModel impleme
530           * <code>false</code> if the MIDI instrument map's list does not contain           * <code>false</code> if the MIDI instrument map's list does not contain
531           * MIDI instrument map with ID <code>mapId</code>.           * MIDI instrument map with ID <code>mapId</code>.
532           */           */
533            @Override
534          public boolean          public boolean
535          removeMidiInstrumentMapById(int mapId) {          removeMidiInstrumentMapById(int mapId) {
536                  for(int i = 0; i < midiInstrMaps.size(); i++) {                  for(int i = 0; i < midiInstrMaps.size(); i++) {
# Line 495  public class DefaultSamplerModel impleme Line 559  public class DefaultSamplerModel impleme
559          }          }
560                    
561          /** Removes all MIDI instrument maps. */          /** Removes all MIDI instrument maps. */
562            @Override
563          public void          public void
564          removeAllMidiInstrumentMaps() {          removeAllMidiInstrumentMaps() {
565                  for(int i = midiInstrMaps.size() - 1; i >= 0; i--) {                  for(int i = midiInstrMaps.size() - 1; i >= 0; i--) {
# Line 509  public class DefaultSamplerModel impleme Line 574  public class DefaultSamplerModel impleme
574           * specified MIDI instrument map on the backend side.           * specified MIDI instrument map on the backend side.
575           * @param mapId The numerical ID of the MIDI instrument map to remove.           * @param mapId The numerical ID of the MIDI instrument map to remove.
576           */           */
577            @Override
578          public void          public void
579          removeBackendMidiInstrumentMap(int mapId) {          removeBackendMidiInstrumentMap(int mapId) {
580                  CC.getTaskQueue().add(new Midi.RemoveInstrumentMap(mapId));                  CC.getTaskQueue().add(new Midi.RemoveInstrumentMap(mapId));
# Line 520  public class DefaultSamplerModel impleme Line 586  public class DefaultSamplerModel impleme
586           * @param mapId The numerical ID of the MIDI instrument map.           * @param mapId The numerical ID of the MIDI instrument map.
587           * @param name The new name for the specified MIDI instrument map.           * @param name The new name for the specified MIDI instrument map.
588           */           */
589            @Override
590          public void          public void
591          setBackendMidiInstrumentMapName(final int mapId, String name) {          setBackendMidiInstrumentMapName(final int mapId, String name) {
592                  final Task t = new Midi.SetInstrumentMapInfo(mapId, name);                  final Task t = new Midi.SetInstrumentMapInfo(mapId, name);
# Line 545  public class DefaultSamplerModel impleme Line 612  public class DefaultSamplerModel impleme
612           * @return The default MIDI instrument map or <code>null</code>           * @return The default MIDI instrument map or <code>null</code>
613           * if there are no maps created.           * if there are no maps created.
614           */           */
615            @Override
616          public MidiInstrumentMap          public MidiInstrumentMap
617          getDefaultMidiInstrumentMap() {          getDefaultMidiInstrumentMap() {
618                  return defaultMidiInstrumentMap;                  return defaultMidiInstrumentMap;
# Line 572  public class DefaultSamplerModel impleme Line 640  public class DefaultSamplerModel impleme
640           * @param program The MIDI program number of the new instrument.           * @param program The MIDI program number of the new instrument.
641           * @param instrInfo Provides the MIDI instrument settings.           * @param instrInfo Provides the MIDI instrument settings.
642           */           */
643            @Override
644          public void          public void
645          mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo) {          mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo) {
646                  CC.getTaskQueue().add(new Midi.MapInstrument(mapId, bank, program, instrInfo));                  CC.getTaskQueue().add(new Midi.MapInstrument(mapId, bank, program, instrInfo));
# Line 583  public class DefaultSamplerModel impleme Line 652  public class DefaultSamplerModel impleme
652           * @param bank The index of the MIDI bank containing the instrument to be removed.           * @param bank The index of the MIDI bank containing the instrument to be removed.
653           * @param program The MIDI program number of the instrument to be removed.           * @param program The MIDI program number of the instrument to be removed.
654           */           */
655            @Override
656          public void          public void
657          unmapBackendMidiInstrument(int mapId, int bank, int program) {          unmapBackendMidiInstrument(int mapId, int bank, int program) {
658                  CC.getTaskQueue().add(new Midi.UnmapInstrument(mapId, bank, program));                  CC.getTaskQueue().add(new Midi.UnmapInstrument(mapId, bank, program));
# Line 592  public class DefaultSamplerModel impleme Line 662  public class DefaultSamplerModel impleme
662           * Gets a list of all available engines.           * Gets a list of all available engines.
663           * @return A list of all available engines.           * @return A list of all available engines.
664           */           */
665            @Override
666          public SamplerEngine[]          public SamplerEngine[]
667          getEngines() { return engines; }          getEngines() { return engines; }
668                    
# Line 602  public class DefaultSamplerModel impleme Line 673  public class DefaultSamplerModel impleme
673          public void          public void
674          setEngines(SamplerEngine[] engines) { this.engines = engines; }          setEngines(SamplerEngine[] engines) { this.engines = engines; }
675                    
676            /** Gets the list of internal effects */
677            public EffectList
678            getEffects() { return effects; }
679            
680            /**
681             * Gets the model of the sampler channel in the specified position.
682             * @param index The position of the channel to return.
683             * @return The model of the specified sampler channel.
684             * @see #getchannelCount
685             */
686            @Override
687            public SamplerChannelModel
688            getChannel(int index) {
689                    return channelModels.get(index);
690            }
691            
692          /**          /**
693           * Gets the model of the sampler channel with ID <code>channelId</code>.           * Gets the model of the sampler channel with ID <code>channelId</code>.
694           * @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.
695           * @return The model of the specified sampler channel or <code>null</code>           * @return The model of the specified sampler channel or <code>null</code>
696           * if there is no channel with ID <code>channelId</code>.           * if there is no channel with ID <code>channelId</code>.
697           */           */
698            @Override
699          public SamplerChannelModel          public SamplerChannelModel
700          getChannelById(int channelId) {          getChannelById(int channelId) {
701                  for(SamplerChannelModel m : channelModels)                  for(SamplerChannelModel m : channelModels)
# Line 617  public class DefaultSamplerModel impleme Line 705  public class DefaultSamplerModel impleme
705          }          }
706                    
707          /**          /**
708             * Gets the position of the specified channel.
709             * @param channel The model of the channel.
710             * @return The position of the specified channel in the channel list or -1
711             * if the channel is not in the list.
712             */
713            @Override
714            public int
715            getChannelIndex(SamplerChannelModel channel) {
716                    if(channel == null) return -1;
717                    for(int i = 0; i < channelModels.size(); i++) {
718                            if(channelModels.get(i).getChannelId() == channel.getChannelId()) return i;
719                    }
720                    
721                    return -1;
722            }
723            
724            /**
725           * Gets the current number of sampler channels.           * Gets the current number of sampler channels.
726           * @return The current number of sampler channels.           * @return The current number of sampler channels.
727           */           */
728            @Override
729          public int          public int
730          getChannelCount() { return channelModels.size(); }          getChannelCount() { return channelModels.size(); }
731                    
# Line 627  public class DefaultSamplerModel impleme Line 733  public class DefaultSamplerModel impleme
733           * Gets the current list of sampler channel models.           * Gets the current list of sampler channel models.
734           * @return The current list of sampler channel models.           * @return The current list of sampler channel models.
735           */           */
736            @Override
737          public SamplerChannelModel[]          public SamplerChannelModel[]
738          getChannels() {          getChannels() {
739                  return channelModels.toArray(new SamplerChannelModel[channelModels.size()]);                  return channelModels.toArray(new SamplerChannelModel[channelModels.size()]);
# Line 638  public class DefaultSamplerModel impleme Line 745  public class DefaultSamplerModel impleme
745           * when the backend notifies for its creation.           * when the backend notifies for its creation.
746           * @see #addChannel           * @see #addChannel
747           */           */
748            @Override
749          public void          public void
750          addBackendChannel() {          addBackendChannel() {
751                  CC.getTaskQueue().add(new Channel.Add());                  CC.getTaskQueue().add(new Channel.Add());
# Line 648  public class DefaultSamplerModel impleme Line 756  public class DefaultSamplerModel impleme
756           * Adds the specified sampler channel.           * Adds the specified sampler channel.
757           * @param channel The channel to be added.           * @param channel The channel to be added.
758           */           */
759            @Override
760          public void          public void
761          addChannel(SamplerChannel channel) {          addChannel(SamplerChannel channel) {
762                  DefaultSamplerChannelModel model = new DefaultSamplerChannelModel(channel);                  DefaultSamplerChannelModel model;
763                  channelModels.add(model);                  model = (channel == null) ? null : new DefaultSamplerChannelModel(channel);
764                    if(model != null) channelModels.add(model);
765                  fireSamplerChannelAdded(model);                  fireSamplerChannelAdded(model);
766          }          }
767                    
# Line 660  public class DefaultSamplerModel impleme Line 770  public class DefaultSamplerModel impleme
770           * @param channel A <code>SamplerChannel</code> instance containing the new settings           * @param channel A <code>SamplerChannel</code> instance containing the new settings
771           * for the channel.           * for the channel.
772           */           */
773            @Override
774          public void          public void
775          updateChannel(SamplerChannel channel) {          updateChannel(SamplerChannel channel) {
776                  for(SamplerChannelModel m : channelModels) {                  for(SamplerChannelModel m : channelModels) {
# Line 675  public class DefaultSamplerModel impleme Line 786  public class DefaultSamplerModel impleme
786          }          }
787                    
788          /**          /**
789             * Determines whether there are known upcoming changes to the
790             * channel list, which should be considered as part of a single action.
791             */
792            @Override
793            public synchronized boolean
794            getChannelListIsAdjusting() { return channelListIsAdjusting; }
795            
796            /**
797             * Sets whether the upcoming changes to the
798             * channel list should be considered part of a single action.
799             */
800            @Override
801            public synchronized void
802            setChannelListIsAdjusting(boolean b) {
803                    channelListIsAdjusting = b;
804            }
805            
806            /**
807           * Removes the specified sampler channel.           * Removes the specified sampler channel.
808             * Note that this method doesn't remove the channel in the backend,
809             * it is used to remove the channel from the model when those channel
810             * is removed in the backend.
811           * @param channelId The ID of the channel to be removed.           * @param channelId The ID of the channel to be removed.
812           * @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>
813           * 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>.
814           */           */
815            @Override
816          public boolean          public boolean
817          removeChannelById(int channelId) {          removeChannelById(int channelId) {
818                  for(int i = 0; i < channelModels.size(); i++) {                  for(int i = 0; i < channelModels.size(); i++) {
# Line 695  public class DefaultSamplerModel impleme Line 828  public class DefaultSamplerModel impleme
828          }          }
829                    
830          /**          /**
831             * Removes all sampler channels.
832             * Note that this method doesn't remove the channel in the backend.
833             */
834            @Override
835            public void
836            removeAllChannels() {
837                    if(channelModels.isEmpty()) return;
838                    
839                    setChannelListIsAdjusting(true);
840                    for(int i = channelModels.size() - 1; i > 0; i--) {
841                            SamplerChannelModel m = channelModels.get(i);
842                            channelModels.remove(i);
843                            fireSamplerChannelRemoved(m);
844                    }
845                    setChannelListIsAdjusting(false);
846                    
847                    SamplerChannelModel m = channelModels.get(0);
848                    channelModels.remove(0);
849                    fireSamplerChannelRemoved(m);
850            }
851            
852            /**
853           * Schedules a new task for removing the specified sampler channel on the backend side.           * Schedules a new task for removing the specified sampler channel on the backend side.
854           * @param channelId The ID of the channel to be removed.           * @param channelId The ID of the channel to be removed.
855           */           */
856            @Override
857          public void          public void
858          removeBackendChannel(int channelId) {          removeBackendChannel(int channelId) {
859                  CC.getTaskQueue().add(new Channel.Remove(channelId));                  CC.getTaskQueue().add(new Channel.Remove(channelId));
# Line 708  public class DefaultSamplerModel impleme Line 864  public class DefaultSamplerModel impleme
864           * the loaded instrument on the specified sampler channel.           * the loaded instrument on the specified sampler channel.
865           * @param channelId The sampler channel number.           * @param channelId The sampler channel number.
866           */           */
867            @Override
868          public void          public void
869          editBackendInstrument(int channelId) {          editBackendInstrument(int channelId) {
870                  CC.getTaskQueue().add(new Channel.EditInstrument(channelId));                  CC.getTaskQueue().add(new Channel.EditInstrument(channelId));
# Line 719  public class DefaultSamplerModel impleme Line 876  public class DefaultSamplerModel impleme
876           * @return <code>true</code> if there is at least one solo channel in the current list of           * @return <code>true</code> if there is at least one solo channel in the current list of
877           * sampler channels, <code>false</code> otherwise.           * sampler channels, <code>false</code> otherwise.
878           */           */
879            @Override
880          public boolean          public boolean
881          hasSoloChannel() {          hasSoloChannel() {
882                  for(SamplerChannelModel m : channelModels)                  for(SamplerChannelModel m : channelModels)
# Line 731  public class DefaultSamplerModel impleme Line 889  public class DefaultSamplerModel impleme
889           * Gets the number of solo channels in the current list of sampler channels.           * Gets the number of solo channels in the current list of sampler channels.
890           * @return The number of solo channels in the current list of sampler channels.           * @return The number of solo channels in the current list of sampler channels.
891           */           */
892            @Override
893          public int          public int
894          getSoloChannelCount() {          getSoloChannelCount() {
895                  int count = 0;                  int count = 0;
# Line 745  public class DefaultSamplerModel impleme Line 904  public class DefaultSamplerModel impleme
904           * This number includes the channels muted because of the presence of a solo channel.           * This number includes the channels muted because of the presence of a solo channel.
905           * @return The number of muted channels in the current list of sampler channels.           * @return The number of muted channels in the current list of sampler channels.
906           */           */
907            @Override
908          public int          public int
909          getMutedChannelCount() {          getMutedChannelCount() {
910                  int count = 0;                  int count = 0;
# Line 758  public class DefaultSamplerModel impleme Line 918  public class DefaultSamplerModel impleme
918           * Gets the number of channels muted because of the presence of a solo channel.           * Gets the number of channels muted because of the presence of a solo channel.
919           * @return The number of channels muted because of the presence of a solo channel.           * @return The number of channels muted because of the presence of a solo channel.
920           */           */
921            @Override
922          public int          public int
923          getMutedBySoloChannelCount() {          getMutedBySoloChannelCount() {
924                  int count = 0;                  int count = 0;
# Line 768  public class DefaultSamplerModel impleme Line 929  public class DefaultSamplerModel impleme
929          }          }
930                    
931          /**          /**
932             * Gets the total number of active streams.
933             * @return The total number of active streams.
934             */
935            @Override
936            public int
937            getTotalStreamCount() { return totalStreamCount; }
938            
939            /**
940           * Gets the total number of active voices.           * Gets the total number of active voices.
941           * @return The total number of active voices.           * @return The total number of active voices.
942           */           */
943            @Override
944          public int          public int
945          getTotalVoiceCount() { return totalVoiceCount; }          getTotalVoiceCount() { return totalVoiceCount; }
946                    
# Line 778  public class DefaultSamplerModel impleme Line 948  public class DefaultSamplerModel impleme
948           * Gets the maximum number of active voices.           * Gets the maximum number of active voices.
949           * @return The maximum number of active voices.           * @return The maximum number of active voices.
950           */           */
951            @Override
952          public int          public int
953          getTotalVoiceCountMax() { return totalVoiceCountMax; }          getTotalVoiceCountMax() { return totalVoiceCountMax; }
954                    
# Line 785  public class DefaultSamplerModel impleme Line 956  public class DefaultSamplerModel impleme
956           * Gets the golobal volume of the sampler.           * Gets the golobal volume of the sampler.
957           * @return The golobal volume of the sampler.           * @return The golobal volume of the sampler.
958           */           */
959            @Override
960          public float          public float
961          getVolume() { return volume; }          getVolume() { return volume; }
962                    
# Line 792  public class DefaultSamplerModel impleme Line 964  public class DefaultSamplerModel impleme
964           * Sets the global volume.           * Sets the global volume.
965           * @param volume The new volume value.           * @param volume The new volume value.
966           */           */
967            @Override
968          public void          public void
969          setVolume(float volume) {          setVolume(float volume) {
970                  if(this.volume == volume) return;                  if(this.volume == volume) return;
# Line 804  public class DefaultSamplerModel impleme Line 977  public class DefaultSamplerModel impleme
977           * Schedules a new task for setting the global volume on the backend side.           * Schedules a new task for setting the global volume on the backend side.
978           * @param volume The new volume value.           * @param volume The new volume value.
979           */           */
980            @Override
981          public void          public void
982          setBackendVolume(float volume) {          setBackendVolume(float volume) {
983                  CC.getTaskQueue().add(new Global.SetVolume(volume));                  CC.getTaskQueue().add(new Global.SetVolume(volume));
# Line 812  public class DefaultSamplerModel impleme Line 986  public class DefaultSamplerModel impleme
986          /**          /**
987           * Schedules a new task for resetting the sampler.           * Schedules a new task for resetting the sampler.
988           */           */
989            @Override
990          public void          public void
991          resetBackend() { CC.getTaskQueue().add(new org.jsampler.task.Global.ResetSampler()); }          resetBackend() { CC.getTaskQueue().add(new org.jsampler.task.Global.ResetSampler()); }
992                    
993          /**          /**
994             * Updates the current number of active disk streams in the sampler.
995             * @param count The new number of active streams.
996             */
997            @Override
998            public void
999            updateActiveStreamsInfo(int count) {
1000                    if(totalStreamCount == count) return;
1001                    
1002                    totalStreamCount = count;
1003                    fireTotalStreamCountChanged();
1004            }
1005            
1006            /**
1007           * 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.
1008           * @param count The new number of active voices.           * @param count The new number of active voices.
1009           * @param countMax The maximum number of active voices.           * @param countMax The maximum number of active voices.
1010           */           */
1011            @Override
1012          public void          public void
1013          updateActiveVoiceInfo(int count, int countMax) {          updateActiveVoiceInfo(int count, int countMax) {
1014                  if(totalVoiceCount == count && totalVoiceCountMax == countMax) return;                  if(totalVoiceCount == count && totalVoiceCountMax == countMax) return;
# Line 830  public class DefaultSamplerModel impleme Line 1019  public class DefaultSamplerModel impleme
1019          }          }
1020                    
1021          /**          /**
1022             * Determines whether the sampler configuration is modified.
1023             */
1024            @Override
1025            public boolean
1026            isModified() { return modified; }
1027            
1028            /**
1029             * Sets whether the sampler configuration is modified.
1030             */
1031            @Override
1032            public void
1033            setModified(boolean b) { modified = b; }
1034            
1035            /** Resets the model. */
1036            @Override
1037            public void
1038            reset() {
1039                    removeAllMidiInstrumentMaps();
1040                    
1041                    for(int i = channelModels.size() - 1; i >= 0; i--) {
1042                            SamplerChannelModel m = channelModels.get(i);
1043                            channelModels.remove(i);
1044                            fireSamplerChannelRemoved(m);
1045                    }
1046                    
1047                    for(int i = midiDeviceModels.size() - 1; i >= 0; i--) {
1048                            MidiDeviceModel m = midiDeviceModels.get(i);
1049                            midiDeviceModels.remove(i);
1050                            fireMidiDeviceRemoved(m);
1051                    }
1052                    
1053                    for(int i = audioDeviceModels.size() - 1; i >= 0; i--) {
1054                            AudioDeviceModel m = audioDeviceModels.get(i);
1055                            audioDeviceModels.remove(i);
1056                            fireAudioDeviceRemoved(m);
1057                    }
1058                    
1059                    setServerInfo(null);
1060                    setAudioOutputDrivers(null);
1061                    setMidiInputDrivers(null);
1062                    setEngines(null);
1063                    
1064                    setVolume(0);
1065                    setModified(false);
1066                    
1067                    totalStreamCount = 0;
1068                    totalVoiceCount = 0;
1069                    totalVoiceCountMax = 0;
1070                    
1071                    fireTotalStreamCountChanged();
1072                    fireTotalVoiceCountChanged();
1073                    fireDefaultMapChanged();
1074            }
1075            
1076            /**
1077           * Notifies listeners that a sampler channel has been added.           * Notifies listeners that a sampler channel has been added.
1078           * This method can be invoked outside the event-dispatching thread.           * This method can be invoked outside the event-dispatching thread.
1079           * @param channelModel A <code>SamplerChannelModel</code> instance.           * @param channelModel A <code>SamplerChannelModel</code> instance.
# Line 848  public class DefaultSamplerModel impleme Line 1092  public class DefaultSamplerModel impleme
1092           */           */
1093          private void          private void
1094          fireSamplerChannelAdded(SamplerChannelListEvent e) {          fireSamplerChannelAdded(SamplerChannelListEvent e) {
1095                    setModified(true);
1096                  Object[] listeners = listenerList.getListenerList();                  Object[] listeners = listenerList.getListenerList();
1097                                    
1098                  for(int i = listeners.length - 2; i >= 0; i -= 2) {                  for(int i = listeners.length - 2; i >= 0; i -= 2) {
# Line 877  public class DefaultSamplerModel impleme Line 1122  public class DefaultSamplerModel impleme
1122           */           */
1123          private void          private void
1124          fireSamplerChannelRemoved(SamplerChannelListEvent e) {          fireSamplerChannelRemoved(SamplerChannelListEvent e) {
1125                    setModified(true);
1126                  Object[] listeners = listenerList.getListenerList();                  Object[] listeners = listenerList.getListenerList();
1127                                    
1128                  for(int i = listeners.length - 2; i >= 0; i -= 2) {                  for(int i = listeners.length - 2; i >= 0; i -= 2) {
# Line 905  public class DefaultSamplerModel impleme Line 1151  public class DefaultSamplerModel impleme
1151           */           */
1152          private void          private void
1153          fireMidiDeviceAdded(MidiDeviceListEvent e) {          fireMidiDeviceAdded(MidiDeviceListEvent e) {
1154                    setModified(true);
1155                  Object[] listeners = listenerList.getListenerList();                  Object[] listeners = listenerList.getListenerList();
1156                                    
1157                  for(int i = listeners.length - 2; i >= 0; i -= 2) {                  for(int i = listeners.length - 2; i >= 0; i -= 2) {
# Line 934  public class DefaultSamplerModel impleme Line 1181  public class DefaultSamplerModel impleme
1181           */           */
1182          private void          private void
1183          fireMidiDeviceRemoved(MidiDeviceListEvent e) {          fireMidiDeviceRemoved(MidiDeviceListEvent e) {
1184                    setModified(true);
1185                  Object[] listeners = listenerList.getListenerList();                  Object[] listeners = listenerList.getListenerList();
1186                                    
1187                  for(int i = listeners.length - 2; i >= 0; i -= 2) {                  for(int i = listeners.length - 2; i >= 0; i -= 2) {
# Line 963  public class DefaultSamplerModel impleme Line 1211  public class DefaultSamplerModel impleme
1211           */           */
1212          private void          private void
1213          fireAudioDeviceAdded(ListEvent<AudioDeviceModel> e) {          fireAudioDeviceAdded(ListEvent<AudioDeviceModel> e) {
1214                    setModified(true);
1215                  Object[] listeners = listenerList.getListenerList();                  Object[] listeners = listenerList.getListenerList();
1216                                    
1217                  for(int i = listeners.length - 2; i >= 0; i -= 2) {                  for(int i = listeners.length - 2; i >= 0; i -= 2) {
# Line 988  public class DefaultSamplerModel impleme Line 1237  public class DefaultSamplerModel impleme
1237          }          }
1238                    
1239          /**          /**
1240             * Notifies listeners that an audio device has been removed.
1241             * This method should be invoked from the event-dispatching thread.
1242             */
1243            private void
1244            fireAudioDeviceRemoved(ListEvent<AudioDeviceModel> e) {
1245                    setModified(true);
1246                    Object[] listeners = listenerList.getListenerList();
1247                    
1248                    for(int i = listeners.length - 2; i >= 0; i -= 2) {
1249                            if(listeners[i] == ListListener.class) {
1250                                    ((ListListener<AudioDeviceModel>)listeners[i + 1]).entryRemoved(e);
1251                            }
1252                    }
1253            }
1254            
1255            /**
1256           * Notifies listeners that a MIDI instrument map has been added to the list.           * Notifies listeners that a MIDI instrument map has been added to the list.
1257           * This method can be invoked outside the event-dispatching thread.           * This method can be invoked outside the event-dispatching thread.
1258           */           */
# Line 1004  public class DefaultSamplerModel impleme Line 1269  public class DefaultSamplerModel impleme
1269          /** Notifies listeners that a MIDI instrument map has been added to the list. */          /** Notifies listeners that a MIDI instrument map has been added to the list. */
1270          private void          private void
1271          fireMidiInstrumentMapAdded(ListEvent<MidiInstrumentMap> e) {          fireMidiInstrumentMapAdded(ListEvent<MidiInstrumentMap> e) {
1272                    setModified(true);
1273                  for(ListListener<MidiInstrumentMap> l : mapsListeners) l.entryAdded(e);                  for(ListListener<MidiInstrumentMap> l : mapsListeners) l.entryAdded(e);
1274          }          }
1275                    
# Line 1023  public class DefaultSamplerModel impleme Line 1289  public class DefaultSamplerModel impleme
1289          /** Notifies listeners that a MIDI instrument map has been removed from the list. */          /** Notifies listeners that a MIDI instrument map has been removed from the list. */
1290          private void          private void
1291          fireMidiInstrumentMapRemoved(ListEvent<MidiInstrumentMap> e) {          fireMidiInstrumentMapRemoved(ListEvent<MidiInstrumentMap> e) {
1292                    setModified(true);
1293                  for(ListListener<MidiInstrumentMap> l : mapsListeners) l.entryRemoved(e);                  for(ListListener<MidiInstrumentMap> l : mapsListeners) l.entryRemoved(e);
1294          }          }
1295                    
           
         /**  
          * Notifies listeners that an audio device has been removed.  
          * This method should be invoked from the event-dispatching thread.  
          */  
         private void  
         fireAudioDeviceRemoved(ListEvent<AudioDeviceModel> e) {  
                 Object[] listeners = listenerList.getListenerList();  
                   
                 for(int i = listeners.length - 2; i >= 0; i -= 2) {  
                         if(listeners[i] == ListListener.class) {  
                                 ((ListListener<AudioDeviceModel>)listeners[i + 1]).entryRemoved(e);  
                         }  
                 }  
         }  
           
1296          /**          /**
1297           * Notifies listeners that the global volume has changed.           * Notifies listeners that the global volume has changed.
1298           * This method can be invoked outside the event-dispatching thread.           * This method can be invoked outside the event-dispatching thread.
# Line 1061  public class DefaultSamplerModel impleme Line 1312  public class DefaultSamplerModel impleme
1312           */           */
1313          private void          private void
1314          fireVolumeChanged(SamplerEvent e) {          fireVolumeChanged(SamplerEvent e) {
1315                    setModified(true);
1316                  for(SamplerListener l : listeners) l.volumeChanged(e);                  for(SamplerListener l : listeners) l.volumeChanged(e);
1317          }          }
1318                    
1319          /*          /*
1320             * Notifies listeners that the total number of active streams has changed.
1321             * This method can be invoked outside the event-dispatching thread.
1322             */
1323            private void
1324            fireTotalStreamCountChanged() {
1325                    final SamplerEvent e = new SamplerEvent(this);
1326                            
1327                    SwingUtilities.invokeLater(new Runnable() {
1328                            public void
1329                            run() { fireTotalStreamCountChanged(e); }
1330                    });
1331            }
1332            
1333            /**
1334             * Notifies listeners that the total number of active streams has changed.
1335             */
1336            private void
1337            fireTotalStreamCountChanged(SamplerEvent e) {
1338                    for(SamplerListener l : listeners) l.totalStreamCountChanged(e);
1339            }
1340            
1341            /*
1342           * Notifies listeners that the total number of active voices has changed.           * Notifies listeners that the total number of active voices has changed.
1343           * This method can be invoked outside the event-dispatching thread.           * This method can be invoked outside the event-dispatching thread.
1344           */           */
# Line 1087  public class DefaultSamplerModel impleme Line 1361  public class DefaultSamplerModel impleme
1361          }          }
1362                    
1363          /**          /**
1364           * Notifies listeners that the global volume has changed.           * Notifies listeners that the default MIDI instrument map is changed.
1365           */           */
1366          private void          private void
1367          fireDefaultMapChanged() {          fireDefaultMapChanged() {
# Line 1102  public class DefaultSamplerModel impleme Line 1376  public class DefaultSamplerModel impleme
1376                    
1377          private class Handler implements ListListener<MidiInstrumentMap> {          private class Handler implements ListListener<MidiInstrumentMap> {
1378                  /** Invoked when a new map is added to a list. */                  /** Invoked when a new map is added to a list. */
1379                    @Override
1380                  public void                  public void
1381                  entryAdded(ListEvent<MidiInstrumentMap> e) { updateDefaultMap(); }                  entryAdded(ListEvent<MidiInstrumentMap> e) { updateDefaultMap(); }
1382                                    
1383                  /** Invoked when a map is removed from a list. */                  /** Invoked when a map is removed from a list. */
1384                    @Override
1385                  public void                  public void
1386                  entryRemoved(ListEvent<MidiInstrumentMap> e) { updateDefaultMap(); }                  entryRemoved(ListEvent<MidiInstrumentMap> e) { updateDefaultMap(); }
1387                                    

Legend:
Removed from v.1341  
changed lines
  Added in v.2192

  ViewVC Help
Powered by ViewVC