val = -1;
static inline int modenv_next_stage(int v){	int stage, ch;	int32 offset, val;	FLOAT_T rate;	Voice *vp = &voice[v];		stage = vp->modenv_stage++;	offset = vp->sample->modenv_offset[stage];	rate = vp->sample->modenv_rate[stage];	if (vp->modenv_volume == offset			|| (stage > 2 && vp->modenv_volume < offset))		return recompute_modulation_envelope(v);	else if(stage < 2 && rate > OFFSET_MAX) {	/* instantaneous attack */			vp->modenv_volume = offset;			return recompute_modulation_envelope(v);	}	ch = vp->channel;	/* envelope generator (see also playmidi.[ch]) */	if (ISDRUMCHANNEL(ch))		val = (channel[ch].drums[vp->note] != NULL)				? channel[ch].drums[vp->note]->drum_envelope_rate[stage]				: -1;	else {		if (vp->sample->modenv_keyf[stage])	/* envelope key-follow */			rate *= pow(2.0, (double) (voice[v].note - 60)					* (double)vp->sample->modenv_keyf[stage] / 1200.0f);		val = channel[ch].envelope_rate[stage];	}	if (vp->sample->modenv_velf[stage])		rate *= pow(2.0, (double) (voice[v].velocity - vp->sample->modenv_velf_bpo)				* (double)vp->sample->modenv_velf[stage] / 1200.0f);	/* just before release-phase, some modifications are necessary */	if (stage > 2) {		/* adjusting release-rate for consistent release-time */		rate *= (double) vp->modenv_volume				/ vp->sample->modenv_offset[0];	}	/* regularizing envelope */	if (offset < vp->modenv_volume) {	/* decaying phase */		if (val != -1) {			if(stage > 2) {				rate *= sc_eg_release_table[val & 0x7f];			} else {				rate *= sc_eg_decay_table[val & 0x7f];			}		}		if(rate > vp->modenv_volume - offset) {	/* fastest decay */			rate = -vp->modenv_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(rate > offset - vp->modenv_volume) {	/* fastest attack */			rate = offset - vp->modenv_volume + 1;		} else if (rate < 1) {rate = 1;}	/* slowest attack */	}		vp->modenv_increment = (int32)rate;	vp->modenv_target = offset;	return 0;}