i'm trying to make a simple convolution of two signals. One is a signal (music for example) and the other one is an IR (simple delay like this scheme:
IR[0] = 1.0
IR[1->511] = 0
IR[512] = 0.5
IR[513->1023] = 0;
so it should make a small echo.
I've learned that convolution in the time domain, is multiplication in the frequency domain.
so my idea is to take the FFT of both signals (music and IR) and to multiply the resulting couple numbers re & im (from re + im*i), then take the iFFT and admire the result.
fft(fftMusic);
fft(fftIR);
for (int i = 0; i < n; i++)
fftMusic[i] = fftMusic[i] * fftIR[i];
ifft(fftusic);
for (int i = 0; i < n; i++)
fftMusic[i] = fftMusic[i] * 2/double(n);
The only problem is that it doesn't works.
I've tried both RFDT and CFDT and i produces a strange result : my signal is delayed but in reverse. Is it a FFT thing ?
first for the RDFT (Real DFT : re in, re & im out), i added +n/2 zero samples at the end or both music and IR, for the convolution, then used 4 overlapped buffers (it is the number required) and calculated when the time is right the FFT of both then multiply, then iFFT etc.
Second for the CDFT (complex DFT : re & im in & out), i put a sample of music every two sample (and zero for the imaginary part) then did the cdft, multiplied ,etc
but both doesn't works and give the same result: a weird mix of reversed and delayed sounds.
please help.
- List item