comparison Simulation/createFiltNoise.m @ 0:ab043bd3b162 tip

First commit
author Alice Clifford <alice.clifford@eecs.qmul.ac.uk>
date Mon, 11 Jun 2012 17:42:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ab043bd3b162
1 function [output]=createFiltNoise(input,centreFreq,bandWidth,filterOrder,Fs)
2
3 % create filtered noise for bandwidth simulation
4 %
5 % Input:
6 % - input: input to be filtered
7 % - centreFreq: centre frequency or cutoff frequency
8 % - bandWidth: width of filter
9 % - filterOrder: order of butterworth filter (4)
10 % - Fs: sampling frequency (44100)
11 %
12 % Output:
13 % - output: array
14 %
15
16 % Developer: - Alice Clifford (alice.clifford@eecs.qmul.ac.uk)
17
18
19
20 if centreFreq==0 %LOW PASS FILTER FOR CENTRE FREQ ==0
21
22 cutoffFreq=bandWidth;
23
24 normCutFreq=(cutoffFreq/(Fs/2));
25
26 [b,a]=butter(filterOrder,normCutFreq,'low');
27
28 output=filter(b,a,input);
29
30
31
32 elseif centreFreq==22050 %HIGH PASS FILTER FOR CENTREFREQ == FS/2
33
34 cutoffFreq=(Fs/2)-bandWidth;
35
36 normCutFreq=(cutoffFreq/(Fs/2));
37
38 [b,a]=butter(filterOrder,normCutFreq,'high'); %HIGH PASS FILTER
39
40 output=filter(b,a,input);
41
42
43
44
45 else% %BAND PASS - NEED LOW AND HIGH PASS
46
47 lowBandFreq=centreFreq-(bandWidth/2);
48 highBandFreq=centreFreq+(bandWidth/2);
49
50 highNormBandFreq=(highBandFreq/(Fs/2));
51 lowNormBandFreq=(lowBandFreq/(Fs/2));
52
53
54 [b,a]=butter(filterOrder,[lowNormBandFreq highNormBandFreq]);
55
56
57
58 output=filter(b,a,input);
59
60 end