import jm.audio.Instrument; import jm.audio.io.*; import jm.audio.synth.*; import jm.music.data.Note; import jm.audio.AudioObject; /** * A basic sabersaw (exponential sawtooth) waveform * instrument implementation * which implements envelope , pan, and volume control * @author Andrew Brown */ public final class SabersawInstRT extends Instrument{ //---------------------------------------------- // Attributes //---------------------------------------------- /** The points to use in the construction of Envelopes */ private EnvPoint[] pointArray = new EnvPoint[10]; private int sampleRate, channels; //---------------------------------------------- // Constructor //---------------------------------------------- /** * Basic default constructor * @param sampleRate */ public SabersawInstRT() { this(44100); } /** * Basic default constructor * @param sampleRate */ public SabersawInstRT(int sampleRate){ this(sampleRate, 2); } /** * Basic default constructor * @param sampleRate * @param channels */ public SabersawInstRT(int sampleRate, int channels){ this.sampleRate = sampleRate; this.channels = channels; EnvPoint[] tempArray = { new EnvPoint((float)0.0, (float)0.0), new EnvPoint((float)0.02, (float)1.0), new EnvPoint((float)0.15, (float)0.6), new EnvPoint((float)0.95, (float)0.3), new EnvPoint((float)1.0, (float)0.0) }; pointArray = tempArray; } //---------------------------------------------- // Methods //---------------------------------------------- /** * Initialisation method used to build the objects that * this instrument will use */ public void createChain(){ Oscillator wt = new Oscillator(this, Oscillator.SABERSAW_WAVE, this.sampleRate, channels); Envelope env = new Envelope(wt, pointArray); Volume vol = new Volume(env); StereoPan span = new StereoPan(vol); } }