vp->orig_vibrato_control_ratio = (int)((double)(play_mode->rate) / (5.0 * 2 * VIBRATO_SAMPLE_INCREMENTS) * channel[ch].vibrato_ratio);
vp->orig_vibrato_control_ratio = (int)(cnv_Hz_to_vib_ratio(5.0) * channel[ch].vibrato_ratio);
void recompute_freq(int v){	int i;	int ch = voice[v].channel;	int note = voice[v].note;	int32 tuning = 0;	int8 st = channel[ch].scale_tuning[note % 12];	int8 tt = channel[ch].temper_type;	uint8 tp = channel[ch].rpnmap[RPN_ADDR_0003];	int32 f;	int pb = channel[ch].pitchbend;	int32 tmp;	FLOAT_T pf, root_freq;	int32 a;	Voice *vp = &(voice[v]);	if (! voice[v].sample->sample_rate)		return;	if (! opt_modulation_wheel)		channel[ch].mod.val = 0;	if (! opt_portamento)		voice[v].porta_control_ratio = 0;	voice[v].vibrato_control_ratio = voice[v].orig_vibrato_control_ratio;	if (voice[v].vibrato_control_ratio || channel[ch].mod.val > 0) {		/* This instrument has vibrato. Invalidate any precomputed		 * sample_increments.		 */		/* MIDI controllers LFO pitch depth */		if (opt_channel_pressure || opt_modulation_wheel) {			if (vp->sample->vibrato_depth < 0) {				vp->vibrato_depth = vp->sample->vibrato_depth - channel[ch].vibrato_depth;				vp->vibrato_depth -= get_midi_controller_pitch_depth(&(channel[ch].mod))					+ get_midi_controller_pitch_depth(&(channel[ch].bend))					+ get_midi_controller_pitch_depth(&(channel[ch].caf))					+ get_midi_controller_pitch_depth(&(channel[ch].paf))					+ get_midi_controller_pitch_depth(&(channel[ch].cc1))					+ get_midi_controller_pitch_depth(&(channel[ch].cc2));				if (vp->vibrato_depth < -VIBRATO_DEPTH_MAX) {vp->vibrato_depth = -VIBRATO_DEPTH_MAX;}			} else {				vp->vibrato_depth = vp->sample->vibrato_depth + channel[ch].vibrato_depth;				vp->vibrato_depth += get_midi_controller_pitch_depth(&(channel[ch].mod))					+ get_midi_controller_pitch_depth(&(channel[ch].bend))					+ get_midi_controller_pitch_depth(&(channel[ch].caf))					+ get_midi_controller_pitch_depth(&(channel[ch].paf))					+ get_midi_controller_pitch_depth(&(channel[ch].cc1))					+ get_midi_controller_pitch_depth(&(channel[ch].cc2));				if (vp->vibrato_depth > VIBRATO_DEPTH_MAX) {vp->vibrato_depth = VIBRATO_DEPTH_MAX;}			}		}				/* fill parameters for modulation wheel */		if (channel[ch].mod.val > 0) {			if(vp->vibrato_control_ratio == 0) {				vp->vibrato_control_ratio = 					vp->orig_vibrato_control_ratio = (int)((double)(play_mode->rate) / (5.0 * 2 * VIBRATO_SAMPLE_INCREMENTS) * channel[ch].vibrato_ratio);			}			vp->vibrato_delay = 0;		}		for (i = 0; i < VIBRATO_SAMPLE_INCREMENTS; i++)			vp->vibrato_sample_increment[i] = 0;		vp->cache = NULL;	}	/* fine: [0..128] => [-256..256]	 * 1 coarse = 256 fine (= 1 note)	 * 1 fine = 2^5 tuning	 */	tuning = (channel[ch].rpnmap[RPN_ADDR_0001] - 0x40			+ (channel[ch].rpnmap[RPN_ADDR_0002] - 0x40) * 64) << 7;	/* for NRPN Coarse Pitch of Drum (GS) & Fine Pitch of Drum (XG) */	if (ISDRUMCHANNEL(ch) && channel[ch].drums[note] != NULL			&& (channel[ch].drums[note]->fine			|| channel[ch].drums[note]->coarse)) {		tuning += (channel[ch].drums[note]->fine				+ channel[ch].drums[note]->coarse * 64) << 7;	}	/* MIDI controllers pitch control */	if (opt_channel_pressure) {		tuning += get_midi_controller_pitch(&(channel[ch].mod))			+ get_midi_controller_pitch(&(channel[ch].bend))			+ get_midi_controller_pitch(&(channel[ch].caf))			+ get_midi_controller_pitch(&(channel[ch].paf))			+ get_midi_controller_pitch(&(channel[ch].cc1))			+ get_midi_controller_pitch(&(channel[ch].cc2));	}	if (opt_modulation_envelope) {		if (voice[v].sample->tremolo_to_pitch) {			tuning += lookup_triangular(voice[v].tremolo_phase >> RATE_SHIFT)					* (voice[v].sample->tremolo_to_pitch << 13) / 100.0 + 0.5;			channel[ch].pitchfactor = 0;		}		if (voice[v].sample->modenv_to_pitch) {			tuning += voice[v].last_modenv_volume					* (voice[v].sample->modenv_to_pitch << 13) / 100.0 + 0.5;			channel[ch].pitchfactor = 0;		}	}	/* GS/XG - Scale Tuning */	if (! ISDRUMCHANNEL(ch)) {		tuning += (st << 13) / 100.0 + 0.5;		if (st != channel[ch].prev_scale_tuning) {			channel[ch].pitchfactor = 0;			channel[ch].prev_scale_tuning = st;		}	}	if (! opt_pure_intonation			&& opt_temper_control && voice[v].temper_instant) {		switch (tt) {		case 0:			f = freq_table_tuning[tp][note];			break;		case 1:			if (current_temper_keysig < 8)				f = freq_table_pytha[current_freq_table][note];			else				f = freq_table_pytha[current_freq_table + 12][note];			break;		case 2:			if (current_temper_keysig < 8)				f = freq_table_meantone[current_freq_table						+ ((temper_adj) ? 36 : 0)][note];			else				f = freq_table_meantone[current_freq_table						+ ((temper_adj) ? 24 : 12)][note];			break;		case 3:			if (current_temper_keysig < 8)				f = freq_table_pureint[current_freq_table						+ ((temper_adj) ? 36 : 0)][note];			else				f = freq_table_pureint[current_freq_table						+ ((temper_adj) ? 24 : 12)][note];			break;		default:	/* user-defined temperaments */			if ((tt -= 0x40) >= 0 && tt < 4) {				if (current_temper_keysig < 8)					f = freq_table_user[tt][current_freq_table							+ ((temper_adj) ? 36 : 0)][note];				else					f = freq_table_user[tt][current_freq_table							+ ((temper_adj) ? 24 : 12)][note];			} else				f = freq_table[note];			break;		}		voice[v].orig_frequency = f;	}	if (! voice[v].porta_control_ratio) {		if (tuning == 0 && pb == 0x2000)			voice[v].frequency = voice[v].orig_frequency;		else {			pb -= 0x2000;			if (! channel[ch].pitchfactor) {				/* Damn.  Somebody bent the pitch. */				tmp = pb * channel[ch].rpnmap[RPN_ADDR_0000] + tuning;				if (tmp >= 0)					channel[ch].pitchfactor = bend_fine[tmp >> 5 & 0xff]							* bend_coarse[tmp >> 13 & 0x7f];				else					channel[ch].pitchfactor = 1.0 /							(bend_fine[-tmp >> 5 & 0xff]							* bend_coarse[-tmp >> 13 & 0x7f]);			}			voice[v].frequency =					voice[v].orig_frequency * channel[ch].pitchfactor;			if (voice[v].frequency != voice[v].orig_frequency)				voice[v].cache = NULL;		}	} else {	/* Portamento */		pb -= 0x2000;		tmp = pb * channel[ch].rpnmap[RPN_ADDR_0000]				+ (voice[v].porta_pb << 5) + tuning;		if (tmp >= 0)			pf = bend_fine[tmp >> 5 & 0xff]					* bend_coarse[tmp >> 13 & 0x7f];		else			pf = 1.0 / (bend_fine[-tmp >> 5 & 0xff]					* bend_coarse[-tmp >> 13 & 0x7f]);		voice[v].frequency = voice[v].orig_frequency * pf;		voice[v].cache = NULL;	}	root_freq = voice[v].sample->root_freq;	a = TIM_FSCALE(((double) voice[v].sample->sample_rate			* ((double)voice[v].frequency + channel[ch].pitch_offset_fine))			/ (root_freq * play_mode->rate), FRACTION_BITS) + 0.5;	/* need to preserve the loop direction */	voice[v].sample_increment = (voice[v].sample_increment >= 0) ? a : -a;#ifdef ABORT_AT_FATAL	if (voice[v].sample_increment == 0) {		fprintf(stderr, "Invalid sample increment a=%e %ld %ld %ld %ld%s\n",				(double)a, (long) voice[v].sample->sample_rate,				(long) voice[v].frequency, (long) voice[v].sample->root_freq,				(long) play_mode->rate, (voice[v].cache) ? " (Cached)" : "");		abort();	}#endif	/* ABORT_AT_FATAL */}