annotate aim-mat/tools/@signal/gennoise.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 % method of class @signal
tomwalters@0 2 % function sig=gennoise
tomwalters@0 3 % sig: original @signal with length and samplerate
tomwalters@0 4 %
tomwalters@0 5 % This function generates 1/f spatial noise, with a normal error
tomwalters@0 6 % distribution (the grid must be at least 10x10 for the errors to be normal).
tomwalters@0 7 % 1/f noise is scale invariant, there is no spatial scale for which the
tomwalters@0 8 % variance plateaus out, so the process is non-stationary.
tomwalters@0 9 %
tomwalters@0 10 % BETA defines the spectral distribution.
tomwalters@0 11 % Spectral density S(f) = N f^BETA
tomwalters@0 12 % (f is the frequency, N is normalisation coeff).
tomwalters@0 13 % BETA = 0 is random white noise.
tomwalters@0 14 % BETA -1 is pink noise
tomwalters@0 15 % BETA = -2 is Brownian noise
tomwalters@0 16 % The fractal dimension is related to BETA by, D = (6+BETA)/2
tomwalters@0 17 %
tomwalters@0 18 %
tomwalters@0 19 % RETURN VALUE:
tomwalters@0 20 % sig: @signal
tomwalters@0 21 %
bleeck@3 22 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 23 % (c) 2011, University of Southampton
bleeck@3 24 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 25 % download of current version is on the soundsoftware site:
bleeck@3 26 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 27 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 28
tomwalters@0 29 % function sig=gennoise(sig,beta,rms_desired)
tomwalters@0 30 function sig=gennoise(sig,beta)
tomwalters@0 31
tomwalters@0 32 % if nargin<3
tomwalters@0 33 % rms_desired=-1; %
tomwalters@0 34 % end
tomwalters@0 35 if nargin<2
tomwalters@0 36 beta=0; %
tomwalters@0 37 end
tomwalters@0 38
tomwalters@0 39 sr=getsr(sig);
tomwalters@0 40 len=getnrpoints(sig);
tomwalters@0 41
tomwalters@0 42 dots=spatialPattern([1,len],beta);
tomwalters@0 43
tomwalters@0 44 sig=setvalues(sig,dots);
tomwalters@0 45 sig=setname(sig,sprintf('Noise with beta = %2.1f',beta));
tomwalters@0 46
tomwalters@0 47
tomwalters@0 48 % if rms_desired>=0
tomwalters@0 49 % sig=rms_desired*sig/rms(sig);
tomwalters@0 50 % end
tomwalters@0 51
tomwalters@0 52