From 299370a10fa6df930a4f9459619904bb15277ab8 Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 21 Mar 2008 17:01:07 +0000 Subject: [PATCH] Add noise tools git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@153 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- tools/pink_noise.m | 15 +++++++++++++++ tools/white_noise.m | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 tools/pink_noise.m create mode 100644 tools/white_noise.m diff --git a/tools/pink_noise.m b/tools/pink_noise.m new file mode 100644 index 0000000..b739a97 --- /dev/null +++ b/tools/pink_noise.m @@ -0,0 +1,15 @@ +function s = pink_noise(n) + +% Generate a pink noise +% n : number of samples to synthesize + +% Filter coefficients +B = [0.049922035 -0.095993537 0.050612699 -0.004408786]; +A = [1 -2.494956002 2.017265875 -0.522189400]; + +nT60 = round(log(1000)/(1-max(abs(roots(A))))); % T60 est. +v = randn(1, n + nT60); % Gaussian white noise: N(0,1) +s = filter(B, A, v); % Apply 1/F roll-off to PSD +s = 2*s(nT60+1:end); % Skip transient response + +end diff --git a/tools/white_noise.m b/tools/white_noise.m new file mode 100644 index 0000000..65f5a3c --- /dev/null +++ b/tools/white_noise.m @@ -0,0 +1,8 @@ +function s = white_noise(n) + +% Generate a white noise +% n : number of samples to synthesize + +s = 2*(rand(n,1)-0.5); + +end -- 2.39.5