# Pitch recognizer C++ API

**URL:** <https://forum.juce.com/t/pitch-recognizer-c-api/6603>\
**Category:** Useful Tools and Components\
**Created:** [March 21, 2011, 8:34am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603 "2011-03-21T08:34:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbop](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tbop](https://forum.juce.com/u/tbop)\
**Post date:** [March 21, 2011, 8:34am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/1 "2011-03-21T08:34:34Z")

</div>

Hi there,

I’m looking for a straightforward pitch recognizer C++ API (like every real tuner do). Does anybody here know how to find this kind of API?

What I would like to do is basically extract the fundamental frequency from a given wave sample (in real-time), then convert it to the closest pitched note, and finally into a proper NoteOn MIDI signal.

I already tried to Google it, but I haven’t found anything so far.

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![tbop](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tbop](https://forum.juce.com/u/tbop)\
**Post date:** [March 21, 2011, 9:48am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/2 "2011-03-21T09:48:04Z")

</div>

Ok I think I finally found out some interesting stuffs here:

[http://aubio.org/doc/files.html](http://aubio.org/doc/files.html)

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 21, 2011, 2:07pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/3 "2011-03-21T14:07:44Z")

</div>

Hey, how’s the beat detector in that lib?

---

<div class="post-metadata">

**Author:** ![tbop](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tbop](https://forum.juce.com/u/tbop)\
**Post date:** [March 21, 2011, 2:10pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/4 "2011-03-21T14:10:13Z")

</div>

I have no idea unfortunately, but the lib sounds fine, you shouldn’t have any issues.

---

<div class="post-metadata">

**Author:** ![symfonysid](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@symfonysid](https://forum.juce.com/u/symfonysid)\
**Post date:** [September 21, 2011, 11:29pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/5 "2011-09-21T23:29:01Z")

</div>

Aubio’s beat tracking was tested in the 2006 Mirex. Check the results for Brossier: [http://www.music-ir.org/mirex/wiki/2006:Audio\_Beat\_Tracking\_Results](http://www.music-ir.org/mirex/wiki/2006:Audio_Beat_Tracking_Results)

---

<div class="post-metadata">

**Author:** ![forart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/forart/32/8467_2.png) [@forart](https://forum.juce.com/u/forart)\
**Post date:** [November 16, 2011, 12:06pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/6 "2011-11-16T12:06:47Z")

</div>

I believe you could “grab” it (along with, why not, other interesting features) from [Mixx](http://www.mixxx.org/):

[quote]Full Feature List  
[list]  
[_]Cross-platform (Windows XP/Vista/7, Mac OS X, Linux)[/_]  
[_]Free and open source (GPL v2)[/_]  
[_]Parallel waveform displays[/_]  
[_]Waveform summaries[/_]  
[_]MP3, OGG, WAVE, and FLAC playback[/_]  
[_]Extra playback formats through plugins[/_]  
[_]Fast, database-powered library[/_]  
[_]Shoutcast and Icecast broadcasting[/_]  
[_]Automatic crossfading with Auto DJ[/_]  
[_]Crates and playlists[/_]  
[_]Reads iTunes and Rhythmbox libraries[/_]  
[_]Pitch-independent time stretch (key lock)[/_]  
[_]Vinyl emulation[/_]  
[_]Hot cues[/_]  
[_]Looping[/_]  
[_]Wave recording[/_]  
[_][color=#FF0000]BPM detection and estimation[/color][/_]  
[_][color=#FF0000]Bulk BPM analysis[/color][/_]  
[_]Multichannel soundcard support (playback and capture)[/_]  
[_]Multiple soundcard support[/_]  
[_]Adjustable EQ shelves[/_]  
[_]Crossfader curve control[/_]  
[_]Skinnable interface with extra skins bundled[/_]  
[_]Advanced MIDI scripting engine[/_]  
[_]Multiple simultaneous MIDI controllers[/_]  
[_]Adjustable pitch range[/_]  
[_]Ramping pitchbend controls[/_]  
[_]Multi-core CPU support[/_]  
[_]24-bit/96000 Hz playback and capture[/_]  
[_]Crystal clear audio[/_]  
[_]Hardware video acceleration[/_]  
[_]…[/_][/list][/quote]

BTW, as I _always_ suggest, collaboration is better than “stealing” !

---

<div class="post-metadata">

**Author:** ![AaronLeese](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aaronleese/32/624_2.png) [@AaronLeese](https://forum.juce.com/u/AaronLeese)\
**Post date:** [April 18, 2012, 9:26pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/7 "2012-04-18T21:26:06Z")

</div>

Also - if you want a quick and easy one that uses FFT peak (on mac only - accelerate framework), take a look here:

[http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8297](http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8297)

---

<div class="post-metadata">

**Author:** ![99bits](https://avatars.discourse-cdn.com/v4/letter/9/57b2e6/32.png) [@99bits](https://forum.juce.com/u/99bits)\
**Post date:** [September 5, 2016, 7:45am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/8 "2016-09-05T07:45:07Z")

</div>

Has anyone found a good solution for this ?

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [September 5, 2016, 8:19am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/9 "2016-09-05T08:19:19Z")

</div>

I put some pitch detection code here, that I use in the app I am currently working on: [https://github.com/adamski/PitchDetector](https://github.com/adamski/PitchDetector)

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [September 5, 2016, 9:15am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/10 "2016-09-05T09:15:41Z")

</div>

Adam that YIN stuff is the best solution around I seem to remember??

PS. I don’t think FFT would be a good solution here. Presumably it’s woefully inaccurate for low pitches … (actually just found some analysis of how inaccurate: [http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html](http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html))

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [September 5, 2016, 11:45am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/11 "2016-09-05T11:45:48Z")

</div>

Yes FFT / frequency-domain based pitch detection is generally much faster than time-domain, but tends to be less accurate. Peak picking FFT is the least accurate, and can completely miss the fundamental frequency.

In my tests, I found the the McLeod Pitch Method faster and more accurate than YIN.

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [September 5, 2016, 12:12pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/12 "2016-09-05T12:12:18Z")

</div>

How would you even do accurate FFT anyway? Even given a steady pitch, if the tone you’re dealing with is doesn’t fit nicely into a bin is there any way of working out what the pitch actually was?

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [September 5, 2016, 12:29pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/13 "2016-09-05T12:29:42Z")

</div>

> [@bazrush](#):
>
> if the tone you’re dealing with is doesn’t fit nicely into a bin is there any way of working out what the pitch actually was?

doing the phase difference at that bin between 2 successive fft

> <https://stackoverflow.com/questions/4633203/extracting-precise-frequencies-from-fft-bins-using-phase-change-between-frames>

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [September 5, 2016, 12:37pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/14 "2016-09-05T12:37:07Z")

</div>

Oh brilliant. That’s super helpful…

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [September 5, 2016, 1:51pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/15 "2016-09-05T13:51:30Z")

</div>

Here is an FFT-based pitch detection method in a JUCE plugin, using “Non Linear Least Square Estimator”: [https://github.com/junilyd/Pitch-Estimator-Plugin](https://github.com/junilyd/Pitch-Estimator-Plugin)

I’ve been meaning to borrow the code and try it out in my project…

---

<div class="post-metadata">

**Author:** ![seanwayland](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/seanwayland/32/3192_2.png) [@seanwayland](https://forum.juce.com/u/seanwayland)\
**Post date:** [December 27, 2017, 3:53am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/16 "2017-12-27T03:53:01Z")

</div>

Hi all,  
I am looking into all this stuff.  
A friend asked me to build a bass synth VST for him.  
I made a simple application using PYO that used Yin and an envelope follower.  
It worked pretty well. I had to mess around to get it to work.  
A buffersize of 1024 with a window size of 3072 at 96k seemed to work best but it didn’t work at all below 50hz ( ie the bottom 4 notes on the low E string weren’t recognized. I wonder if the MPM method would work better that low. I guess the lower down you get the bigger the errors get. A couple of HZ is almost a semitone/half-step down there … I set the minimum freq yin was looking for to 10hz and applied a hi pass filter at 1000k … I managed to build a simple sampler in JUCE totally in C++ but getting on of these complicated algorythms to work seems a bit beyond my skills … I wish JUCE would compile PYO properly which was 7 lines of code … All the books I read seem to go from a description of DSP of a sine wave to rocket science. It would be nice if someone could suggest an easy way in. I also want to try and implement a PSOLA algorithm I made easily in JUCE. … Sean

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [December 27, 2017, 4:31am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/17 "2017-12-27T04:31:34Z")

</div>

[http://sites.uci.edu/computermusic/2014/09/22/sigmund-for-pitch-tracking/](http://sites.uci.edu/computermusic/2014/09/22/sigmund-for-pitch-tracking/)

follow the links, and you’ll be taken to the github repo for sigmund. it’s in C…

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [December 28, 2017, 10:25am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/18 "2017-12-28T10:25:40Z")

</div>

You need a much larger buffer size to capture lower frequencies. Try 4096 or 8192 or even larger, depending on your sample rate.

---

<div class="post-metadata">

**Author:** ![seanwayland](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/seanwayland/32/3192_2.png) [@seanwayland](https://forum.juce.com/u/seanwayland)\
**Post date:** [December 28, 2017, 3:01pm UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/19 "2017-12-28T15:01:46Z")

</div>

Thanks Adamski I will try it out. I would think that might add too much  
latency when tracking for a jazz musician to use live.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [December 29, 2017, 6:15am UTC](https://forum.juce.com/t/pitch-recognizer-c-api/6603/20 "2017-12-29T06:15:41Z")

</div>

How do those octave pedals bass players and guitar players use work?

[Next page](https://forum.juce.com/t/pitch-recognizer-c-api/6603.md?page=2)
