aubio / aubio

a library for audio and music analysis
https://aubio.org
GNU General Public License v3.0
3.29k stars 376 forks source link

How to get notes in accurate Hz in Python with aubio.notes? #104

Open danielweinmann opened 7 years ago

danielweinmann commented 7 years ago

Hi there! Thanks for the great library :D

I'm having trouble finding out how to get the accurate frequency in Hz of a note from aubio.notes in Python.

In the example, notes_o = notes("default", win_s, hop_s, samplerate) returns the notes in MIDI frequencies, but for the closest chromatic note, not for the accurate pitch (as I can clearly see when I run miditofreq on each note).

Is there a way to get the actual pitch of each note, in Hz, instead of the closest chromatic note in MIDI frequency?

Thanks o/

piem commented 7 years ago

Hello @danielweinmann,

The note algorithm is rather simple for now: the midi note number is rounded to the closest integer value. You can experiment micro-tonal notes by increasing the parameter AUBIO_DEFAULT_CENT_PRECISION in src/notes/notes.c.

Let us know if this is useful to you, we could make this a modifiable parameter.

danielweinmann commented 7 years ago

Hello, @piem,

This wouldn't help me, since I'm working on a software that gives feedback on the user's singing ability. But I ended up making it work with a simple algorithm to detect distinct notes from the results of the pitch function.

In case you're curious, the source code is available at https://github.com/danielweinmann/melody_parser

Thanks again!

piem commented 7 years ago

hello @danielweinmann,

Awesome, thank you for that. Do you have a live instance of it? We will be announcing something similar soon. If you are interested to join efforts, please contact us by email!

I'm curious: how do you group notes? I see you round the frequency to the closest midi note number, but I don't see how you determine a more precise frequency value.

danielweinmann commented 7 years ago

Hey, @piem! I'm definitely interested in joining efforts.

I'm not a Python programmer, neither understand much about PDA, but I'm a seasoned programmer and a student of many singing methods. I'm creating an iOS and Android app that is intended to be a social network to help people learn how to sing through tools + community effort.

Right now, I created a ridiculously simple algorithm, yet to be proof-tested, that group pitches together by identifying the longest distinct notes. It is expressed in this method: https://github.com/danielweinmann/melody_parser/blob/master/note.py#L37

Then, after that, I group the small pitches for each note here: https://github.com/danielweinmann/melody_parser/blob/master/melody.py#L5

It's almost silly, but it produced some very interesting (though not 100% accurate) results. I have the service live on https://melodyparser.herokuapp.com. You just have to POST to /with a file param in form data format (file uploading pattern).

Here you can see an example result. it is the result for this file.

jlearman commented 5 months ago

I believe this issue can be closed, because (running demo_pitch.py) I see it returns float values for pitches.