1. /*
  2. * @(#)Soundbank.java 1.22 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sound.midi;
  8. import java.net.URL;
  9. /**
  10. * A <code>Soundbank</code> contains a set of <code>Instruments</code>
  11. * that can be loaded into a <code>Synthesizer</code>.
  12. * Note that a Java Sound <code>Soundbank</code> is different from a MIDI bank.
  13. * MIDI permits up to 16383 banks, each containing up to 128 instruments
  14. * (also sometimes called programs, patches, or timbres).
  15. * However, a <code>Soundbank</code> can contain 16383 times 128 instruments,
  16. * because the instruments within a <code>Soundbank</code> are indexed by both
  17. * a MIDI program number and a MIDI bank number (via a <code>Patch</code>
  18. * object). Thus, a <code>Soundbank</code> can be thought of as a collection
  19. * of MIDI banks.
  20. * <p>
  21. * <code>Soundbank</code> includes methods that return <code>String</code>
  22. * objects containing the sound bank's name, manufacturer, version number, and
  23. * description. The precise content and format of these strings is left
  24. * to the implementor.
  25. * <p>
  26. * Different synthesizers use a variety of synthesis techniques. A common
  27. * one is wavetable synthesis, in which a segment of recorded sound is
  28. * played back, often with looping and pitch change. The Downloadable Sound
  29. * (DLS) format uses segments of recorded sound, as does the Headspace Engine.
  30. * <code>Soundbanks</code> and <code>Instruments</code> that are based on
  31. * wavetable synthesis (or other uses of stored sound recordings) should
  32. * typically implement the <code>getResources()</code>
  33. * method to provide access to these recorded segments. This is optional,
  34. * however; the method can return an zero-length array if the synthesis technique
  35. * doesn't use sampled sound (FM synthesis and physical modeling are examples
  36. * of such techniques), or if it does but the implementor chooses not to make the
  37. * samples accessible.
  38. *
  39. * @see Synthesizer#getDefaultSoundbank
  40. * @see Synthesizer#isSoundbankSupported
  41. * @see Synthesizer#loadInstruments(Soundbank, Patch[])
  42. * @see Patch
  43. * @see Instrument
  44. * @see SoundbankResource
  45. *
  46. * @version 1.22, 03/01/23
  47. * @author David Rivas
  48. * @author Kara Kytle
  49. */
  50. public interface Soundbank {
  51. /**
  52. * Obtains the name of the sound bank.
  53. * @return a <code>String</code> naming the sound bank
  54. */
  55. public String getName();
  56. /**
  57. * Obtains the version string for the sound bank.
  58. * @return a <code>String</code> that indicates the sound bank's version
  59. */
  60. public String getVersion();
  61. /**
  62. * Obtains a <code>string</code> naming the company that provides the
  63. * sound bank
  64. * @return the vendor string
  65. */
  66. public String getVendor();
  67. /**
  68. * Obtains a textual description of the sound bank, suitable for display.
  69. * @return a <code>String</code> that describes the sound bank
  70. */
  71. public String getDescription();
  72. /**
  73. * Extracts a list of non-Instrument resources contained in the sound bank.
  74. * @return an array of resources, exclusing instruments. If the sound bank contains
  75. * no resources (other than instruments), returns an array of length 0.
  76. */
  77. public SoundbankResource[] getResources();
  78. /**
  79. * Obtains a list of instruments contained in this sound bank.
  80. * @return an array of the <code>Instruments</code> in this
  81. * <code>SoundBank</code>
  82. * If the sound bank contains no instruments, returns an array of length 0.
  83. *
  84. * @see Synthesizer#getLoadedInstruments
  85. * @see #getInstrument(Patch)
  86. */
  87. public Instrument[] getInstruments();
  88. /**
  89. * Obtains an <code>Instrument</code> from the given <code>Patch</code>.
  90. * @param patch a <code>Patch</code> object specifying the bank index
  91. * and program change number
  92. * @return the requested instrument, or <code>null</code> if the
  93. * sound bank doesn't contain that instrument
  94. *
  95. * @see #getInstruments
  96. * @see Synthesizer#loadInstruments(Soundbank, Patch[])
  97. */
  98. public Instrument getInstrument(Patch patch);
  99. // OLD
  100. /**
  101. * Obtains the names of all samples contained in the sound bank.
  102. * @return sample names or identifiers.
  103. * If the sound bank contains no samples, returns an array with length 0.
  104. */
  105. //public String[] getSampleNames();
  106. /**
  107. * Extracts a sample contained in the sound bank.
  108. * @param name name identifying the sample to be extracted.
  109. * @throws IllegalArgumentException thrown if the requested sample does
  110. * not exist in the soundbank.
  111. * @return requested sample, or null if the sample could not be obtained from
  112. * the sound bank.
  113. */
  114. //public AudioInputStream getSample(String name);
  115. /**
  116. * Indicates that the sound bank is of type DLS.
  117. */
  118. //public static final String DLS = "DLS";
  119. /**
  120. * Indicates that the sound bank is of type HSB.
  121. */
  122. //public static final String HSB = "HSB";
  123. /**
  124. * Obtains the sound bank type.
  125. * @return Sound bank type.
  126. * @see BankType#DLS
  127. * @see BankType#HSB
  128. */
  129. //public BankType getType();
  130. /**
  131. * Obtains a URL representing the default location of the sound bank,
  132. * or a location where more information may be available.
  133. * @return Locator for this sound bank, or <code>null</code> if the sound
  134. * bank does not have a locator.
  135. * <p>
  136. */
  137. //public URL getLocator();
  138. /**
  139. * Obtains the names of all sequences contained in the sound bank.
  140. * @return sequence names or identifiers.
  141. * If the sound bank contains no sequences, returns an array with length 0.
  142. */
  143. //public String[] getSequenceNames();
  144. /**
  145. * Extracts a sequence contained in the sound bank.
  146. * @param name name identifying the sequence to be extracted.
  147. * @throws IllegalArgumentException thrown if the requested sequence does
  148. * not exist in the soundbank.
  149. * @return requested sequence, or null if the sequence could not be obtained from
  150. * the sound bank.
  151. */
  152. //public Sequence getSequence(String name);
  153. /**
  154. * Obtains a URL representing the default location of the sound bank,
  155. * or a location where more information may be available.
  156. * @return Locator for this sound bank, or <code>null</code> if the sound
  157. * bank does not have a locator.
  158. * <p>
  159. */
  160. //public URL getLocator();
  161. /**
  162. * Obtains the names of all sequences contained in the sound bank.
  163. * @return sequence names or identifiers.
  164. * If the sound bank contains no sequences, returns an array with length 0.
  165. */
  166. //public String[] getSequenceNames();
  167. /**
  168. * Extracts a sequence contained in the sound bank.
  169. * @param name name identifying the sequence to be extracted.
  170. * @throws IllegalArgumentException thrown if the requested sequence does
  171. * not exist in the soundbank.
  172. * @return requested sequence, or null if the sequence could not be obtained from
  173. * the sound bank.
  174. */
  175. //public Sequence getSequence(String name);
  176. /**
  177. * Represents MIDI soundbank types.
  178. */
  179. /*
  180. public static class BankType {
  181. */
  182. /**
  183. * Bank type name.
  184. */
  185. // private String name;
  186. /**
  187. * Constructs a bank type.
  188. * @param name name of the bank type
  189. */
  190. /*
  191. protected BankType(String name) {
  192. this.name = name;
  193. }
  194. */
  195. /**
  196. * Determines whether two objects are equal.
  197. * Returns true if the objects are identical.
  198. * @param obj the reference object with which to compare
  199. * @return true if this object is the same as the obj argument; false otherwise
  200. */
  201. /*
  202. public final boolean equals(Object obj) {
  203. return super.equals(obj);
  204. }
  205. */
  206. /**
  207. * Finalizes the hashcode method.
  208. */
  209. /*
  210. public final int hashCode() {
  211. return super.hashCode();
  212. }
  213. */
  214. /**
  215. * Provides the element type name as the String representation of the type.
  216. * @return type name
  217. */
  218. /*
  219. public final String toString() {
  220. return name;
  221. }
  222. */
  223. /**
  224. * DLS bank type
  225. */
  226. // public static final BankType DLS = new BankType("DLS");
  227. /**
  228. * HSB bank type.
  229. */
  230. // public static final BankType HSB = new BankType("HSB");
  231. /*
  232. } // class BankType
  233. */
  234. }