samer@34: function y=shepardtone(N,C,prof,H) samer@34: % shepardtone - Shepard tone by additive synthesis samer@34: % samer@34: % shepardtone :: samer@34: % N:natural ~'size of buffers to produce', samer@34: % seq(real) ~'sequence of chroma values, 0--1 is one octave', samer@34: % -> seq([[1,N]]) ~'sum of components'. samer@34: % samer@34: % Note: the number of components must remain constant samer@34: samer@34: if nargin<3, samer@34: prof=@(z)betapdf(2*z,2,9); samer@34: elseif isvector(prof), samer@34: a=prof(1); b=prof(2); samer@34: prof=@(z)betapdf(2*z,a,b); samer@34: end samer@34: samer@34: fc=0.25; samer@34: if nargin<4, H=(-10:1)'; else H=H(:); end samer@36: F=map(@(c)fc*2.^(H+mod(c,1)),C); % frequencies samer@36: A=map(prof,F); % component amplitudes samer@34: y=addsynth(N,A,F,0); samer@34: