%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create the wavetable -- five overtones with 1/F amplitudes:
%
or = 11025; % output sampling rate
X = (0:(or-1))*2*pi/or; % time base
P = sin(X) + (1/2)*sin(2*X) + (1/3)*sin(3*X) + (1/4)*sin(4*X) + (1/5)*sin(5*X);

%%%%%%%%%%%%%%%%%%%
% Read in .cf0 file
%
fid = fopen('JfkX1.cf0′); NR = textscan(fid, '%f %f', 6000); fclose(fid);F = NR{1}; A = NR{2};

A(F==0) = 0.0; % zero amplitude where pitch is undefined
F(F==0) = 100; % nominal pitch where undefined, to avoid possible division by 0

mr=200; % sampling rate of frequency- and amplitude-modulating signals

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make the audio signal and save it to a .wav file
%
s = afwosc(P,F,A,mr,11025);
soundsc(s,11025); % play it
s = s/max(abs(s)); % normalize amplitude
wavwrite(s,11025,'JfkX1r.wav');

