0
$\begingroup$

I have an audio signal that is composed of 2 channels. The signal is all real numbers.

I transform this signal into frequency domain using fft, multiply it with a filter frequency response, and then transform it back into time domain.

My problem is that the result is a complex signal.

How can I convert this complex signal back into a real time signal.

The filter is not a real filter.

$\endgroup$
  • 1
    $\begingroup$ 1. Is the filter real? If it isn't, then its output won't be, either. 2. Are the resulting imaginary numbers very small? If they are, they could be the result of numerical approximations and can be discarded. $\endgroup$ – MBaz Mar 20 '17 at 13:57
  • $\begingroup$ No, the filter is not real, and the imaginary numbers are not small. $\endgroup$ – user304584 Mar 20 '17 at 14:02
  • $\begingroup$ I am thinking to break it down to multiple sinusoids from the frequency domain. Then scale each sinusoid and shift its phase according to the frequency value before adding them all up. Unless there is a simpler way to do it in matlab. $\endgroup$ – user304584 Mar 20 '17 at 14:13
  • $\begingroup$ If the filter is not real (note that I'm referring to its impulse response, not its frequency response), then in general you cannot expect the output to be real. In Matlab, the easiest way to filter is with the conv or filter commands. $\endgroup$ – MBaz Mar 20 '17 at 14:39
1
$\begingroup$

First I would advise against your filtering approach, which is the "Frequency Sampling" method of filtering (if you are using multiplying your FFT by a target response directly) which has poor performance and efficiency. (The frequency sampling approach will provide your exact solution at your FFT bin centers only, and then a lot more ripple in between vs the algorithms I suggest below.) However if you need to be in the frequency domain anyway, and are multiplying by the FFT of your desired filter coefficients, this would be ok as long as you are properly dealing with the circular convolution involved.

Also I would use a real filter unless you are intentionally trying to get an asymmetric spectrum response (meaning positive and negative spectrums are differrent, which implies a complex signal-- given that is what you are trying to avoid then there is no reason to use a complex filter).

To implement a real filter, with a real signal and a real output, consider using either the Parks-McClellan or Least Squares algorithms, with design tools readily available in Matlab, Octave and Python, and then implement your filter as an FIR filter in the time domain.

If you need to implement filtering in the frequency domain, you can force it to be a real filter by ensuring that the filter is conjugate symmetric; for an FFT the 0 bin is the center (DC value), and then the samples from 1 to N/2-1 should be conjugate symmetric to the samples from N/2 to N-1; where sample 1 is the conjugate of sample N-1, sample 2 is conjugate of sample N-2 etc...

$\endgroup$
  • $\begingroup$ I am bound to use an asymmetric filter as I cannot change the filter type due to the application. Also, I am bound to use the frequency filtering method as I am working with frequency bands of the signal it self one at a time, and time filtering will be even less efficient. $\endgroup$ – user304584 Mar 20 '17 at 15:14
  • $\begingroup$ I just understood that it is impossible because the frequency response in this case will not be symmetric. So in order to make the signal real, I will have to change the frequency response and the signal will not be the same. $\endgroup$ – user304584 Mar 20 '17 at 15:17
  • $\begingroup$ Note: when you say asymmetric filter do you really mean a filter whose frequency response is asymmetric for positive and negative frequencies or a filter whos taps are not symmetric (meaning not linear phase)? If you really require asymmetry in frequency then you have to have complex signals. I am guessing you just want a non-linear phase filter--- what is your application? $\endgroup$ – Dan Boschen Mar 20 '17 at 15:21
  • $\begingroup$ I see regarding your frequency filtering; I assumed you were doing it in frequency to apply a certain filtering response directly as determined at each FFT bin; but you could just as well multiply your signal FFT with the FFT of a well designed filter with similar result. So not sure my response is of any help yet and will delete it soon unless we can improve it (just so that you can attract a better answer). $\endgroup$ – Dan Boschen Mar 20 '17 at 15:27
  • $\begingroup$ Oh yeah, my filter is nonlinear in phase. I am doing a project in speech compression which uses complex gamma tone filters, where the filtering happens as you noted, each band is multiplied in frequency domain with a certain gamma tone filter. The filter is not conj. symmetric in frequency. so, the answer is that it is not possible to transform it back into time domain as a real signal. Thanks for your response anyways. $\endgroup$ – user304584 Mar 20 '17 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.