Chromagram with logarithmic compression

188 views
Skip to first unread message

Jason T.

unread,
Apr 15, 2016, 3:40:38 AM4/15/16
to librosa
Hi , I am now doing some works on key detection and I noted that logarithm on pitch then get the chromagram can make the performance better.
The pitch_to_chroma function in Matlab can implement this, so i wonder if there's method i can implement log compression before getting the chromagram by  

librosa.feature.chroma_stft 

the math function is Γ𝛾𝑥≔log(1+𝛾|𝑥|)  
Thanks!!

Dan Ellis

unread,
Apr 15, 2016, 9:29:35 AM4/15/16
to Jason T., librosa
You can pass in a precomputed spectrogram to chroma_stft. So I think you want:

y, sr = librosa.load(wavfilename)
S = np.abs(librosa.stft(y))
chroma = librosa.feature.chroma_stft(S=np.log(1.0 + gain * S), sr=sr)

.. for some value of gain.

DAn.
> --
> You received this message because you are subscribed to the Google Groups
> "librosa" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to librosa+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/librosa/8706ba26-c841-470d-8a6c-cfc2823e9012%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jason T.

unread,
Apr 15, 2016, 11:43:36 AM4/15/16
to librosa, pennil...@gmail.com, dp...@ee.columbia.edu
Thanks ! But as i implemented it , i got a weird chromagram (the second one )which seems lots different from the original one(the first one).
Then i tried to log the chroma(the third picture). I am wondering which method is more reasonable or similar to the Matlab function.
The following picture is a song in D minor.  Thanks !!



Dan Ellis於 2016年4月15日星期五 UTC+8下午9時29分35秒寫道:
Reply all
Reply to author
Forward
0 new messages