annotate 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 |
|
rev |
line source |
samer@34
|
1 function y=shepardtone(N,C,prof,H)
|
samer@34
|
2 % shepardtone - Shepard tone by additive synthesis
|
samer@34
|
3 %
|
samer@34
|
4 % shepardtone ::
|
samer@34
|
5 % N:natural ~'size of buffers to produce',
|
samer@34
|
6 % seq(real) ~'sequence of chroma values, 0--1 is one octave',
|
samer@34
|
7 % -> seq([[1,N]]) ~'sum of components'.
|
samer@34
|
8 %
|
samer@34
|
9 % Note: the number of components must remain constant
|
samer@34
|
10
|
samer@34
|
11 if nargin<3,
|
samer@34
|
12 prof=@(z)betapdf(2*z,2,9);
|
samer@34
|
13 elseif isvector(prof),
|
samer@34
|
14 a=prof(1); b=prof(2);
|
samer@34
|
15 prof=@(z)betapdf(2*z,a,b);
|
samer@34
|
16 end
|
samer@34
|
17
|
samer@34
|
18 fc=0.25;
|
samer@34
|
19 if nargin<4, H=(-10:1)'; else H=H(:); end
|
samer@36
|
20 F=map(@(c)fc*2.^(H+mod(c,1)),C); % frequencies
|
samer@36
|
21 A=map(prof,F); % component amplitudes
|
samer@34
|
22 y=addsynth(N,A,F,0);
|
samer@34
|
23
|