annotate toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/FMPoints.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function points=FMPoints(len, freq, fmFreq, fmAmp, fs)
wolffd@0 2 % points=FMPoints(len, freq, fmFreq, fmAmp, fs)
wolffd@0 3 % Generates (fractional) sample locations for frequency-modulated impulses
wolffd@0 4 % len = number of samples
wolffd@0 5 % freq = pitch frequency (Hz)
wolffd@0 6 % fmFreq = vibrato frequency (Hz) (defaults to 6 Hz)
wolffd@0 7 % fmAmp = max change in pitch (defaults to 5% of freq)
wolffd@0 8 % fs = sample frequency (defaults to 22254.545454 samples/s)
wolffd@0 9 %
wolffd@0 10 % Basic formula: phase angle = 2*pi*freq*t + (fmAmp/fmFreq)*sin(2*pi*fmFreq*t)
wolffd@0 11 % k-th zero crossing approximately at sample number
wolffd@0 12 % (fs/freq)*(k - (fmAmp/(2*pi*fmFreq))*sin(2*pi*k*(fmFreq/freq)))
wolffd@0 13
wolffd@0 14 % (c) 1998 Interval Research Corporation
wolffd@0 15
wolffd@0 16 if nargin<2,
wolffd@0 17 fprintf('Format: sig=fmPoints(len, freq [, fmAmp, fmFreq, sampleRate])\n');
wolffd@0 18 return;
wolffd@0 19 end;
wolffd@0 20 if nargin<5,
wolffd@0 21 fs=22254.545454;
wolffd@0 22 end;
wolffd@0 23 if nargin<4,
wolffd@0 24 fmAmp=0.05*freq;
wolffd@0 25 end;
wolffd@0 26 if nargin<3,
wolffd@0 27 fmFreq=6;
wolffd@0 28 end;
wolffd@0 29
wolffd@0 30 kmax=fix(freq*(len/fs));
wolffd@0 31 points=0:kmax-1;
wolffd@0 32 points=1+(fs/freq)*(points-(fmAmp/(2*pi*fmFreq))* ...
wolffd@0 33 sin(2*pi*(fmFreq/freq)*points));