static inline int next_stage(int v){	int stage, ch, eg_stage;	int32 offset, val;	FLOAT_T rate;	Voice *vp = &voice[v];	stage = vp->envelope_stage++;	offset = vp->sample->envelope_offset[stage];	rate = vp->sample->envelope_rate[stage];	if (vp->envelope_volume == offset			|| (stage > EG_GUS_SUSTAIN && vp->envelope_volume < offset))		return recompute_envelope(v);	ch = vp->channel;	/* there is some difference between GUS patch and Soundfont at envelope. */	eg_stage = get_eg_stage(v, stage);	/* envelope generator (see also playmidi.[ch]) */	if (ISDRUMCHANNEL(ch))		val = (channel[ch].drums[vp->note] != NULL)				? channel[ch].drums[vp->note]->drum_envelope_rate[eg_stage]				: -1;	else {//		ctl->cmsg(CMSG_INFO,VERB_NOISY,"keyf: %ld", vp->sample->envelope_keyf[stage]);		if (vp->sample->envelope_keyf[stage])	/* envelope key-follow */			rate *= pow(2.0, (double) (voice[v].note - 60)					* (double)vp->sample->envelope_keyf[stage] / 1200.0f);		val = channel[ch].envelope_rate[eg_stage];	}	if (vp->sample->envelope_velf[stage])	/* envelope velocity-follow */		rate *= pow(2.0, (double) (voice[v].velocity - vp->sample->envelope_velf_bpo)				* (double)vp->sample->envelope_velf[stage] / 1200.0f);	/* just before release-phase, some modifications are necessary */	if (stage > EG_GUS_SUSTAIN) {		/* adjusting release-rate for consistent release-time */		rate *= (double) vp->envelope_volume				/ vp->sample->envelope_offset[EG_GUS_ATTACK];		/* calculating current envelope scale and a inverted value for optimization */		vp->envelope_scale = vp->last_envelope_volume;		vp->inv_envelope_scale			= TIM_FSCALE(OFFSET_MAX	/ (double)vp->envelope_volume, 16);	}	/* regularizing envelope */	if (offset < vp->envelope_volume) {	/* decaying phase */		if (val != -1) {			if(eg_stage > EG_DECAY) {				rate *= sc_eg_release_table[val & 0x7f];			} else {				rate *= sc_eg_decay_table[val & 0x7f];			}		}		if(stage < EG_SF_DECAY && rate > OFFSET_MAX) {	/* instantaneous decay */			vp->envelope_volume = offset;			return recompute_envelope(v);		} else if(rate > vp->envelope_volume - offset) {	/* fastest decay */			rate = -vp->envelope_volume + offset - 1;		} else if (rate < 1) {	/* slowest decay */			rate = -1;		}		else {	/* ordinary decay */			rate = -rate;		}	} else {	/* attacking phase */		if (val != -1)			rate *= sc_eg_attack_table[val & 0x7f];		if(stage < EG_SF_DECAY && rate > OFFSET_MAX) {	/* instantaneous attack */			vp->envelope_volume = offset;			return recompute_envelope(v);		} else if(rate > offset - vp->envelope_volume) {	/* fastest attack */			rate = offset - vp->envelope_volume + 1;		} else if (rate < 1) {rate =  1;}	/* slowest attack */	}	vp->envelope_increment = (int32)rate;	vp->envelope_target = offset;	return 0;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/ed69ed31b6cedd8b2afd20d5b452016556b78c12/mix.c/clean/timidity/mix.c