- 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
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Nayan
am 11 Apr. 2023
Bearbeitet: Nayan
am 11 Apr. 2023
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 Kommentare
Siehe auch
Kategorien
Mehr zu Time-Frequency Analysis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!