view dsp/synth/shepardtone.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 9e7be347b3a0
children
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=map(@(c)fc*2.^(H+mod(c,1)),C);  % frequencies
A=map(prof,F); % component amplitudes
y=addsynth(N,A,F,0);