Mercurial > hg > aimmat
annotate aim-mat/tools/@signal/genfm.asv @ 4:537f939baef0 tip
various bug fixes and changed copyright message
author | Stefan Bleeck <bleeck@gmail.com> |
---|---|
date | Tue, 16 Aug 2011 14:37:17 +0100 |
parents | 74dedb26614d |
children |
rev | line source |
---|---|
tomwalters@0 | 1 % method of class @signal |
tomwalters@0 | 2 % function sig=genfm(sig,fc,f_mod,modindex,amplitude) |
tomwalters@0 | 3 % |
tomwalters@0 | 4 % INPUT VALUES: |
tomwalters@0 | 5 % sig: original @signal with length and samplerate |
tomwalters@0 | 6 % fc: carrier frequency (Hz) |
tomwalters@0 | 7 % fmod: modulation frequency (Hz) |
tomwalters@0 | 8 % modindex: modulation index b = |
tomwalters@0 | 9 % maximum carrier frequency deviation / modulation frequency |
tomwalters@0 | 10 % modulation depth = |
tomwalters@0 | 11 % |
tomwalters@0 | 12 % RETURN VALUE: |
tomwalters@0 | 13 % sig: @signal |
tomwalters@0 | 14 % |
tomwalters@0 | 15 % (c) 2007 ISVR University of Southampton |
tomwalters@0 | 16 % Stefan Bleeck (bleeck@gmail.com) |
tomwalters@0 | 17 % $Date: 2003/01/25 12:47:43 $ |
tomwalters@0 | 18 % $Revision: 1.4 $ |
tomwalters@0 | 19 |
tomwalters@0 | 20 function sig=genfm(sig,fc,f_mod,modindex,amplitude) |
tomwalters@0 | 21 |
tomwalters@0 | 22 if nargin<5 |
tomwalters@0 | 23 amplitude=1; |
tomwalters@0 | 24 end |
tomwalters@0 | 25 if nargin<4 |
tomwalters@0 | 26 modindex=0.1; |
tomwalters@0 | 27 end |
tomwalters@0 | 28 if nargin<3 |
tomwalters@0 | 29 f_mod=100; |
tomwalters@0 | 30 end |
tomwalters@0 | 31 if nargin<2 |
tomwalters@0 | 32 fc=1000; |
tomwalters@0 | 33 end |
tomwalters@0 | 34 |
tomwalters@0 | 35 |
tomwalters@0 | 36 |
tomwalters@0 | 37 sr=getsr(sig); |
tomwalters@0 | 38 len=getlength(sig); |
tomwalters@0 | 39 |
tomwalters@0 | 40 d=getvalues(sig); |
tomwalters@0 | 41 d=zeros(size(d)); |
tomwalters@0 | 42 |
tomwalters@0 | 43 t=0:1/sr:len-1/sr; |
tomwalters@0 | 44 |
tomwalters@0 | 45 fm=amplitude*cos(2*pi*fc.*t + modindex*sin(2*pi*f_mod.*t)); |
tomwalters@0 | 46 |
tomwalters@0 | 47 sig=setvalues(sig,fm); |
tomwalters@0 | 48 |
tomwalters@0 | 49 |
tomwalters@0 | 50 % f1=fc-f_mod; |
tomwalters@0 | 51 % f2=fc; |
tomwalters@0 | 52 % f3=fc+f_mod; |
tomwalters@0 | 53 % sin1=sinus(len,sr,f1,modgrad/2,0); |
tomwalters@0 | 54 % sin2=sinus(len,sr,f2,1,0); |
tomwalters@0 | 55 % sin3=sinus(len,sr,f3,modgrad/2,0); |
tomwalters@0 | 56 % sig=sin1; |
tomwalters@0 | 57 % sig=sig+sin2; |
tomwalters@0 | 58 % sig=sig+sin3; |
tomwalters@0 | 59 |
tomwalters@0 | 60 name=sprintf('FM: modulation: %3.1f Hz, carrier: %4.1f kHz, mod index: %2.1f',f_mod,fc/1000,modindex); |
tomwalters@0 | 61 sig=setname(sig,name); |
tomwalters@0 | 62 % sig=scaletomaxvalue(sig,1); |
tomwalters@0 | 63 % sig=RampAmplitude(sig,0.01); % baue eine Rampe |
tomwalters@0 | 64 |