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