# Haar Wavelets vs STFT for graceful audio quality degradation (newbie question)

I'm playing around with FFT (using Naudio library) and with Wavelets (using TarsosDSP library) trying to get better understanding of both of them.

I've noticed that when I zero out FFT/Wavelet coefficients (for the same window size - and then perform inverse transform and listen to the result) starting from low to high energies and compare the loss of audio quality Wavelets seems to suffer less. They have less noise for the same number of zeroed out coefficients (or require less non-zero coefficients to have roughly the same amount of noise) and require less non-zero coefficients for audio still to be recognizable.

Is it inherent property of Haar Wavelets or have I messed up somewhere and FFT should perform equally well in this regard?

• Have you used a window function (other than rectangular) with FFT? – Olli Niemitalo Dec 28 '16 at 13:01
• yes, HammingWindow – Anton Dec 28 '16 at 13:35
• Your question has beeen answered. Do not hesitate to vote for the useful ones and accept the most suitable – Laurent Duval Feb 9 '17 at 17:25

For some non-stationary 1D signals, containing sudden changes, or a lot of noise, wavelets can have a close to optimal performance. Here, by wavelets I mean short oscillating shapes spanning several frequency ranges or scales. Wavelets are somehow better than Fourier to that respect, as they can deal with peicewise regular + jumping signals.

However, this covers a huge range of possibilities for continuous and discrete tools.

Hence, I am confused with your "Haar Wavelets vs STFT" title. Haar wavelets can be orthogonal, STFT very redundant. So one cannot compare them directly in terms of sparsity and quality of approximation.

I will thus hypothesize that you performed a Hamming window of some audio signal frame of length $L$. Then applied either an FFT or an orthogonal Haar discrete wavelet transform on the result. Then performed a nonlinear approximation by keeping the $N$th largest coefficients, with $L \ll N$.

The result you evoke is a bit surprising to me, and I am a wavelet supporter: it seems a little too good for Haar wavelets. Haar wavelets are often not the best fit for audio, and few audio coders use wavelets. What makes me wondering about your results is:

• the length of your frame, or is the signal sufficiently nonstationary to win by KO on Fourier?
• "starting from low to high energies": I have problem understanding what it means with wavelets. Are you performing a fair treatment on Fourier ?
• magnitude and complex symmetry: Fourier coefficients are usually "doubled" on real signals. Did you take that into account? Are you sure you have reconstructed Fourier coefficient fully, and not from magnitude only?

All in all, a sketch of your code could help us deciphering the results.