Mercurial > hg > gccphat-windowing
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Simulation/createFiltNoise.m Mon Jun 11 17:42:13 2012 +0100 @@ -0,0 +1,60 @@ +function [output]=createFiltNoise(input,centreFreq,bandWidth,filterOrder,Fs) + +% create filtered noise for bandwidth simulation +% +% Input: +% - input: input to be filtered +% - centreFreq: centre frequency or cutoff frequency +% - bandWidth: width of filter +% - filterOrder: order of butterworth filter (4) +% - Fs: sampling frequency (44100) +% +% Output: +% - output: array +% + +% Developer: - Alice Clifford (alice.clifford@eecs.qmul.ac.uk) + + + +if centreFreq==0 %LOW PASS FILTER FOR CENTRE FREQ ==0 + + cutoffFreq=bandWidth; + + normCutFreq=(cutoffFreq/(Fs/2)); + + [b,a]=butter(filterOrder,normCutFreq,'low'); + + output=filter(b,a,input); + + + +elseif centreFreq==22050 %HIGH PASS FILTER FOR CENTREFREQ == FS/2 + + cutoffFreq=(Fs/2)-bandWidth; + + normCutFreq=(cutoffFreq/(Fs/2)); + + [b,a]=butter(filterOrder,normCutFreq,'high'); %HIGH PASS FILTER + + output=filter(b,a,input); + + + + +else% %BAND PASS - NEED LOW AND HIGH PASS + + lowBandFreq=centreFreq-(bandWidth/2); + highBandFreq=centreFreq+(bandWidth/2); + + highNormBandFreq=(highBandFreq/(Fs/2)); + lowNormBandFreq=(lowBandFreq/(Fs/2)); + + + [b,a]=butter(filterOrder,[lowNormBandFreq highNormBandFreq]); + + + + output=filter(b,a,input); + +end \ No newline at end of file