1 /* Synthesizer.java -- A MIDI audio synthesizer interface
2    Copyright (C) 2005 Free Software Foundation, Inc.
3 
4 This file is part of GNU Classpath.
5 
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20 
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25 
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37 
38 
39 package javax.sound.midi;
40 
41 /**
42  * Interface for MIDI audio synthesizer devices.
43  *
44  * @author Anthony Green (green@redhat.com)
45  * @since 1.3
46  *
47  */
48 public interface Synthesizer extends MidiDevice
49 {
50   /**
51    * Get the maximum number of notes that the synth can play at once.
52    *
53    * @return the maximum number of notes that the synth can play at once
54    */
getMaxPolyphony()55   public int getMaxPolyphony();
56 
57   /**
58    * The processing latency for this synth in microseconds.
59    *
60    * @return the processing latency for this synth in microseconds
61    */
getLatency()62   public long getLatency();
63 
64   /**
65    * Get the set of MIDI channels controlled by this synth.
66    *
67    * @return an array of MIDI channels controlled by this synth
68    */
getChannels()69   public MidiChannel[] getChannels();
70 
71   /**
72    * Get the current status for the voices produced by this synth.
73    *
74    * @return an array of VoiceStatus objects, getMaxPolyphony() in length
75    */
getVoiceStatus()76   public VoiceStatus[] getVoiceStatus();
77 
78   /**
79    * Returns true is this synth is capable of loading soundbank.
80    *
81    * @param soundbank the Soundbank to examine
82    * @return true if soundbank can be loaded, false otherwise
83    */
isSoundbankSupported(Soundbank soundbank)84   public boolean isSoundbankSupported(Soundbank soundbank);
85 
86   /**
87    * Load an instrument into this synth.  The instrument must be part of a
88    * supported soundbank.
89    *
90    * @param instrument the Instrument to load
91    * @return true if the instrument was loaded and false otherwise
92    * @throws IllegalArgumentException if this synth doesn't support instrument
93    */
loadInstrument(Instrument instrument)94   public boolean loadInstrument(Instrument instrument);
95 
96   /**
97    * Unload an instrument from this synth.
98    *
99    * @param instrument the Instrument to unload
100    * @throws IllegalArgumentException if this synth doesn't support instrument
101    */
unloadInstrument(Instrument instrument)102   public void unloadInstrument(Instrument instrument);
103 
104   /**
105    * Move an intrument from one place to another.  The instrument at the
106    * target location is unloaded.
107    *
108    * @param from the instrument source
109    * @param to the instrument target
110    * @return if from was remapped
111    * @throws IllegalArgumentException
112    */
remapInstrument(Instrument from, Instrument to)113   public boolean remapInstrument(Instrument from, Instrument to);
114 
115   /**
116    * Get the default Soundbank for this synth.  Return null if there is no
117    * default.
118    *
119    * @return the default Soundbank for this synth, possibly null.
120    */
getDefaultSoundbank()121   public Soundbank getDefaultSoundbank();
122 
123   /**
124    * Get an array containing all instruments in this synthesizer.
125    *
126    * @return an array containing all instruments in this synthesizer
127    */
getAvailableInstruments()128   public Instrument[] getAvailableInstruments();
129 
130   /**
131    * Get an array containing all instruments loaded in this synthesizer.
132    *
133    * @return an array containing all instruments loaded in this synthesizer
134    */
getLoadedInstruments()135   public Instrument[] getLoadedInstruments();
136 
137   /**
138    * Load all soundbank instruments into this synthesizer.
139    *
140    * @param soundbank the Soundbank from which to load instruments
141    * @return true if all instruments were loaded, false othewise
142    * @throws IllegalArgumentException if the soundbank isn't supported by this
143    */
loadAllInstruments(Soundbank soundbank)144   public boolean loadAllInstruments(Soundbank soundbank);
145 
146   /**
147    * Unload all soundbank instruments from this synthesizer.
148    *
149    * @param soundbank the Soundbank containing the instruments to unload
150    * @throws IllegalArgumentException if the soundbank isn't supported by this
151    */
unloadAllInstruments(Soundbank soundbank)152   public void unloadAllInstruments(Soundbank soundbank);
153 
154   /**
155    * Load a subset of soundbank instruments into this synthesizer.  The
156    * subset is defined by an array of Patch objects.
157    *
158    * @param soundbank the Soundbank from which to load instruments
159    * @param patchList the array of patches identifying instruments to load
160    * @return true if instruments were loaded, false otherwise
161    * @throws IllegalArgumentException if the soundbank isn't supported by this
162    */
loadInstruments(Soundbank soundbank, Patch[] patchList)163   public boolean loadInstruments(Soundbank soundbank, Patch[] patchList);
164 
165   /**
166    * Unload a subset of soundbank instruments from this synthesizer.
167    *
168    * @param soundbank the Soundbank containing the instruments to unload
169    * @param patchList the array of patches identifying instruments to unload
170    * @throws IllegalArgumentException if the soundbank isn't supported by this
171    */
unloadInstruments(Soundbank soundbank, Patch[] patchList)172   public void unloadInstruments(Soundbank soundbank, Patch[] patchList);
173 }
174