Skip to content

Commit 815cfe3

Browse files
authored
Matchering rewrite for GitHub
1 parent 6fb239b commit 815cfe3

File tree

5 files changed

+745
-0
lines changed

5 files changed

+745
-0
lines changed

fconv.m

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function [y] = fconv(x, h)
2+
%FCONV Fast Convolution
3+
% [y] = FCONV(x, h) convolves x and h, and normalizes the output
4+
% to +-1.
5+
%
6+
% x = input vector
7+
% h = input vector
8+
%
9+
% See also CONV
10+
%
11+
% NOTES:
12+
%
13+
% 1) I have a short article explaining what a convolution is. It
14+
% is available at http://stevem.us/fconv.html.
15+
%
16+
%
17+
%Version 1.0
18+
%Coded by: Stephen G. McGovern, 2003-2004.
19+
20+
Ly = length(x) + length(h) - 1; %
21+
Ly2 = pow2(nextpow2(Ly)); % Find smallest power of 2 that is > Ly
22+
X = fft(x, Ly2); % Fast Fourier transform
23+
H = fft(h, Ly2); % Fast Fourier transform
24+
Y = X .* H; %
25+
y = real(ifft(Y, Ly2)); % Inverse fast Fourier transform
26+
y = y(1:1:Ly); % Take just the first N elements
27+
%y=y/max(abs(y)); % Normalize the output (commented by SOUND.TOOLS, we don't need this normalization)

0 commit comments

Comments
 (0)