1. /*
  2. * @(#)Instrument.java 1.16 04/05/05
  3. *
  4. * Copyright 2004 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. * An instrument is a sound-synthesis algorithm with certain parameter
  11. * settings, usually designed to emulate a specific real-world
  12. * musical instrument or to achieve a specific sort of sound effect.
  13. * Instruments are typically stored in collections called soundbanks.
  14. * Before the instrument can be used to play notes, it must first be loaded
  15. * onto a synthesizer, and then it must be selected for use on
  16. * one or more channels, via a program-change command. MIDI notes
  17. * that are subsequently received on those channels will be played using
  18. * the sound of the selected instrument.
  19. *
  20. * @see Soundbank
  21. * @see Soundbank#getInstruments
  22. * @see Patch
  23. * @see Synthesizer#loadInstrument(Instrument)
  24. * @see MidiChannel#programChange(int, int)
  25. * @version 1.16, 04/05/05
  26. * @author Kara Kytle
  27. */
  28. public abstract class Instrument extends SoundbankResource {
  29. /**
  30. * Instrument patch
  31. */
  32. private final Patch patch;
  33. /**
  34. * Constructs a new MIDI instrument from the specified <code>Patch</code>.
  35. * When a subsequent request is made to load the
  36. * instrument, the sound bank will search its contents for this instrument's <code>Patch</code>,
  37. * and the instrument will be loaded into the synthesizer at the
  38. * bank and program location indicated by the <code>Patch</code> object.
  39. * @param soundbank sound bank containing the instrument
  40. * @param patch the patch of this instrument
  41. * @param name the name of this instrument
  42. * @param dataClass the class used to represent the sample's data.
  43. *
  44. * @see Synthesizer#loadInstrument(Instrument)
  45. */
  46. protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {
  47. super(soundbank, name, dataClass);
  48. this.patch = patch;
  49. }
  50. /**
  51. * Obtains the <code>Patch</code> object that indicates the bank and program
  52. * numbers where this instrument is to be stored in the synthesizer.
  53. * @return this instrument's patch
  54. */
  55. public Patch getPatch() {
  56. return patch;
  57. }
  58. }