annotate aim-mat/tools/gen_multiramp.m @ 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 20ada0af3d7d
children
rev   line source
tomwalters@0 1 %
tomwalters@0 2 % function sig=gen_multiramp(carriers,halflifes,reprate,signal_length, sample_fq)
tomwalters@0 3 %
tomwalters@0 4 % Generates a superposition of ramped sinusiod signals
tomwalters@0 5 %
tomwalters@0 6 % INPUT VALUES:
tomwalters@0 7 % carriers carrier frequences (vector)
tomwalters@0 8 % halflifes (vector, same length as carriers)
tomwalters@0 9 % reprate frequence of envelope
tomwalters@0 10 % signal_length in seconds !!!
tomwalters@0 11 % sample_fq sample frequence
tomwalters@0 12 %
tomwalters@0 13 % RETURN VALUE:
tomwalters@0 14 % sig object signal
tomwalters@0 15 %
tomwalters@0 16 %
bleeck@3 17 % (c) 2011, University of Southampton
bleeck@3 18 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 19 % download of current version is on the soundsoftware site:
bleeck@3 20 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 21 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 22
tomwalters@0 23 function sig=gen_multiramp(carriers,halflifes,reprate,signal_length, sample_fq)
tomwalters@0 24 if nargin < 4
tomwalters@0 25 signal_length=0.128;
tomwalters@0 26 end
tomwalters@0 27 if nargin < 3
tomwalters@0 28 reprate=62.5;
tomwalters@0 29 end
tomwalters@0 30 if nargin < 2
tomwalters@0 31 hlsteps=8;
tomwalters@0 32 halflives=distributelogarithmic(0.064,0.0005,hlsteps);
tomwalters@0 33 else
tomwalters@0 34 hlsteps=length(halflifes);
tomwalters@0 35 end
tomwalters@0 36 if nargin < 1
tomwalters@0 37 carsteps=5;
tomwalters@0 38 carriers=distributelogarithmic(250,4000,carsteps);
tomwalters@0 39 else
tomwalters@0 40 carsteps=length(carriers);
tomwalters@0 41 end
tomwalters@0 42
tomwalters@0 43
tomwalters@0 44 sr = sample_fq;
tomwalters@0 45 % sr=16000;
tomwalters@0 46 % signal_length=0.264-1/sr;
tomwalters@0 47 sig=signal(signal_length,sr);
tomwalters@0 48
tomwalters@0 49 for i=1:hlsteps
tomwalters@0 50 for j=1:carsteps
tomwalters@0 51 current_carrier=carriers(j);
tomwalters@0 52 halflife=halflifes(i);
tomwalters@0 53 sig=generaterampsinus(sig,current_carrier,reprate,1,halflife);
tomwalters@0 54
tomwalters@0 55 if j==1
tomwalters@0 56 gsig=sig;
tomwalters@0 57 else
tomwalters@0 58 gsig=gsig+sig;
tomwalters@0 59 end
tomwalters@0 60 end
tomwalters@0 61
tomwalters@0 62 if i==1
tomwalters@0 63 tsig=gsig;
tomwalters@0 64 else
tomwalters@0 65 tsig=append(tsig,gsig);
tomwalters@0 66 end
tomwalters@0 67
tomwalters@0 68 end
tomwalters@0 69 % savewave(tsig,'tsig');
tomwalters@0 70
tomwalters@0 71
tomwalters@0 72 sig=tsig;