protected double generateAmplitude(double time, double amplitude) {
	double amp = amplitude;
	if (time < this.attackTime) {
	    //the rate of growth of amplitude per sample
	    double deltaAmp = this.amplitude/(getSampleRate()*this.attackTime);
	    return amplitude + deltaAmp;
	} else if (time < this.attackTime + decayTime) {
	    double a = amplitude - this.sustainAmplitude;
	    //when amplitude =.0001*A[max value of 1] 127*A=0;
	    double k = Math.log(.001) / (this.decayTime*getSampleRate());
	    if(DEBUG && time < .26)
		System.out.println(k+" "+a+" "+decayTime+" "+Math.log(.001));
	    return amplitude + k*a;
	} else if (time < this.attackTime + this.decayTime + this.sustainTime) {
	    return amplitude;
	} else {
	    //when amplitude =.0001*A[max value of 1] 127*A=0;
	    double k = Math.log(.001) / (this.releaseTime * getSampleRate());
	    return amplitude + k*amplitude;
	}
    }