view dsp/synth/shepardtone.m @ 34:c75bb62b90a9

Imported audio synthesis tools.
author samer
date Sun, 20 Jan 2013 19:05:05 +0000
parents
children 9e7be347b3a0
line wrap: on
line source
function y=shepardtone(N,C,prof,H)
% shepardtone - Shepard tone by additive synthesis
%
% shepardtone ::
%    N:natural    ~'size of buffers to produce',
%    seq(real)    ~'sequence of chroma values, 0--1 is one octave',
% -> seq([[1,N]]) ~'sum of components'.
%
% Note: the number of components must remain constant

if nargin<3, 
	prof=@(z)betapdf(2*z,2,9); 
elseif isvector(prof),
	a=prof(1); b=prof(2);
	prof=@(z)betapdf(2*z,a,b);
end

fc=0.25;
if nargin<4, H=(-10:1)'; else H=H(:); end
F=fndata(@(c)fc*2.^(H+mod(c,1)),C);  % frequencies
A=fndata(prof,F); % component amplitudes
y=addsynth(N,A,F,0);