function newi = Pitch(i,v)
% compute new sample for this ith one sample using voice v.
% newi is  a fractional index to be interpolated.
    % Here, the sweep amplitude indicates an increase (or decrease) in sampling
    % rate, so it's a multiplicative phenomenon really.  Thus if the
% sweep amplitude stays the same, then that amplitude will be added to 
%THE EXISTING OFFSET; effect is not a shifted sampling but a sampling
% at a different rate!  Again, with sinewave sweeps it's hard to
% differentiate between pitch and delay but you'd notice with an
% exponent of .4 I betcha.



global N Fs DEL_E DEL_HZ DEL_AMP DEL_PH;
global PIT_E PIT_HZ PIT_SWAMP PIT_PH PITCHES;
persistent cur_samp_ind; % current sample "index" or location.
if i == 1 
    cur_samp_ind = 0;
end

e = PITCHES(v, PIT_E);
hz = PITCHES(v, PIT_HZ);
amp = PITCHES(v, PIT_SWAMP);
p = PITCHES(v, PIT_PH);
inc = (amp-1) * (cbexp(sin(ind2ang(i,hz,p)), e));
% now del is really the increment to next sample. it
%varies by up to so many hundredths of half-step or whatever,
% defined purely as a multiple of the current rate.
% So....
cur_samp_ind = cur_samp_ind  + inc; % add 1+inc to last
newi = i+ cur_samp_ind;
end
