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:
-
ModelInstrument, each instrument contains 1 or more performers.
-
ModelPerformer, each performer contains 1 oscillator and connections blocks.
-
ModelOscillator, are used to generate sound.
- ModelWavetable, is a oscillator that uses wavetable.
- ModelByteBufferWavetable, is the default wavetable oscillator.
- ModelByteBuffer, is a pointer to wavetable sample data.
ModelConnectionBlock, are for control routing (e.g. connect velocity to output gain).
-
ModelSource, are used to describe synthesizer source.
- ModelDestination, are used to describe synthesizer destinations.
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 file) throws 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.