jdk/src/share/classes/javax/sound/midi/Synthesizer.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 19207 3448b0cb4077
child 26003 d630c97424bd
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sound.midi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.sound.sampled.Control;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A <code>Synthesizer</code> generates sound.  This usually happens when one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * the <code>Synthesizer</code>'s {@link MidiChannel} objects receives a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * {@link MidiChannel#noteOn(int, int) noteOn} message, either
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * directly or via the <code>Synthesizer</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Many <code>Synthesizer</code>s support <code>Receivers</code>, through which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * MIDI events can be delivered to the <code>Synthesizer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * In such cases, the <code>Synthesizer</code> typically responds by sending
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * a corresponding message to the appropriate <code>MidiChannel</code>, or by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * processing the event itself if the event isn't one of the MIDI channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * The <code>Synthesizer</code> interface includes methods for loading and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * unloading instruments from soundbanks.  An instrument is a specification for synthesizing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * certain type of sound, whether that sound emulates a traditional instrument or is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * some kind of sound effect or other imaginary sound. A soundbank is a collection of instruments, organized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * by bank and program number (via the instrument's <code>Patch</code> object).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Different <code>Synthesizer</code> classes might implement different sound-synthesis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * techniques, meaning that some instruments and not others might be compatible with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * given synthesizer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Also, synthesizers may have a limited amount of memory for instruments, meaning
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * that not every soundbank and instrument can be used by every synthesizer, even if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * the synthesis technique is compatible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * To see whether the instruments from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * a certain soundbank can be played by a given synthesizer, invoke the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <code>Synthesizer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * "Loading" an instrument means that that instrument becomes available for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * synthesizing notes.  The instrument is loaded into the bank and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * program location specified by its <code>Patch</code> object.  Loading does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * not necessarily mean that subsequently played notes will immediately have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * the sound of this newly loaded instrument.  For the instrument to play notes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * one of the synthesizer's <code>MidiChannel</code> objects must receive (or have received)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * a program-change message that causes that particular instrument's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * bank and program number to be selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @see MidiSystem#getSynthesizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @see Soundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * @see Instrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @see MidiChannel#programChange(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @see Receiver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * @see Transmitter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * @see MidiDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @author Kara Kytle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
public interface Synthesizer extends MidiDevice {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // SYNTHESIZER METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Obtains the maximum number of notes that this synthesizer can sound simultaneously.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @return the maximum number of simultaneous notes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @see #getVoiceStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public int getMaxPolyphony();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Obtains the processing latency incurred by this synthesizer, expressed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * microseconds.  This latency measures the worst-case delay between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * time a MIDI message is delivered to the synthesizer and the time that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * synthesizer actually produces the corresponding result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Although the latency is expressed in microseconds, a synthesizer's actual measured
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * delay may vary over a wider range than this resolution suggests.  For example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * a synthesizer might have a worst-case delay of a few milliseconds or more.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return the worst-case delay, in microseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public long getLatency();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Obtains the set of MIDI channels controlled by this synthesizer.  Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * non-null element in the returned array is a <code>MidiChannel</code> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * receives the MIDI messages sent on that channel number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * The MIDI 1.0 specification provides for 16 channels, so this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * method returns an array of at least 16 elements.  However, if this synthesizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * doesn't make use of all 16 channels, some of the elements of the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * might be <code>null</code>, so you should check each element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * before using it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @return an array of the <code>MidiChannel</code> objects managed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <code>Synthesizer</code>.  Some of the array elements may be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public MidiChannel[] getChannels();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Obtains the current status of the voices produced by this synthesizer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * If this class of <code>Synthesizer</code> does not provide voice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * information, the returned array will always be of length 0.  Otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * its length is always equal to the total number of voices, as returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <code>getMaxPolyphony()</code>.  (See the <code>VoiceStatus</code> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * description for an explanation of synthesizer voices.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @return an array of <code>VoiceStatus</code> objects that supply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * information about the corresponding synthesizer voices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see #getMaxPolyphony
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @see VoiceStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public VoiceStatus[] getVoiceStatus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Informs the caller whether this synthesizer is capable of loading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * instruments from the specified soundbank.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * If the soundbank is unsupported, any attempts to load instruments from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * it will result in an <code>IllegalArgumentException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param soundbank soundbank for which support is queried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @return <code>true</code> if the soundbank is supported, otherwise <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @see #loadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @see #loadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @see #unloadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see #unloadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @see #getDefaultSoundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public boolean isSoundbankSupported(Soundbank soundbank);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Makes a particular instrument available for synthesis.  This instrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * is loaded into the patch location specified by its <code>Patch</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * object, so that if a program-change message is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * received (or has been received) that causes that patch to be selected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * subsequent notes will be played using the sound of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <code>instrument</code>.  If the specified instrument is already loaded,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * this method does nothing and returns <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * The instrument must be part of a soundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * that this <code>Synthesizer</code> supports.  (To make sure, you can use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * the <code>getSoundbank</code> method of <code>Instrument</code> and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * <code>isSoundbankSupported</code> method of <code>Synthesizer</code>.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param instrument instrument to load
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return <code>true</code> if the instrument is successfully loaded (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * already had been), <code>false</code> if the instrument could not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * loaded (for example, if the synthesizer has insufficient
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * memory to load it)
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
   173
     * @throws IllegalArgumentException if this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <code>Synthesizer</code> doesn't support the specified instrument's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * soundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @see #unloadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @see #loadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @see #loadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @see #remapInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @see SoundbankResource#getSoundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @see MidiChannel#programChange(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public boolean loadInstrument(Instrument instrument);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Unloads a particular instrument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param instrument instrument to unload
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
   189
     * @throws IllegalArgumentException if this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * <code>Synthesizer</code> doesn't support the specified instrument's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * soundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see #unloadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @see #unloadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @see #getLoadedInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @see #remapInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public void unloadInstrument(Instrument instrument);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Remaps an instrument. Instrument <code>to</code> takes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * place of instrument <code>from</code>.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * For example, if <code>from</code> was located at bank number 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * program number 11, remapping causes that bank and program location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * to be occupied instead by <code>to</code>.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * If the function succeeds,  instrument <code>from</code> is unloaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <p>To cancel the remapping reload instrument <code>from</code> by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * invoking one of {@link #loadInstrument}, {@link #loadInstruments}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * or {@link #loadAllInstruments}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param from the <code>Instrument</code> object to be replaced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @param to the <code>Instrument</code> object to be used in place
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * of the old instrument, it should be loaded into the synthesizer
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19207
diff changeset
   215
     * @return <code>true</code> if the instrument successfully remapped,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <code>false</code> if feature is not implemented by synthesizer
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
   217
     * @throws IllegalArgumentException if instrument
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <code>from</code> or instrument <code>to</code> aren't supported by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * synthesizer or if instrument <code>to</code> is not loaded
19207
3448b0cb4077 8022174: Fix doclint warnings in javax.sound
darcy
parents: 5506
diff changeset
   220
     * @throws NullPointerException if <code>from</code> or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <code>to</code> parameters have null value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @see #loadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @see #loadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public boolean remapInstrument(Instrument from, Instrument to);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * Obtains the default soundbank for the synthesizer, if one exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * (Some synthesizers provide a default or built-in soundbank.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * If a synthesizer doesn't have a default soundbank, instruments must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * be loaded explicitly from an external soundbank.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @return default soundbank, or <code>null</code> if one does not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @see #isSoundbankSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public Soundbank getDefaultSoundbank();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Obtains a list of instruments that come with the synthesizer.  These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * instruments might be built into the synthesizer, or they might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * part of a default soundbank provided with the synthesizer, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Note that you don't use this method  to find out which instruments are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * currently loaded onto the synthesizer; for that purpose, you use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * <code>getLoadedInstruments()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Nor does the method indicate all the instruments that can be loaded onto
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * the synthesizer; it only indicates the subset that come with the synthesizer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * To learn whether another instrument can be loaded, you can invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * <code>isSoundbankSupported()</code>, and if the instrument's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * <code>Soundbank</code> is supported, you can try loading the instrument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @return list of available instruments. If the synthesizer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * has no instruments coming with it, an array of length 0 is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @see #getLoadedInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @see #isSoundbankSupported(Soundbank)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public Instrument[] getAvailableInstruments();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Obtains a list of the instruments that are currently loaded onto this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * <code>Synthesizer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @return a list of currently loaded instruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @see #getAvailableInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @see Soundbank#getInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public Instrument[] getLoadedInstruments();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Loads onto the <code>Synthesizer</code> all instruments contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * in the specified <code>Soundbank</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @param soundbank the <code>Soundbank</code> whose are instruments are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * to be loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @return <code>true</code> if the instruments are all successfully loaded (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * already had been), <code>false</code> if any instrument could not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * loaded (for example, if the <code>Synthesizer</code> had insufficient memory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @throws IllegalArgumentException if the requested soundbank is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * incompatible with this synthesizer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @see #isSoundbankSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @see #loadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public boolean loadAllInstruments(Soundbank soundbank);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * Unloads all instruments contained in the specified <code>Soundbank</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @param soundbank soundbank containing instruments to unload
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @see #isSoundbankSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @see #unloadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @see #unloadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    public void unloadAllInstruments(Soundbank soundbank);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * Loads the instruments referenced by the specified patches, from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * specified <code>Soundbank</code>.  Each of the <code>Patch</code> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * indicates a bank and program number; the <code>Instrument</code> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * has the matching <code>Patch</code> is loaded into that bank and program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param soundbank the <code>Soundbank</code> containing the instruments to load
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @param patchList list of patches for which instruments should be loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @return <code>true</code> if the instruments are all successfully loaded (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * already had been), <code>false</code> if any instrument could not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * loaded (for example, if the <code>Synthesizer</code> had insufficient memory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @see #isSoundbankSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @see Instrument#getPatch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @see #loadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @see #loadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @see Soundbank#getInstrument(Patch)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @see Sequence#getPatchList()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public boolean loadInstruments(Soundbank soundbank, Patch[] patchList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Unloads the instruments referenced by the specified patches, from the MIDI sound bank specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @param soundbank soundbank containing instruments to unload
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @param patchList list of patches for which instruments should be unloaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @throws IllegalArgumentException thrown if the soundbank is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @see #unloadInstrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @see #unloadAllInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @see #isSoundbankSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @see Instrument#getPatch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @see #loadInstruments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public void unloadInstruments(Soundbank soundbank, Patch[] patchList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    // RECEIVER METHODS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Obtains the name of the receiver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @return receiver name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    //  public abstract String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * Opens the receiver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @throws MidiUnavailableException if the receiver is cannot be opened,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * usually because the MIDI device is in use by another application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @throws SecurityException if the receiver cannot be opened due to security
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * restrictions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    //  public abstract void open() throws MidiUnavailableException, SecurityException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Closes the receiver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    //  public abstract void close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Sends a MIDI event to the receiver.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @param event event to send.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @throws IllegalStateException if the receiver is not open.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    //  public void send(MidiEvent event) throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    //  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * Obtains the set of controls supported by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * element.  If no controls are supported, returns an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * array of length 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @return set of controls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    // $$kk: 03.04.99: josh bloch recommends getting rid of this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    // what can you really do with a set of untyped controls??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    // $$kk: 03.05.99: i am putting this back in.  for one thing,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    // you can check the length and know whether you should keep
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    // looking....
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    // public Control[] getControls();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Obtains the specified control.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param controlClass class of the requested control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @return requested control object, or null if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * control is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    // public Control getControl(Class controlClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
}