The Internal Instrument Model


Made of these classes:
com.sun.media.sound.Model*

Gervill has a single internal instrument model.
This provides unified way to describe how instrument are synthesized.

Soundbanks that implement this model returns instrument which extends ModelInstrument.
And those instrument must implement "getPerformers" method.

The "getPerformers" method is used to tell instruments to convert from its own format into the internal instrument model.

This is layout on model instruments:

Example

The most simple example on how the instrument model is used
can be found in the AudioFileSoundbankReader.
Here is a code snippet on how audio files used to define model instrument:

  public Soundbank getSoundbank(File filethrows InvalidMidiDataException,
      IOException {
    try {                  
      AudioInputStream ais = AudioSystem.getAudioInputStream(file);
      ais.close();
      ModelByteBufferWavetable osc = new ModelByteBufferWavetable(
        new ModelByteBuffer(file, 0, file.length()), -4800);
      ModelPerformer performer = new ModelPerformer();        
      performer.getOscillators().add(osc);
      SimpleSoundbank sbk = new SimpleSoundbank();
      SimpleInstrument ins = new SimpleInstrument();
      ins.add(performer);
      sbk.addInstrument(ins);
      return sbk;              
    catch (UnsupportedAudioFileException e1) {
      return null;
    catch (IOException e) {
      return null;
    }
  }
Java2html

In the example above we can see that the SimpleSoundbank and SimpleInstrument
are used to define soundbank and instrument structures.
SimpleSoundbank can also be used to contain instrument from other
soundbanks which implement the internal instrument model.