Manual STFT to obtain spectrogram of an audio signal

9 ビュー (過去 30 日間)
Fernanda Cortes
Fernanda Cortes 2019 年 6 月 14 日
回答済み: UMAIR RASOOL 2020 年 8 月 1 日
Hi, Im trying to obtain the notes that are on an audio signal by using the spectrogram to know the frequencies on it, but i dont know why this code plots me an empty graph. Can sombody help me please.
[x,fs]= audioread("estrellita.mp3");
dt = 1/44100;
t=0:dt:(117204*dt)-dt;
S = zeros(501,117);
windowlength = 1e3;
k = 1;
for jj = 1:117
y = x(k:k+windowlength-1)';
ydft = fft(y).*gausswin(1e3);
S(:,jj) = ydft(1:501);
k = k+windowlength;
end
F = 0:44100/1000:44100/2;
T = 0:(1e3*dt):(117000*dt)-(1e3*dt);
surf(T,F,20*log10(abs(S)),'EdgeColor','none')
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Time');
ylabel('Frequency (Hz)');
set(gca,'YDir','Normal')
xlabel('Time (secs)')
ylabel('Freq (Hz)')
title('Short-time Fourier Transform spectrum')

回答 (1 件)

UMAIR RASOOL
UMAIR RASOOL 2020 年 8 月 1 日
close all
clear all
clc
[y,Fs]=audioread('black_hole.mp3');
Y=fft(y,Fs);
L= (1:length(Y))*Fs/length(Y);
plot(L,abs(Y))
xlabel('Frequency');
ylabel('Amplitude');
title('(Magnitude Spectrum')
windowSize = 256;
windowOverlap = [];
freqRange = 0:Fs;
spectrogram(y(:,1), windowSize, windowOverlap, freqRange, Fs, 'xaxis');

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by