How do I apply a wavelet decomposition filter?
2 views (last 30 days)
Show older comments
Hello everyone, I applied stft to audio files. But I want to apply wavelet decomposition filter before stft. However, I couldn't. I would be very happy if you help.
windowLength = 256;
win = hamming(windowLength,"periodic");
overlap = round(0.75 * windowLength);
ffTLength = windowLength;
fs = 16e3;
numFeatures = ffTLength/2 + 1;
numSegments = 8;
inputFs = 16e3;
%% STFT
cleanSTFT = stft(audio,'Window',win,'OverlapLength',overlap,'FFTLength',ffTLength);
cleanSTFT = abs(cleanSTFT(numFeatures-1:end,:));
0 Comments
Answers (1)
Hari
on 3 Oct 2023
Hi Studentmatlaber,
I understand that you have already applied Short-Time Fourier Transform (STFT) to your audio files you are now looking to incorporate a wavelet decomposition filter before performing the STFT.
To apply a wavelet decomposition filter before the STFT, you can use the “wavedec” function in MATLAB's Wavelet Toolbox. This function performs a wavelet decomposition on the audio signal, providing you with the wavelet coefficients at different scales. You can then pass these coefficients to the “stft” function for further processing.
Here is a sample code of how you can apply the wavelet decomposition filter using “wavedec” function.
% Specify the wavelet and level of decomposition
waveletName = 'db4'; % Choose the desired wavelet
level = 5; % Choose the desired level of decomposition
% Apply wavelet decomposition to the audio signal
[c, l] = wavedec(audio, level, waveletName);
% Extract the approximation coefficients at the desired level
approximation = appcoef(c, l, waveletName, level);
The “wavedec” function performs the wavelet decomposition, and “appcoef” extracts the approximation coefficients at the desired level. Then, you can apply the STFT to these approximation coefficients using the “stft” function.
For comprehensive information on the Wavelet Toolbox in MATLAB, refer the documentation:
Refer to the documentation of “wavedec” for more details on performing wavelet decomposition in MATLAB:
To understand how to extract approximation coefficients at a desired level during wavelet decomposition, explore the documentation for “appcoef” in MATLAB:
Hope this helps!
0 Comments
See Also
Categories
Find more on Wavelet Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!