API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.sound.midi. Synthesizer View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

/*
 * @(#)Synthesizer.java	1.29 06/04/05
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.sound.midi;		  	 

import javax.sound.sampled.Control;


/**
 * A <code>Synthesizer</code> generates sound.  This usually happens when one of 
 * the <code>Synthesizer</code>'s {@link MidiChannel} objects receives a 
 * {@link MidiChannel#noteOn(int, int) noteOn} message, either
 * directly or via the <code>Synthesizer</code> object.
 * Many <code>Synthesizer</code>s support <code>Receivers</code>, through which
 * MIDI events can be delivered to the <code>Synthesizer</code>.  
 * In such cases, the <code>Synthesizer</code> typically responds by sending
 * a corresponding message to the appropriate <code>MidiChannel</code>, or by
 * processing the event itself if the event isn't one of the MIDI channel 
 * messages.
 * <p>
 * The <code>Synthesizer</code> interface includes methods for loading and 
 * unloading instruments from soundbanks.  An instrument is a specification for synthesizing a
 * certain type of sound, whether that sound emulates a traditional instrument or is
 * some kind of sound effect or other imaginary sound. A soundbank is a collection of instruments, organized
 * by bank and program number (via the instrument's <code>Patch</code> object).  
 * Different <code>Synthesizer</code> classes might implement different sound-synthesis
 * techniques, meaning that some instruments and not others might be compatible with a
 * given synthesizer.
 * Also, synthesizers may have a limited amount of memory for instruments, meaning
 * that not every soundbank and instrument can be used by every synthesizer, even if
 * the synthesis technique is compatible.
 * To see whether the instruments from 
 * a certain soundbank can be played by a given synthesizer, invoke the
 * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} method of 
 * <code>Synthesizer</code>.
 * <p>
 * "Loading" an instrument means that that instrument becomes available for 
 * synthesizing notes.  The instrument is loaded into the bank and 
 * program location specified by its <code>Patch</code> object.  Loading does
 * not necessarily mean that subsequently played notes will immediately have 
 * the sound of this newly loaded instrument.  For the instrument to play notes, 
 * one of the synthesizer's <code>MidiChannel</code> objects must receive (or have received)
 * a program-change message that causes that particular instrument's
 * bank and program number to be selected.
 *
 * @see MidiSystem#getSynthesizer
 * @see Soundbank
 * @see Instrument
 * @see MidiChannel#programChange(int, int)
 * @see Receiver
 * @see Transmitter
 * @see MidiDevice
 *
 * @version 1.29, 06/04/05
 * @author Kara Kytle
 */
public interface Synthesizer extends MidiDevice {


    // SYNTHESIZER METHODS


    /**
     * Obtains the maximum number of notes that this synthesizer can sound simultaneously.
     * @return the maximum number of simultaneous notes
     * @see #getVoiceStatus
     */
    public int getMaxPolyphony();


    /**
     * Obtains the processing latency incurred by this synthesizer, expressed in 
     * microseconds.  This latency measures the worst-case delay between the  
     * time a MIDI message is delivered to the synthesizer and the time that the
     * synthesizer actually produces the corresponding result.
     * <p>
     * Although the latency is expressed in microseconds, a synthesizer's actual measured 
     * delay may vary over a wider range than this resolution suggests.  For example,
     * a synthesizer might have a worst-case delay of a few milliseconds or more.
     *
     * @return the worst-case delay, in microseconds
     */
    public long getLatency();	

	
    /**
     * Obtains the set of MIDI channels controlled by this synthesizer.  Each 
     * non-null element in the returned array is a <code>MidiChannel</code> that 
     * receives the MIDI messages sent on that channel number.
     * <p>
     * The MIDI 1.0 specification provides for 16 channels, so this 
     * method returns an array of at least 16 elements.  However, if this synthesizer 
     * doesn't make use of all 16 channels, some of the elements of the array
     * might be <code>null</code>, so you should check each element
     * before using it.
     * @return an array of the <code>MidiChannel</code> objects managed by this
     * <code>Synthesizer</code>.  Some of the array elements may be <code>null</code>.
     */
    public MidiChannel[] getChannels();


    /**
     * Obtains the current status of the voices produced by this synthesizer.  
     * If this class of <code>Synthesizer</code> does not provide voice 
     * information, the returned array will always be of length 0.  Otherwise,
     * its length is always equal to the total number of voices, as returned by 
     * <code>getMaxPolyphony()</code>.  (See the <code>VoiceStatus</code> class 
     * description for an explanation of synthesizer voices.)
     *
     * @return an array of <code>VoiceStatus</code> objects that supply 
     * information about the corresponding synthesizer voices
     * @see #getMaxPolyphony
     * @see VoiceStatus
     */
    public VoiceStatus[] getVoiceStatus();


