Old 08-25-2019, 02:08 PM   #1
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default What algorithm does ReaTune use to detect pitch?

I'm writing a pitch correction editor script so I am interested in very accurate and fast pitch detection.

I'm currently using an EEL script derived from here for my pitch detection, which works fairly well, however it takes quite a while to extract the pitch.

ReaTune seems to be able to extract the pitch from long audio files insanely fast. Is this because the algorithm is really fast or is it just that scripts are slow?

It would be nice if there was a way to tap into the way ReaTune does pitch detection, like if there was a way in the API to get the pitch that was super optimized.
Alkamist is offline   Reply With Quote
Old 08-25-2019, 06:07 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

You may have more efficient results using



reaper.GetMediaItemTake_Peaks( take, peakrate, starttime, numchannels, numsamplesperchannel, want_extra_type, buf )


I use it in my audio waveform pack to get pitch:


https://www.extremraym.com/en/downlo...item-waveform/





Here is code snippet:


https://github.com/ReaTeam/ReaScript...20position.lua
X-Raym is offline   Reply With Quote
Old 08-25-2019, 06:57 PM   #3
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by X-Raym View Post
You may have more efficient results using



reaper.GetMediaItemTake_Peaks( take, peakrate, starttime, numchannels, numsamplesperchannel, want_extra_type, buf )


I use it in my audio waveform pack to get pitch:


https://www.extremraym.com/en/downlo...item-waveform/





Here is code snippet:


https://github.com/ReaTeam/ReaScript...20position.lua
Interesting. Thank you for the idea and code for reference! I'll take a look and play around with it as soon as I get the chance.
Alkamist is offline   Reply With Quote
Old 08-25-2019, 09:28 PM   #4
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Cepstrum with modifications, Justin said. I'm sure taking FFT twice will be also fast even from ReaScript even with overlapping.

I personally didn't get good results with it, instead I used modified YIN for PitchEditor, looks slightly better than cepstrum/autocorrelation, it 80% based on link you shared.

Spectral peaks are indeed useful, but it is not a pitch detection.

Last edited by mpl; 08-25-2019 at 09:38 PM.
mpl is offline   Reply With Quote
Old 08-26-2019, 07:11 AM   #5
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by mpl View Post
Cepstrum with modifications, Justin said. I'm sure taking FFT twice will be also fast even from ReaScript even with overlapping.

I personally didn't get good results with it, instead I used modified YIN for PitchEditor, looks slightly better than cepstrum/autocorrelation, it 80% based on link you shared.

Spectral peaks are indeed useful, but it is not a pitch detection.
Thanks for the insight. Your modified code was actually my reference for what I have done so far. It seems to render pitch at about 3x realtime on my processor. It's really not bad, fairly quick and really accurate. It's just that ReaTune seems to do it almost instantly.

Unfortunately I'm really not up to date with spectral approaches to anything. My calculus is super rusty. I'm not so good at reading through math papers and converting to code. Do you happen to have any of your old code of when you tried using it? I'd like to take a look.
Alkamist is offline   Reply With Quote
Old 08-26-2019, 08:11 AM   #6
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by X-Raym View Post
You may have more efficient results using...
I just got around to trying this. It can get frequency almost instantly just like ReaTune, however, it doesn't seem to be very precise. It seems usable, if only there weren't octave shifts everywhere. It gets the octave wrong most of the time, sometimes by two octaves.
Alkamist is offline   Reply With Quote
Old 08-26-2019, 09:45 AM   #7
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Alkamist View Post
I just got around to trying this. It can get frequency almost instantly just like ReaTune, however, it doesn't seem to be very precise. It seems usable, if only there weren't octave shifts everywhere. It gets the octave wrong most of the time, sometimes by two octaves.
The spectral peaks don't measure the fundamental frequency of the signal. (ReaTune uses some other algorithm for the pitch detection.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-26-2019, 12:32 PM   #8
Alkamist
Human being with feelings
 
Join Date: Dec 2011
Posts: 506
Default

Quote:
Originally Posted by Xenakios View Post
The spectral peaks don't measure the fundamental frequency of the signal. (ReaTune uses some other algorithm for the pitch detection.)
I see. I suppose that makes sense. I'll have to do some reading and see if I can figure out how the Cepstrum algorithm works.
Alkamist is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.