if ((st = sp->scale_tuning) != 100) { ratio = pow(2.0, (note - 60) * (st - 100) / 1200.0); ft = f * ratio + 0.5, fst = fs * ratio + 0.5; } else ft = f, fst = fs;
if ((st = sp->scale_tuning) != 100) {	 ratio = (double)st / 100.0f; ft = sp->root_freq + ((f - sp->root_freq) * ratio + 0.5), fst = sp->root_freq + ((fs - sp->root_freq) * ratio + 0.5); } else {ft = f, fst = fs;} if(channel[ch].drums[keynote] != NULL && channel[ch].drums[keynote]->play_note != -1) { ratio = (double)freq_table[channel[ch].drums[keynote]->play_note] / (double)sp->root_freq; ft = ft * ratio + 0.5, fst = fst * ratio + 0.5; }
static int select_play_sample(Sample *splist,		int nsp, int note, int *vlist, MidiEvent *e){	int32 f, fs, ft, fst, fc, cdiff, diff;	int8 tt = channel[e->channel].temper_type;	uint8 tp = channel[e->channel].rpnmap[RPN_ADDR_0003];	Sample *sp, *spc;	int16 st;	double ratio;	int i, j, nv, vel;		if (opt_pure_intonation) {		if (current_keysig < 8)			f = freq_table_pureint[current_freq_table][note];		else			f = freq_table_pureint[current_freq_table + 12][note];	} else if (opt_temper_control)		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;		}	else		f = freq_table[note];	if (opt_temper_control)		fs = (tt) ? freq_table[note] : freq_table_tuning[tp][note];	else		fs = freq_table[note];	vel = e->b;	nv = 0;	for (i = 0, sp = splist; i < nsp; i++, sp++) {		/* SF2 - Scale Tuning */		if ((st = sp->scale_tuning) != 100) {			ratio = pow(2.0, (note - 60) * (st - 100) / 1200.0);			ft = f * ratio + 0.5, fst = fs * ratio + 0.5;		} else			ft = f, fst = fs;		if (sp->low_freq <= fst && sp->high_freq >= fst				&& sp->low_vel <= vel && sp->high_vel >= vel) {			j = vlist[nv] = find_voice(e);			voice[j].orig_frequency = ft;			MYCHECK(voice[j].orig_frequency);			voice[j].sample = sp;			voice[j].status = VOICE_ON;			nv++;		}	}	if (nv == 0) {		cdiff = 0x7fffffff;		for (i = 0, sp = splist; i < nsp; i++, sp++) {			/* SF2 - Scale Tuning */			if ((st = sp->scale_tuning) != 100) {				ratio = pow(2.0, (note - 60) * (st - 100) / 1200.0);				ft = f * ratio + 0.5, fst = fs * ratio + 0.5;			} else				ft = f, fst = fs;			diff = abs(sp->root_freq - fst);			if (diff < cdiff) {				fc = ft;				spc = sp;				cdiff = diff;			}		}		j = vlist[nv] = find_voice(e);		voice[j].orig_frequency = fc;		MYCHECK(voice[j].orig_frequency);		voice[j].sample = spc;		voice[j].status = VOICE_ON;		nv++;	}	return nv;}