    /**
     * Informs the caller whether this synthesizer is capable of loading 
     * instruments from the specified soundbank.
     * If the soundbank is unsupported, any attempts to load instruments from
     * it will result in an <code>IllegalArgumentException</code>.
     * @param soundbank soundbank for which support is queried
     * @return <code>true</code> if the soundbank is supported, otherwise <code>false</code>
     * @see #loadInstruments
     * @see #loadAllInstruments
     * @see #unloadInstruments
     * @see #unloadAllInstruments
     * @see #getDefaultSoundbank
     */
    public boolean isSoundbankSupported(Soundbank soundbank);


    /**
     * Makes a particular instrument available for synthesis.  This instrument
     * is loaded into the patch location specified by its <code>Patch</code> 
     * object, so that if a program-change message is 
     * received (or has been received) that causes that patch to be selected,
     * subsequent notes will be played using the sound of 
     * <code>instrument</code>.  If the specified instrument is already loaded,
     * this method does nothing and returns <code>true</code>.
     * <p>
     * The instrument must be part of a soundbank 
     * that this <code>Synthesizer</code> supports.  (To make sure, you can use
     * the <code>getSoundbank</code> method of <code>Instrument</code> and the 
     * <code>isSoundbankSupported</code> method of <code>Synthesizer</code>.)
     * @param instrument instrument to load
     * @return <code>true</code> if the instrument is successfully loaded (or 
     * already had been), <code>false</code> if the instrument could not be 
     * loaded (for example, if the synthesizer has insufficient
     * memory to load it)
     * @throws <code>IllegalArgumentException</code> if this 
     * <code>Synthesizer</code> doesn't support the specified instrument's 
     * soundbank 
     * @see #unloadInstrument	 
     * @see #loadInstruments	 
     * @see #loadAllInstruments	 
     * @see #remapInstrument
     * @see SoundbankResource#getSoundbank	 
     * @see MidiChannel#programChange(int, int)
     */
    public boolean loadInstrument(Instrument instrument);

	
    /**
     * Unloads a particular instrument.
     * @param instrument instrument to unload
     * @throws <code>IllegalArgumentException</code> if this 
     * <code>Synthesizer</code> doesn't support the specified instrument's 
     * soundbank 
     * @see #loadInstrument	 
     * @see #unloadInstruments	 
     * @see #unloadAllInstruments	 
     * @see #getLoadedInstruments
     * @see #remapInstrument	 
     */
    public void unloadInstrument(Instrument instrument);


    /**
     * Remaps an instrument. Instrument <code>to</code> takes the
     * place of instrument <code>from</code>.<br>
     * For example, if <code>from</code> was located at bank number 2,
     * program number 11, remapping causes that bank and program location
     * to be occupied instead by <code>to</code>.<br>
     * If the function succeeds,  instrument <code>from</code> is unloaded.
     * <p>To cancel the remapping reload instrument <code>from</code> by
     * invoking one of {@link #loadInstrument}, {@link #loadInstruments}
     * or {@link #loadAllInstruments}.
     *
     * @param from the <code>Instrument</code> object to be replaced
     * @param to the <code>Instrument</code> object to be used in place
     * of the old instrument, it should be loaded into the synthesizer
     * @return <code>true</code> if the instrument succeessfully remapped,
     * <code>false</code> if feature is not implemented by synthesizer
     * @throws <code>IllegalArgumentException</code> if instrument
     * <code>from</code> or instrument <code>to</code> aren't supported by
     * synthesizer or if instrument <code>to</code> is not loaded
     * @throws <code>NullPointerException</code> if <code>from</code> or
     * <code>to</code> parameters have null value
     * @see #loadInstrument
     * @see #loadInstruments
     * @see #loadAllInstruments
     */
    public boolean remapInstrument(Instrument from, Instrument to);	

	
    /**
     * Obtains the default soundbank for the synthesizer, if one exists.
     * (Some synthesizers provide a default or built-in soundbank.)
     * If a synthesizer doesn't have a default soundbank, instruments must
     * be loaded explicitly from an external soundbank.  
     * @return default soundbank, or <code>null</code> if one does not exist.
     * @see #isSoundbankSupported
     */
    public Soundbank getDefaultSoundbank();

	
    /**
     * Obtains a list of instruments that come with the synthesizer.  These
     * instruments might be built into the synthesizer, or they might be
     * part of a default soundbank provided with the synthesizer, etc.
     * <p>  
     * Note that you don't use this method  to find out which instruments are 
     * currently loaded onto the synthesizer; for that purpose, you use 
     * <code>getLoadedInstruments()</code>.
     * Nor does the method indicate all the instruments that can be loaded onto
     * the synthesizer; it only indicates the subset that come with the synthesizer.
     * To learn whether another instrument can be loaded, you can invoke 
     * <code>isSoundbankSupported()</code>, and if the instrument's 
     * <code>Soundbank</code> is supported, you can try loading the instrument.
     *  
     * @return list of available instruments.
     * @see #getLoadedInstruments	 
     * @see #isSoundbankSupported(Soundbank)
     * @see #loadInstrument	 
     */
    public Instrument[] getAvailableInstruments();


