How do I apply a wavelet decomposition filter?

4 ビュー (過去 30 日間)
studentmatlaber
studentmatlaber 2022 年 5 月 16 日
回答済み: Hari 2023 年 10 月 3 日
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,:));

回答 (1 件)

Hari
Hari 2023 年 10 月 3 日
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!

カテゴリ

Help Center および File ExchangeSignal Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by