if(opt_pan_delay) {
if(opt_pan_delay && channel[ch].insertion_effect == 0) {
static void start_note(MidiEvent *e, int i, int vid, int cnt){  int j, ch, note, pan;#ifdef ENABLE_PAN_DELAY  double pan_delay_diff;  #endif  ch = e->channel;  note = MIDI_EVENT_NOTE(e);  voice[i].status = VOICE_ON;  voice[i].channel = ch;  voice[i].note = note;  voice[i].velocity = e->b;  voice[i].chorus_link = i;	/* No link */  voice[i].proximate_flag = 1;  j = channel[ch].special_sample;  if(j == 0 || special_patch[j] == NULL)      voice[i].sample_offset = 0;  else  {      voice[i].sample_offset =	  special_patch[j]->sample_offset << FRACTION_BITS;      if(voice[i].sample->modes & MODES_LOOPING)      {	  if(voice[i].sample_offset > voice[i].sample->loop_end)	      voice[i].sample_offset = voice[i].sample->loop_start;      }      else if(voice[i].sample_offset > voice[i].sample->data_length)      {	  free_voice(i);	  return;      }  }  voice[i].sample_increment=0; /* make sure it isn't negative */  voice[i].modulation_wheel=channel[ch].modulation_wheel;  voice[i].delay = voice[i].sample->envelope_delay;  voice[i].modenv_delay = voice[i].sample->modenv_delay;  voice[i].tremolo_delay = voice[i].sample->tremolo_delay;  voice[i].vid=vid;  voice[i].tremolo_phase=0;  voice[i].tremolo_phase_increment=voice[i].sample->tremolo_phase_increment;  voice[i].tremolo_sweep=voice[i].sample->tremolo_sweep_increment;  voice[i].tremolo_sweep_position=0;  voice[i].tremolo_depth = voice[i].sample->tremolo_depth;  voice[i].vibrato_sweep=voice[i].sample->vibrato_sweep_increment;  voice[i].vibrato_sweep_position=0;  voice[i].delay_counter = 0;	init_voice_filter(i);	if (opt_nrpn_vibrato && channel[ch].vibrato_ratio) {		voice[i].vibrato_control_ratio = voice[i].sample->vibrato_control_ratio + channel[ch].vibrato_ratio;		if (voice[i].vibrato_control_ratio < 0)			voice[i].vibrato_control_ratio = 0;	} else		voice[i].vibrato_control_ratio = voice[i].sample->vibrato_control_ratio;	if (opt_nrpn_vibrato && channel[ch].vibrato_depth) {		voice[i].vibrato_depth = voice[i].sample->vibrato_depth + channel[ch].vibrato_depth;		if (voice[i].vibrato_depth > 255)			voice[i].vibrato_depth = 255;		else if (voice[i].vibrato_depth < -255)			voice[i].vibrato_depth = -255;	} else		voice[i].vibrato_depth = voice[i].sample->vibrato_depth;	voice[i].vibrato_delay = voice[i].sample->vibrato_delay + channel[ch].vibrato_delay;	voice[i].orig_vibrato_control_ratio = voice[i].sample->vibrato_control_ratio;  voice[i].vibrato_control_counter=voice[i].vibrato_phase=0;  for (j=0; j<VIBRATO_SAMPLE_INCREMENTS; j++)    voice[i].vibrato_sample_increment[j]=0;  /* Pan */  voice[i].panning = get_panning(ch, note, i);#ifdef ENABLE_PAN_DELAY  voice[i].pan_delay_rpt = 0;  if(opt_pan_delay) {	  if(voice[i].panning == 64) {voice[i].delay += pan_delay_table[64] * play_mode->rate / 1000;}	  else {		  if(pan_delay_table[voice[i].panning] > pan_delay_table[127 - voice[i].panning]) {			  pan_delay_diff = pan_delay_table[voice[i].panning] - pan_delay_table[127 - voice[i].panning];			  voice[i].delay += (pan_delay_table[voice[i].panning] - pan_delay_diff) * play_mode->rate / 1000;		  } else {			  pan_delay_diff = pan_delay_table[127 - voice[i].panning] - pan_delay_table[voice[i].panning];			  voice[i].delay += (pan_delay_table[127 - voice[i].panning] - pan_delay_diff) * play_mode->rate / 1000;		  }		  voice[i].pan_delay_rpt = pan_delay_diff * play_mode->rate / 1000;	  }	  memset(voice[i].pan_delay_buf, 0, sizeof(voice[i].pan_delay_buf));	  if(voice[i].pan_delay_rpt < 1) {voice[i].pan_delay_rpt = 0;}	  voice[i].pan_delay_wpt = voice[i].pan_delay_rpt - 1;  }#endif	/* ENABLE_PAN_DELAY */  voice[i].porta_control_counter = 0;  if(channel[ch].legato && channel[ch].legato_flag) {	  update_legato_controls(ch);  }  else if(channel[ch].portamento && !channel[ch].porta_control_ratio)      update_portamento_controls(ch);  voice[i].porta_control_ratio = 0;  if(channel[ch].porta_control_ratio)  {      if(channel[ch].last_note_fine == -1)      {	  /* first on */	  channel[ch].last_note_fine = voice[i].note * 256;	  channel[ch].porta_control_ratio = 0;      }      else      {	  voice[i].porta_control_ratio = channel[ch].porta_control_ratio;	  voice[i].porta_dpb = channel[ch].porta_dpb;	  voice[i].porta_pb = channel[ch].last_note_fine -	      voice[i].note * 256;	  if(voice[i].porta_pb == 0)	      voice[i].porta_control_ratio = 0;      }  }  if(cnt == 0)      channel[ch].last_note_fine = voice[i].note * 256;  recompute_amp(i);  if (voice[i].sample->modes & MODES_ENVELOPE)    {      /* Ramp up from 0 */	  voice[i].envelope_stage=0;      voice[i].envelope_volume=0;      voice[i].control_counter=0;      recompute_envelope(i);	  apply_envelope_to_amp(i);	  voice[i].modenv_stage = 0;      voice[i].modenv_volume = 0;      recompute_modulation_envelope(i);	  apply_modulation_envelope(i);    }  else    {      voice[i].envelope_increment=0;	  voice[i].modenv_increment=0;      apply_envelope_to_amp(i);	  apply_modulation_envelope(i);    }  recompute_freq(i);  recompute_voice_filter(i);  voice[i].timeout = -1;  if(!prescanning_flag)      ctl_note_event(i);}