- Read the wave-file using audioread(filename)
- Find the spectrogram of the signal with the desired "overlap", "number of frequency bins(nfft)" and the window type using spectrogram(x)
- Window length and the overlap can be calculated as per the requirement.
- Once the spectrogram is obtain, the spectrogram on bark-scale can be obtained using hz2bark(hz)
Spectrogram computed on the Bark scale
조회 수: 9 (최근 30일)
이전 댓글 표시
I want to generate a spectrogram for a given song, segmented at 1 second intervals, with 50% overlap.
I want to reproduce the results of a paper, which suggests computing the spectrogram on the 21 first Bark bands. My code is as follows, and I am not sure if it is correct. I would appreciate feedback on the process. I use 1:7700, so I can obtain a matrix with 7700 rows, which I can then segment into each individual bin. But I am not sure if the result returned makes sense.
[sounds,freqs]=audioread(file_name);
windowsize=floor(freqs); %if i want to change the windowsize to 0.5sec, I can divide by 2. So floor here is not required
%you can start from 0 or 20.
BandBarks = [20, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700];
Spectro=spectrogram(sounds,hann(windowsize),floor(0.5*windowsize),1:7700);
%OR should I use
Spectro=spectrogram(sounds,hann(windowsize),floor(0.5*windowsize),1:7700,freqs);
댓글 수: 0
답변 (1개)
Nayan
2023년 4월 11일
편집: Nayan
2023년 4월 11일
Hi
As I understand, you need to find the spectrogram on the bark-scale. This can be achieved by the following steps :-
I would suggest you to take help of the following code snippet and the libraries mentioned above :-
N = 1024;
n = 0:N-1;
[x, fs] = audioread('farspeech.wav');
duration = length(x)/fs;
t = linspace(0, duration, length(x));
plot(t, x);
xlabel('Time (s)');
ylabel('Amplitude');
window = hann(256);
noverlap = 128; % can be adjusted as needed
nfft = 512; % can be adjusted as needed
spectrogram(x, window, noverlap, nfft, fs, 'yaxis');
[s, f, t] = spectrogram(x, window, noverlap, nfft, fs, 'yaxis');
f_bark = hz2bark(f);
imagesc(t, f_bark, 20*log10(abs(s)));
axis xy;
xlabel('Time (s)');
ylabel('Bark');
colorbar;
You can also obtain spectrogram with different scales directly by using simulink block. I would suggest you to go through the following link for you benifit and interest.
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!