Digital System Processing (Audio Processing)

I'm working on project to find the piano notes of a song. From the time domain graph, I was able to find the correct frequency where the note is present. I used: [S,F,T] = spectrogram (y, 512 , [] , 512, fs); to get the frequency of my song. But the size of the matrix S is too big and I cannot find the correcr frequency row. Can someone please help me understand how to get the correct row of frequency knowing the time?
Thanks

2 件のコメント

Mathieu NOE
Mathieu NOE 2020 年 12 月 9 日
hello
do you have a audio (wav) file to share ?
Lina Ngoopos
Lina Ngoopos 2020 年 12 月 9 日
Hello! Unfortunately, the audio that I have is the format .m4a, I cannot attached it. My problem is understanding how to extract the frequency from the spectrogram array knowing the time. Is there a way you can explan this to me without me sending the audio? You can use any .wav files you can have. It is the concept that I'm trying to understand

サインインしてコメントする。

 採用された回答

Elimelech Schreiber
Elimelech Schreiber 2020 年 12 月 9 日
編集済み: Elimelech Schreiber 2020 年 12 月 9 日

0 投票

If you have a specific time, then you should probably find the maximum frequency at that time, in the matrix S.
Each column in the matrix S contains the magnitudes of all the processed frequencies at a certain timestep.
e.g. Lets say t=1.13[sec].
first find the correct time index in T, which index 'i' yields T[i] =~ t (= 1.13) :
[~, i ] = min(abs(T - t))
lets say you've found i = 11,
now find the INDEX of the maximum magnitude in the i-th column of S:
[~, maxIdx] = max(S(:, i) ) % S(:, i)- The i-th column, containing freq. magnitudes at timestep i
finaly convert that index into a frequency, using F:
maxFrequency = F[maxIdx];

5 件のコメント

Lina Ngoopos
Lina Ngoopos 2020 年 12 月 9 日
Thank you very much for your response! So, if I understand well i is the total number of column I have in the S array? Let say if S is 257x2761, then i = 2761. Am i correct?
Elimelech Schreiber
Elimelech Schreiber 2020 年 12 月 9 日
編集済み: Elimelech Schreiber 2020 年 12 月 9 日
no, i is in the interval: 0 <= i <= 2761.
i is the time index you should find, that matches the time you've found in the time domain.
So, back to my example, say you are interested in the note frequency playing at time t=1.13[sec].
You need to find which column of S coresponds to that time. one way of doing this is by lookig for the closest time in the time vector: T.
Throughout this answer i am using S,F,T from your question: [S,F,T] = spectrogram (y, 512 , [] , 512, fs);
Lina Ngoopos
Lina Ngoopos 2020 年 12 月 9 日
編集済み: Lina Ngoopos 2020 年 12 月 9 日
I'm having a little trouble following you on the i. I, totally, understand the process you are doing but it's not working on my code. I was able to find the column of S that contained my time. So, should I relpace i by the value I found? Let say the correct column of t=1.3 sec is 255. So, i would be replaced by 255? If so, I did that but MATLAB doesn't like this synthax: [~, 255 ] = min(abs(T - t)), it's giving me an error?
Elimelech Schreiber
Elimelech Schreiber 2020 年 12 月 9 日
Yes, replace it if you have already found it.
And skip that step: that line is meant to find the correct index.
Lina Ngoopos
Lina Ngoopos 2020 年 12 月 9 日
Thank you very much! I appreciate the help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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