FFT Convolution on Wav File

조회 수: 2 (최근 30일)
Matthew Tindall
Matthew Tindall 2016년 12월 5일
댓글: Massimo Zanetti 2016년 12월 5일
Seem to get a Vercat error on line 10 saying there is a problem with 'X = fft( [x ; zeros(length(brirL),1) ]); ' however i just can't see it and have been trying for a while now. Here is the code, Thanks in advanced, regards Matt
close all clear all
[x Fs]=audioread('drums.wav'); brir = audioread('HRIR_C.wav'); brirL = brir(:,1); brirR = brir(:,2);
L = length(x) + length(brirL) -1 ; % Output data length X = fft( [x ; zeros(length(brirL),1) ]); HL = fft( [ brirL ; zeros(length(x) ,1) ] ); HR = fft( [ brirR ; zeros(length(x) ,1 ) ] );
outL = zeros(L,1); % output buffer outR = zeros(L,1);
outL = ifft(X .* HL); % multiplication of fft results & ifft outR = ifft(X .* HR);
mainOut = [outL outR];
sound(mainOut,Fs)

답변 (1개)

Massimo Zanetti
Massimo Zanetti 2016년 12월 5일
Is your audio file x (loaded with [x Fs]=audioread('drums.wav'); ) stereo? Because in this case the line
X = fft( [x ; zeros(length(brirL),1) ]);
will of course throw an error, because you cannot vertcat a 2-column matrix with a one-column matrix...
  댓글 수: 2
Matthew Tindall
Matthew Tindall 2016년 12월 5일
The file is mono I believe
Massimo Zanetti
Massimo Zanetti 2016년 12월 5일
Do you believe? Let's try a more deterministic check, what's the output of size(x)?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by