    /**
     * Obtains a list of the instruments that are currently loaded onto this 
     * <code>Synthesizer</code>.
     * @return a list of currently loaded instruments
     * @see #loadInstrument	 
     * @see #getAvailableInstruments	 
     * @see Soundbank#getInstruments	 
     */
    public Instrument[] getLoadedInstruments();

	
    /**
     * Loads onto the <code>Synthesizer</code> all instruments contained 
     * in the specified <code>Soundbank</code>.
     * @param soundbank the <code>Soundbank</code> whose are instruments are 
     * to be loaded
     * @return <code>true</code> if the instruments are all successfully loaded (or 
     * already had been), <code>false</code> if any instrument could not be 
     * loaded (for example, if the <code>Synthesizer</code> had insufficient memory)
     * @throws IllegalArgumentException if the requested soundbank is 
     * incompatible with this synthesizer.
     * @see #isSoundbankSupported
     * @see #loadInstrument	 
     * @see #loadInstruments	 
     */
    public boolean loadAllInstruments(Soundbank soundbank);


	
    /**
     * Unloads all instruments contained in the specified <code>Soundbank</code>.
     * @param soundbank soundbank containing instruments to unload
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
     * @see #isSoundbankSupported
     * @see #unloadInstrument	 
     * @see #unloadInstruments	 
     */
    public void unloadAllInstruments(Soundbank soundbank);

	
    /**
     * Loads the instruments referenced by the specified patches, from the 
     * specified <code>Soundbank</code>.  Each of the <code>Patch</code> objects
     * indicates a bank and program number; the <code>Instrument</code> that
     * has the matching <code>Patch</code> is loaded into that bank and program
     * location.
     * @param soundbank the <code>Soundbank</code> containing the instruments to load
     * @param patchList list of patches for which instruments should be loaded
     * @return <code>true</code> if the instruments are all successfully loaded (or 
     * already had been), <code>false</code> if any instrument could not be 
     * loaded (for example, if the <code>Synthesizer</code> had insufficient memory)
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
     * @see #isSoundbankSupported
     * @see Instrument#getPatch
     * @see #loadAllInstruments
     * @see #loadInstrument	 
     * @see Soundbank#getInstrument(Patch)
     * @see Sequence#getPatchList()
     */
    public boolean loadInstruments(Soundbank soundbank, Patch[] patchList);
	
    /**
     * Unloads the instruments referenced by the specified patches, from the MIDI sound bank specified.
     * @param soundbank soundbank containing instruments to unload
     * @param patchList list of patches for which instruments should be unloaded
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
     *
     * @see #unloadInstrument	 
     * @see #unloadAllInstruments	 
     * @see #isSoundbankSupported
     * @see Instrument#getPatch
     * @see #loadInstruments	 
     */
    public void unloadInstruments(Soundbank soundbank, Patch[] patchList);


    // RECEIVER METHODS

    /**
     * Obtains the name of the receiver.
     * @return receiver name
     */
    //	public abstract String getName();

	
    /**
     * Opens the receiver.
     * @throws MidiUnavailableException if the receiver is cannot be opened, 
     * usually because the MIDI device is in use by another application.
     * @throws SecurityException if the receiver cannot be opened due to security
     * restrictions.
     */
    //	public abstract void open() throws MidiUnavailableException, SecurityException;


    /**
     * Closes the receiver.
     */
    //	public abstract void close();


    /**
     * Sends a MIDI event to the receiver.
     * @param event event to send.
     * @throws IllegalStateException if the receiver is not open.
     */ 
    //	public void send(MidiEvent event) throws IllegalStateException {
    //
    //	}


    /**
     * Obtains the set of controls supported by the
     * element.  If no controls are supported, returns an
     * array of length 0.
     * @return set of controls
     */
    // $$kk: 03.04.99: josh bloch recommends getting rid of this: 
    // what can you really do with a set of untyped controls??	
    // $$kk: 03.05.99: i am putting this back in.  for one thing,
    // you can check the length and know whether you should keep
    // looking.... 
    // public Control[] getControls();

    /**
     * Obtains the specified control.
     * @param controlClass class of the requested control
     * @return requested control object, or null if the 
     * control is not supported.
     */
    // public Control getControl(Class controlClass);
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar