# Could a DCT be used for an audio magnitude spectrum rather than DFT?

From what I understand, the DCT has half the bin size as a DFT of the same size N. The DFT also includes phase information, but often this is not needed when only the magnitude spectrum is desired.

• Could the DCT be used to provide a magnitude spectrum with twice the density (half the bin spacing) of the DFT or would out of phase information be lost?
• How about with a 50% overlap?
• I believe the DCT includes phase information, too, it just doesn't use complex numbers. The "real FFT" also uses half the memory and half the computation time for the same information, by throwing away the identical negative frequencies. "the real part of a double-length FFT is the same as the DCT except for the half-sample phase shift in the sinusoidal basis functions" – endolith Aug 22 '11 at 19:13
• Indeed, at minimum the sign of a coefficient can be considered as a poor man's phase – Laurent Duval Sep 9 '16 at 8:57

## 2 Answers

Yes, DCT can be used to provide a magnitude spectrum with twice the density. I do not quite understand overlap, but I am assuming that since DCT covers less, you thought there would be an overlap. To provide an eligible answer to the question, let me make a quick review for usage of DCT in mainly image processing.

First, we need to make some assumptions. In order to use DCT, you need to have a real signal. This is by definition. While you are saying, DCT has half the bin size comparing to DFT in size N, you are assuming that the signal is low frequency signal. Otherwise, not so much.

For usage of DCT in compression, since DFT of image will be symmetric, it produces redundant information (one side mirror will be enough to reproduce the signal). Therefore, kernel of DCT is used in order to produce denser information comparing to DFT. This is also true for low frequency audio signals, it can be used in the same way. While it makes it denser, coefficients gets bigger, since kernel of DCT covers both sides(real and imaginary parts) of the signal.

My major is image processing, so I tried to map DCT and DFT concepts and explanations in image processing. One difference between image and audio could be sizes, though. In image processing, you know the sizes(row and columns for FFT and other purpose of processing). I guess that you need to divide the vector of audio data somehow in order to further process. Without knowing the data, this could be troublesome(I am not sure).

Here is an image taken from web, but I did not write it down where I took it, could be wikipedia.; As you can see, transformed image is represented in DCT by magnitude spectrum with no problem. In a more compact and denser way, and look at the magnitude of coefficients. It is bigger than two times of DFT. DFT is symmetric, you could just divide it into two. One part is redundant. And one more thing, DCT can store the information is not just half of DFT but nearly quarter of DFT. That is generally the case of DCT overcoming to DFT in images.

• Can't the FFT be divided into fourths, because it's redundant in both X and Y dimensions? – endolith Sep 7 '11 at 19:44
• Why does it look like the FFT contains more information and the DCT contains more zeroes? – endolith Sep 7 '11 at 19:53
• First question, I do not quite understand, what do you mean by X and Y dimensions? For second question, is because of difference in their kernels. It does not look like DCT contains more zeroes, it actually contains more zeroes than normal Fourier Transform(DFT). This is due to again their difference in their kernels. – Hephaestus Sep 13 '11 at 0:47
• I mean that the image is a real signal, so the FFT contains redundant information. The negative half of the FFT is just a mirror of the positive half, in both dimensions. – endolith Nov 14 '11 at 18:56
• How about with a 50% overlap?

From this question, I understand that you are thinking about performing localized, block processing, in the manner of sliding Fourier or spectrogram.

• Could the DCT be used to provide a magnitude spectrum with twice the density (half the bin spacing) of the DFT or would out of phase information be lost?

If you talk about magnitude spectrum, of course part of the phase (be it the argument of a complex Fourier coefficient, or the sign of a DCT coefficient) will be lost anyway.

So of course you can plug a lot of kernels in replacement for the windowed Fourier transform inside the short-term-Fourier formulation for analysis only. The various breeds of DCT, their overlapped versions (LOT, MDCT), with nice orthogonal and window properties, can even be inverted (synthesis).

In audio, (non-complex) DCT or overlapped versions are often used for analysis, onset and pitch detection, (blind source separation) there is for instance the STFT, MDCT and inverses Matlab toolbox by A. Liutkus. The Large-time frequency analysis toolbox (LTFAT) also possesses:

• Fast TF-transforms with a linear time-frequency scale: Gabor (STFT), Wilson and windowed MDCT
• Sparse regression in the Gabor and WMDCT domain

I do not know audio very well. However, a 50% or 75% overlap are very common, and very few people use other settings. However, it is very common to use at least two window sizes, a long one of stationary part, a short one for transient, to help overcome the "one-window" time-frequency limitation.