Adjusting spectrogram of piano sound
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to do 'inveerse engineering' with piano sound and find sequence of frequencies in it. I have to use spectrogram() and adjust parameters but my problem is that I don't know how. Here's what I've already done:
[y,fs] = audioread('piano.wav');
%sound(y,fs)
f = 0:1:0.5*fs;
Nx = length(y);
n= 0:Nx-1;
dt = 1/fs;
t = dt*n;
figure(1)
plot(t,y)
figure(2)
spectrogram(y,512,512-64,f,fs); %
But it's only a guess, I don't have any idea how to adjust window length or shift and also in my task there's: "FFT length (zero padding)".
Can somebody explain how to manage these requirements?
2 Kommentare
Michael Soskind
am 11 Jun. 2020
Hi Sylwia,
In general, this is the correct method. If you would like a bit more of an explanation of what is meant by some of the values that you have been working with I can only provide as much as the spectrogram documentation.
However, there may be some insight to offer. In general, the 512 and 512-64 that you use are good values to have, as they determine how quickly the code will run, and how many short time Fourier transforms (STFTs) will take place.
For anaysis, I recommend extracting the STFT, with the following command:
[s,f,t] = spectrogram(y,512,512-64,f,fs); %
By looking at s, you can extract a frequency or set of frequencies at the time value determined by the STFT performed by spectogram. In general, this is done by filtering the length defined, and then the step size in time is related to the overlap of the STFT. The smaller the overlap, the fewer calculations, but the fewer time samples you have. You may be able to get away with quite large gaps if your piano sample is quite a slow piece, as the STFT simply needs a few samples that are well timed to extract the primary frequencies in the audio sample.
Not sure if that helps at all, but hopefully that clarifies a bit the use of the windows and overlaps in the analysis and re-engineering of audio samples,
Michael
Michael Soskind
am 11 Jun. 2020
Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!