rate = -0x3fffffff * (double) control_ratio * 1000 / (sustain_time * play_mode->rate);  if (vp->sample->inst_type == INST_SF2) { /* Soundfonts don't have sustain-rate */ vp->modenv_increment = rate; } else { vp->modenv_increment = -vp->sample->modenv_rate[EG_GUS_SUSTAIN]; /* use the slower of the two rates */ if (vp->modenv_increment < rate) vp->modenv_increment = rate; } if (! vp->modenv_increment) /* Avoid freezing */ vp->modenv_increment = -1; vp->modenv_target = 0; /* it's not decaying, so freeze it */ } else { /* tiny value to make other functions happy, freeze note */ vp->modenv_increment = 1; /* this will cause update_envelope(v) to undo the +1 inc. */ vp->modenv_target = vp->modenv_volume; 
modenv_width = sustain_time * play_mode->rate / (1000.0f * (double)control_ratio);  vp->modenv_increment = -1; vp->modenv_target = vp->modenv_volume - modenv_width; if (vp->modenv_target < 0) {vp->modenv_target = 0;} 
int recompute_modulation_envelope(int v){	int stage, ch;	int32 rate;	double sustain_time;	Voice *vp = &voice[v];	if(!opt_modulation_envelope) {return 0;}	stage = vp->modenv_stage;	if (stage > EG_GUS_RELEASE3) {return 1;}	else if (stage > EG_GUS_SUSTAIN && vp->modenv_volume <= 0) {		return 1;	}	if (stage == EG_GUS_RELEASE1 && 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->modenv_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 modenv_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);			if (vp->sample->inst_type == INST_SF2) {				/* Soundfonts don't have sustain-rate */				vp->modenv_increment = rate;			} else {				vp->modenv_increment = -vp->sample->modenv_rate[EG_GUS_SUSTAIN];				/* use the slower of the two rates */				if (vp->modenv_increment < rate)					vp->modenv_increment = rate;			}			if (! vp->modenv_increment)				/* Avoid freezing */				vp->modenv_increment = -1;			vp->modenv_target = 0;		/* it's not decaying, so freeze it */		} else {			/* tiny value to make other functions happy, freeze note */			vp->modenv_increment = 1;			/* this will cause update_envelope(v) to undo the +1 inc. */			vp->modenv_target = vp->modenv_volume;		}		return 0;	}	return modenv_next_stage(v);}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/be40b80e039694c95b8472c2b8737270f5b1af41/mix.c/buggy/timidity/mix.c