-
Notifications
You must be signed in to change notification settings - Fork 0
/
myPemoAnalysisFilterBank.m
68 lines (58 loc) · 2.13 KB
/
myPemoAnalysisFilterBank.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [gfb_out_dec, analyzer,M] = myPemoAnalysisFilterBank(x,fs,M)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Version history
% - Version 2.0, October 2011: reduced the number of frequency bands per
% ERB
% - Version 1.0, June 2010: first release
% Copyright 2010-2011 Valentin Emiya (INRIA), Simon Maller and Pierre
% Leveau (Audionamix)
% This software is distributed under the terms of the GNU Public License
% version 3 (http://www.gnu.org/licenses/gpl.txt).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isdeployed
addpath(genpath('gammatone/'));
end
if nargin < 2,
error('Not enough input arguments.');
end
% ----------------------------------------------------------------------
% settings
% ----------------------------------------------------------------------
MinCF = 20; % (desired) minimum center frequency of the Gammatone filterbank in Hz
MaxCF = fs/2; % (desired) maximum center frequency of the Gammatone filterbank in Hz
base_freq = 1000; % one of the gammatone filters will have this center frequency
filters_per_ERB = 1.0; % density of gammatone filterbank
% upsampling of input signal to avoid aliasing in upper gammatone filters
fsOrig = fs;
if fs/2 < 1.5*MaxCF,
x = resample(x, round(1.5*fs), fs);
fs = round(1.5*fs);
end
% ----------------------------------------------------------------------
% actual signal processing
% ----------------------------------------------------------------------
% gammatone filterbank
analyzer = Gfb_Analyzer_new(fs, MinCF, base_freq, MaxCF, filters_per_ERB);
analyzer.fsOrig = fsOrig;
analyzer.fast = true;
[gfb_out, analyzer] = Gfb_Analyzer_process(analyzer, x(:).');
Nb = size(gfb_out,1);
if nargin<3 || isempty(M)
M = exp(-2*1i*pi/fs*analyzer.center_frequencies_hz(:)*(0:size(gfb_out,2)-1));
end
gfb_out = gfb_out.*M;
% decimate
bw = erbBW(analyzer.center_frequencies_hz);
alpha_dec = 2;
gfb_out_dec = cell(Nb,1);
Ndec = floor(fs./bw/alpha_dec);
for k=1:Nb
gfb_out_dec{k} = resample(gfb_out(k,:),1,Ndec(k));
end
if nargout>1
analyzer.Ndec = Ndec;
analyzer.fs = fs;
analyzer.bw = bw;
end
return;