% Catie % shepardtones.m - plays the shepard tones % adjustable parameters commented out % max_time = 2; % max_repeat = 3; % A = 440; % "base frequency" fs = 8192; % the sampling rate dt = 1/fs; t = [0:dt:max_time]; k = -2:(-2+num_harm); m = 2^(1/12); % semitones % sigmasq = 1; rep = []; for j = 0:11 y = zeros(size(t)); % initialize the tone vector for i = 1:num_harm % use each harmonic in k f_ij = 2^k(i)*(A*(m^j)); % the frequency of this component amp = exp((-1/2*sigmasq)*(log2(f_ij/A))^2); y = y + amp*cos(2*pi*f_ij*t); end; rep = [rep y]; % append the finished tone to the tone vector end; rep = repmat(rep,1,max_repeat); % repeat max_repeat times soundsc(rep,fs); % play it