Skip to content

v4.0: Changed parts of functions fftconv2 and gfbank_calcaxis #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions gbfb.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
% nu half-waves under the envelope in [spectral temporal] dimension
% distance [spectral temporal] spacing of filters (<1)
%
% - Gabor filter bank v3.0 -
% - Gabor filter bank v4.0 -
%
% This script extracts Gabor filter bank features
% from a spectro-temporal representation, e.g., from a log Mel-spectrogram.
Expand All @@ -27,6 +27,7 @@
% v3.0 - Fixed hann_win bug
% v3.0 - Removed log Mel-spectrogram calculation
% v3.0 - Added caching and simplified feature vector composition
% v4.0 - Sped-up part of functions fftconv2 and gfbank_calcaxis
%

%% Default settings and checks
Expand Down Expand Up @@ -110,25 +111,14 @@
c = distance .* 8 ./ nu;
% Second factor of Eq. (2a)
space_n = (1 + c(2)./2) ./ (1 - c(2)./2);
count_n = 0;
omega_n(1) = omega_max(2);
% Iterate starting with omega_max in spectral dimension
while omega_n/space_n > omega_min(2)
omega_n(1+count_n) = omega_max(2)/space_n.^count_n;
count_n = count_n + 1;
end
omega_n = fliplr(omega_n);
% Add DC
omega_n = [0,omega_n];
% Vectorised iteration starting with omega_max in spectral dimension, and adding DC (0)
n = floor(log(omega_max(2)/omega_min(2))/log(space_n));
omega_n = [0,omega_max(2)./space_n.^(n:-1:0)];
% Second factor of Eq. (2a)
space_k = (1 + c(1)./2) ./ (1 - c(1)./2);
count_k = 0;
omega_k(1) = omega_max(1);
% Iterate starting with omega_max in temporal dimension
while omega_k/space_k > omega_min(1)
omega_k(1+count_k) = omega_max(1)/space_k.^count_k;
count_k = count_k + 1;
end
% Vectorised iteration starting with omega_max in temporal dimension
k = floor(log(omega_max(1)/omega_min(1))/log(space_k));
omega_k = omega_max(1)./space_k.^(0:k);
% Add DC and negative MFs for spectro-temporal opposite
% filters (upward/downward)
omega_k = [-omega_k,0,fliplr(omega_k)];
Expand Down Expand Up @@ -266,10 +256,7 @@
size_x = size(in1,2)+size(in2,2)-1;
fft_size_x = 2.^ceil(log2(size_x));
fft_size_y = 2.^ceil(log2(size_y));
in1_fft = fft2(in1,fft_size_y,fft_size_x);
in2_fft = fft2(in2,fft_size_y,fft_size_x);
out_fft = in1_fft .* in2_fft;
out_padd = ifft2(out_fft);
out_padd = ifft2(fft2(in1,fft_size_y,fft_size_x) .* fft2(in2,fft_size_y,fft_size_x));
out_padd = out_padd(1:size_y,1:size_x);
switch shape
case 'same'
Expand Down