Skip to content
Snippets Groups Projects
Commit 24581519 authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Fixed bugs in winSincFracDel.m where no integral delay was applied and...

Fixed bugs in winSincFracDel.m where no integral delay was applied and corrected calculation of delayed signals
parent dbe64773
Branches
No related tags found
1 merge request!3Update to v0.2.3
......@@ -137,9 +137,9 @@ function [sincFilt, causDel, dSig] = winSincFracDel(del, len, winFun, sig, sigLe
% ====================================================
% Calculate some parameters
% ====================================================
fracDel = del - abs(rem(intDel, 1)); % Fractional part of the delay
fracDel = rem(del, 1); % Fractional part of the delay
% ====================================================
% Generate FIR filter for fractional delay
% ====================================================
......@@ -156,7 +156,7 @@ function [sincFilt, causDel, dSig] = winSincFracDel(del, len, winFun, sig, sigLe
if isstring(winFun)
switch lower(winFun)
case "rectangular"
win = ones(length(idx), 1);
win = ones(1, length(idx));
case "hann"
win = sin(pi * (idx - fracDel + causDel + 1)/len).^2;
case "hamming"
......@@ -171,13 +171,18 @@ function [sincFilt, causDel, dSig] = winSincFracDel(del, len, winFun, sig, sigLe
% Apply window to the filter
sincFilt = sincFilt .* win;
% Add the integral delay
intDel = zeros(fix(del) + 1, 1); intDel(end) = 1;
sincFilt = conv(sincFilt, intDel);
sincFilt = sincFilt(1:len);
% ====================================================
% Filter the signals
% ====================================================
if nargout > 2
for idx = size(sig, 2):-1:1
dSig(:, idx) = conv(sig, sincFilt, lower(sigLen));
dSig(:, idx) = conv(sig, sincFilt.', lower(sigLen));
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment