if (stage == 3 && vp->sample->modes & MODES_ENVELOPE 
if (stage == EG_GUS_RELEASE1 && vp->sample->modes & MODES_ENVELOPE 
int recompute_envelope(int v){	int stage, ch;	int32 rate;	double sustain_time;	Voice *vp = &voice[v];		stage = vp->envelope_stage;	if (stage > 5) {		voice_ran_out(v);		return 1;	} else if (stage > 2 && vp->envelope_volume <= 0) {		/* Remove silent voice in the release stage */		voice_ran_out(v);		return 1;	}	/* EAW -- Routine to decay the sustain envelope	 *	 * Disabled if !min_sustain_time or if there is no loop.	 * If calculated decay rate is larger than the regular	 *  stage 3 rate, use the stage 3 rate instead.	 * min_sustain_time is given in msec, and is the time	 *  it will take to decay a note at maximum volume.	 * 2000-3000 msec seem to be decent values to use.	 *	 * 08/24/00 changed behavior to not begin the decay until	 *  after the sample plays past it's loop start	 *	 */	if (stage == 3 && vp->sample->modes & MODES_ENVELOPE			&& vp->status & (VOICE_ON | VOICE_SUSTAINED)) {		/* Default behavior */		if (min_sustain_time <= 0)			/* Freeze envelope until note turns off */			vp->envelope_increment = 0;		else if (vp->status & VOICE_SUSTAINED				&& vp->sample->modes & MODES_LOOPING				&& vp->sample_offset - vp->sample->loop_start >= 0) {			if (min_sustain_time == 1)				/* The sustain stage is ignored. */				return next_stage(v);			ch = vp->channel;			if (channel[ch].sostenuto) {				sustain_time = min_sustain_time;			} else {				sustain_time = (double)min_sustain_time * (double)channel[ch].sustain / 127.0;			}			/* Calculate the release phase speed. */			rate = -0x3fffffff * (double) control_ratio * 1000					/ (sustain_time * play_mode->rate);						vp->envelope_increment = -vp->sample->envelope_rate[2];			/* use the slower of the two rates */			if (vp->envelope_increment < rate)				vp->envelope_increment = rate;			if (! vp->envelope_increment)				/* Avoid freezing */				vp->envelope_increment = -1;			vp->envelope_target = 0;		/* it's not decaying, so freeze it */		} else {			/* tiny value to make other functions happy, freeze note */			vp->envelope_increment = 1;			/* this will cause update_envelope(v) to undo the +1 inc. */			vp->envelope_target = vp->envelope_volume;		}		return 0;	}	return next_stage(v);}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/543c227e99565399000840723ae551202c087eae/mix.c/clean/timidity/mix.c