Draw f0 on cqt's image
See original GitHub issueDraw f0 on cqt’s image
Draw f0 on cqt’s image for users to read note’s name directly
Is your feature request related to a problem? Please describe.
I’m always frustrated when trying to draw a f0 line into a cqt image.
I use code1
to draw cqt_note - time image. I find it useful because I can read the name of the notes directly from y-axis.
# code1
y, sr = librosa.load("F:\\Script\\Voice\\music\\human.wav", duration=15.0, sr=None)
C = librosa.cqt(y=y, sr=sr)
C_db = librosa.amplitude_to_db(np.abs(C), ref=np.max)
fig, ax = plt.subplots()
img = librosa.display.specshow(C_db, sr=sr, y_axis='cqt_note', x_axis='time', ax=ax, cmap='gray_r')
fig.colorbar(img, ax=ax, format='%+2.0f dB')
plt.show()
But, the pyin didn’t suppprt it, I can draw f0 line by log y-axis in ‘ferequency-time’ image, but I can not directly read out the note’s name on the y-axis.
Describe the solution you’d like
Provide a new function[let’s call itnote_0()
]. and the output could be added to the cqt’s ‘ax’ object, just like drawing pyin’s output on ‘db-time’ image
Describe alternatives you’ve considered
I tried to slove it in a physical way. I set all the figures to a certain size, then, mark the notes in one picture’s y-axis by a pen.
Then, I cut it off, and use this piece of paper as a ruler, but it is very funny, and I have to copy the ‘ruler’ a lot of times.😢
Additional context
I want to get a <u>‘line’</u> of f0, not a number of rectangle(s) filled by a color.
this function is very useful for musicians.
Thanks for your reading
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@lostanlen Thanks for your answer. But Bmcfee showed me how to achieve my goal. https://github.com/librosa/librosa/issues/1227#issuecomment-678241271 Issue close. By the way, I think the code should be added to the document
@unbadfish it’s unclear what you’re asking. If what you want is to overlay a fundamental frequency curve on top of a CQT image, specshow and plot will do that in two lines. If what you want is to be able to name pitches extracted by pYIN, then
hz_to_note
is your friend: https://librosa.org/doc/latest/generated/librosa.hz_to_note.html