/[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 1204 by iliev, Thu May 24 21:43:45 2007 UTC revision 1545 by iliev, Tue Dec 4 18:28:29 2007 UTC
# 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 210  public class DefaultSamplerModel impleme Line 211  public class DefaultSamplerModel impleme
211          setAudioOutputDrivers(AudioOutputDriver[] drivers) { aoDrvS = drivers; }          setAudioOutputDrivers(AudioOutputDriver[] drivers) { aoDrvS = drivers; }
212                    
213          /**          /**
214             * Gets the model of the audio device at the specified position.
215             * @param index The position of the audio device to return.
216             * @return The model of the audio device at the specified position.
217             * @see #getAudioDeviceCount
218             */
219            public AudioDeviceModel
220            getAudioDevice(int index) {
221                    return audioDeviceModels.get(index);
222            }
223            
224            /**
225           * Gets the model of the audio device with ID <code>deviceId</code>.           * Gets the model of the audio device with ID <code>deviceId</code>.
226           * @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.
227           * @return The model of the specified audio device or <code>null</code>           * @return The model of the specified audio device or <code>null</code>
# Line 298  public class DefaultSamplerModel impleme Line 310  public class DefaultSamplerModel impleme
310          setMidiInputDrivers(MidiInputDriver[] drivers) { miDrvS = drivers; }          setMidiInputDrivers(MidiInputDriver[] drivers) { miDrvS = drivers; }
311                    
312          /**          /**
313             * Gets the model of the MIDI device at the specified position.
314             * @param index The position of the MIDI device to return.
315             * @return The model of the MIDI device at the specified position.
316             */
317            public MidiDeviceModel
318            getMidiDevice(int index) {
319                    return midiDeviceModels.get(index);
320            }
321            
322            /**
323           * Gets the model of the MIDI device with ID <code>deviceId</code>.           * Gets the model of the MIDI device with ID <code>deviceId</code>.
324           * @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.
325           * @return The model of the specified MIDI device or <code>null</code>           * @return The model of the specified MIDI device or <code>null</code>
# Line 418  public class DefaultSamplerModel impleme Line 440  public class DefaultSamplerModel impleme
440          }          }
441                    
442          /**          /**
443             * Gets the position of the specified MIDI instrument map in the list.
444             * @param map The map whose index should be returned.
445             * @return The position of the specified map in the list,
446             * or -1 if <code>map</code> is <code>null</code> or
447             * the map list does not contain the specified map.
448             */
449            public int
450            getMidiInstrumentMapIndex(MidiInstrumentMap map) {
451                    if(map == null) return -1;
452                    
453                    for(int i = 0; i < getMidiInstrumentMapCount(); i++) {
454                            if(getMidiInstrumentMap(i) == map) return i;
455                    }
456                    
457                    return -1;
458            }
459            
460            /**
461           * Adds the specified MIDI instrument map.           * Adds the specified MIDI instrument map.
462           * @param map The MIDI instrument map to be added.           * @param map The MIDI instrument map to be added.
463           * @throws IllegalArgumentException If <code>map</code> is <code>null</code>.           * @throws IllegalArgumentException If <code>map</code> is <code>null</code>.
# Line 585  public class DefaultSamplerModel impleme Line 625  public class DefaultSamplerModel impleme
625          setEngines(SamplerEngine[] engines) { this.engines = engines; }          setEngines(SamplerEngine[] engines) { this.engines = engines; }
626                    
627          /**          /**
628             * Gets the model of the sampler channel in the specified position.
629             * @param index The position of the channel to return.
630             * @return The model of the specified sampler channel.
631             * @see #getchannelCount
632             */
633            public SamplerChannelModel
634            getChannel(int index) {
635                    return channelModels.get(index);
636            }
637            
638            /**
639           * Gets the model of the sampler channel with ID <code>channelId</code>.           * Gets the model of the sampler channel with ID <code>channelId</code>.
640           * @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.
641           * @return The model of the specified sampler channel or <code>null</code>           * @return The model of the specified sampler channel or <code>null</code>
# Line 682  public class DefaultSamplerModel impleme Line 733  public class DefaultSamplerModel impleme
733           */           */
734          public void          public void
735          removeBackendChannel(int channelId) {          removeBackendChannel(int channelId) {
736                  CC.getTaskQueue().add(new org.jsampler.task.Channel.Remove(channelId));                  CC.getTaskQueue().add(new Channel.Remove(channelId));
737            }
738            
739            /**
740             * Schedules a new task for starting an instrument editor for editing
741             * the loaded instrument on the specified sampler channel.
742             * @param channelId The sampler channel number.
743             */
744            public void
745            editBackendInstrument(int channelId) {
746                    CC.getTaskQueue().add(new Channel.EditInstrument(channelId));
747          }          }
748                    
749          /**          /**
# Line 740  public class DefaultSamplerModel impleme Line 801  public class DefaultSamplerModel impleme
801          }          }
802                    
803          /**          /**
804             * Gets the total number of active streams.
805             * @return The total number of active streams.
806             */
807            public int
808            getTotalStreamCount() { return totalStreamCount; }
809            
810            /**
811           * Gets the total number of active voices.           * Gets the total number of active voices.
812           * @return The total number of active voices.           * @return The total number of active voices.
813           */           */
# Line 788  public class DefaultSamplerModel impleme Line 856  public class DefaultSamplerModel impleme
856          resetBackend() { CC.getTaskQueue().add(new org.jsampler.task.Global.ResetSampler()); }          resetBackend() { CC.getTaskQueue().add(new org.jsampler.task.Global.ResetSampler()); }
857                    
858          /**          /**
859             * Updates the current number of active disk streams in the sampler.
860             * @param count The new number of active streams.
861             */
862            public void
863            updateActiveStreamsInfo(int count) {
864                    if(totalStreamCount == count) return;
865                    
866                    totalStreamCount = count;
867                    fireTotalStreamCountChanged();
868            }
869            
870            /**
871           * 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.
872           * @param count The new number of active voices.           * @param count The new number of active voices.
873           * @param countMax The maximum number of active voices.           * @param countMax The maximum number of active voices.
# Line 1037  public class DefaultSamplerModel impleme Line 1117  public class DefaultSamplerModel impleme
1117          }          }
1118                    
1119          /*          /*
1120             * Notifies listeners that the total number of active streams has changed.
1121             * This method can be invoked outside the event-dispatching thread.
1122             */
1123            private void
1124            fireTotalStreamCountChanged() {
1125                    final SamplerEvent e = new SamplerEvent(this);
1126                            
1127                    SwingUtilities.invokeLater(new Runnable() {
1128                            public void
1129                            run() { fireTotalStreamCountChanged(e); }
1130                    });
1131            }
1132            
1133            /**
1134             * Notifies listeners that the total number of active streams has changed.
1135             */
1136            private void
1137            fireTotalStreamCountChanged(SamplerEvent e) {
1138                    for(SamplerListener l : listeners) l.totalStreamCountChanged(e);
1139            }
1140            
1141            /*
1142           * Notifies listeners that the total number of active voices has changed.           * Notifies listeners that the total number of active voices has changed.
1143           * This method can be invoked outside the event-dispatching thread.           * This method can be invoked outside the event-dispatching thread.
1144           */           */

Legend:
Removed from v.1204  
changed lines
  Added in v.1545

  ViewVC Help
Powered by ViewVC