How to obtain the same output in spectral descriptors, using frequency and time domain inputs?

1 回表示 (過去 30 日間)
All matlab spectral descriptors as spectralSlope, spectralKurtosis,ect have the choice to use a time domain or a frequency domain input, but I'm unable the get the same (even aproximadetly) result, does anyone knows how to solve this?
Example:
clear;
%load an audio
[x,fs]=audioread('example.wav');
%windowing data
win=round(0.025890625*fs);
over=round(0.01875*fs); % 72%
%Obtain the spectral data
[s, f, t]=spectrogram(...
x,...
hamming(win),...
over,...
win,fs,'yaxis');
slope_normal(:,1)=spectralSlope(x,fs, Window=hamming(win),OverlapLength=over);
slope_spec(:,1)=spectralSlope(s,f);
figure;plot(slope_normal);hold on;plot(slope_sub);

採用された回答

Brian Hemmat
Brian Hemmat 2023 年 6 月 16 日
%% Compare Time-Domain and Frequency-Domain Inputs
[x,fs] = audioread('Counting-16-44p1-mono-15secs.wav');
% Define window and overlap length
windowLength = round(0.025890625*fs);
overlapLength = round(0.01875*fs);
win = hamming(windowLength);
fftLength = windowLength;
% Calculate the power spectrum the same was as the spectral descriptors
[~,f,~,ps] = spectrogram( ...
x, ...
win, ...
overlapLength, ...
fftLength,fs,'yaxis','power','onesided');
% Slope using time domain input
slope_timeDomainInput = spectralSlope(x,fs, ...
Window=win,OverlapLength=overlapLength,SpectrumType='power');
% Slope using frequency domain input
slope_frequencyDomainInput = spectralSlope(ps,f);
figure(1)
plot(slope_timeDomainInput,'ro');hold on
plot(slope_frequencyDomainInput,'b*');hold off
title("Error = " +rms(slope_timeDomainInput - slope_frequencyDomainInput))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by