0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sound.midi;
0N/A
0N/A/**
0N/A * A <code>SoundbankResource</code> represents any audio resource stored
0N/A * in a <code>{@link Soundbank}</code>. Common soundbank resources include:
0N/A * <ul>
0N/A * <li>Instruments. An instrument may be specified in a variety of
0N/A * ways. However, all soundbanks have some mechanism for defining
0N/A * instruments. In doing so, they may reference other resources
0N/A * stored in the soundbank. Each instrument has a <code>Patch</code>
0N/A * which specifies the MIDI program and bank by which it may be
0N/A * referenced in MIDI messages. Instrument information may be
0N/A * stored in <code>{@link Instrument}</code> objects.
0N/A * <li>Audio samples. A sample typically is a sampled audio waveform
0N/A * which contains a short sound recording whose duration is a fraction of
0N/A * a second, or at most a few seconds. These audio samples may be
0N/A * used by a <code>{@link Synthesizer}</code> to synthesize sound in response to MIDI
0N/A * commands, or extracted for use by an application.
0N/A * (The terminology reflects musicians' use of the word "sample" to refer
0N/A * collectively to a series of contiguous audio samples or frames, rather than
0N/A * to a single, instantaneous sample.)
0N/A * The data class for an audio sample will be an object
0N/A * that encapsulates the audio sample data itself and information
0N/A * about how to interpret it (the format of the audio data), such
0N/A * as an <code>{@link javax.sound.sampled.AudioInputStream}</code>. </li>
0N/A * <li>Embedded sequences. A sound bank may contain built-in
0N/A * song data stored in a data object such as a <code>{@link Sequence}</code>.
0N/A * </ul>
0N/A * <p>
0N/A * Synthesizers that use wavetable synthesis or related
0N/A * techniques play back the audio in a sample when
0N/A * synthesizing notes, often when emulating the real-world instrument that
0N/A * was originally recorded. However, there is not necessarily a one-to-one
0N/A * correspondence between the <code>Instruments</code> and samples
0N/A * in a <code>Soundbank</code>. A single <code>Instrument</code> can use
0N/A * multiple SoundbankResources (typically for notes of dissimilar pitch or
0N/A * brightness). Also, more than one <code>Instrument</code> can use the same
0N/A * sample.
0N/A *
0N/A * @author Kara Kytle
0N/A */
0N/A
0N/Apublic abstract class SoundbankResource {
0N/A
0N/A
0N/A /**
0N/A * The sound bank that contains the <code>SoundbankResources</code>
0N/A */
0N/A private final Soundbank soundBank;
0N/A
0N/A
0N/A /**
0N/A * The name of the <code>SoundbankResource</code>
0N/A */
0N/A private final String name;
0N/A
0N/A
0N/A /**
0N/A * The class used to represent the sample's data.
0N/A */
0N/A private final Class dataClass;
0N/A
0N/A
0N/A /**
0N/A * The wavetable index.
0N/A */
0N/A //private final int index;
0N/A
0N/A
0N/A /**
0N/A * Constructs a new <code>SoundbankResource</code> from the given sound bank
0N/A * and wavetable index. (Setting the <code>SoundbankResource's</code> name,
0N/A * sampled audio data, and instruments is a subclass responsibility.)
0N/A * @param soundBank the sound bank containing this <code>SoundbankResource</code>
0N/A * @param name the name of the sample
0N/A * @param dataClass the class used to represent the sample's data
0N/A *
0N/A * @see #getSoundbank
0N/A * @see #getName
0N/A * @see #getDataClass
0N/A * @see #getData
0N/A */
0N/A protected SoundbankResource(Soundbank soundBank, String name, Class<?> dataClass) {
0N/A
0N/A this.soundBank = soundBank;
0N/A this.name = name;
0N/A this.dataClass = dataClass;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Obtains the sound bank that contains this <code>SoundbankResource</code>.
0N/A * @return the sound bank in which this <code>SoundbankResource</code> is stored
0N/A */
0N/A public Soundbank getSoundbank() {
0N/A return soundBank;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Obtains the name of the resource. This should generally be a string
0N/A * descriptive of the resource.
0N/A * @return the instrument's name
0N/A */
0N/A public String getName() {
0N/A return name;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Obtains the class used by this sample to represent its data.
0N/A * The object returned by <code>getData</code> will be of this
0N/A * class. If this <code>SoundbankResource</code> object does not support
0N/A * direct access to its data, returns <code>null</code>.
0N/A * @return the class used to represent the sample's data, or
0N/A * null if the data is not accessible
0N/A */
0N/A public Class<?> getDataClass() {
0N/A return dataClass;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Obtains the sampled audio that is stored in this <code>SoundbankResource</code>.
0N/A * The type of object returned depends on the implementation of the
0N/A * concrete class, and may be queried using <code>getDataClass</code>.
0N/A * @return an object containing the sampled audio data
0N/A * @see #getDataClass
0N/A */
0N/A public abstract Object getData();
0N/A
0N/A
0N/A /**
0N/A * Obtains the index of this <code>SoundbankResource</code> into the
0N/A * <code>Soundbank's</code> set of <code>SoundbankResources</code>.
0N/A * @return the wavetable index
0N/A */
0N/A //public int getIndex() {
0N/A // return index;
0N/A //}
0N/A
0N/A
0N/A /**
0N/A * Obtains a list of the instruments in the sound bank that use the
0N/A * <code>SoundbankResource</code> for sound synthesis.
0N/A * @return an array of <code>Instruments</code> that reference this
0N/A * <code>SoundbankResource</code>
0N/A *
0N/A * @see Instrument#getSamples
0N/A */
0N/A //public abstract Instrument[] getInstruments();
0N/A}