9

I'm trying to do real-time pitch detection using C++. I'm testing some code from performous (http://performous.org/), because everything else hasn't worked for me. I know for sure that this works, but i just cant get it to work. I've been trying this for a few weeks now, and I haven't been able to get any pitch detection code working.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Niall
  • 757
  • 3
  • 9
  • 17
  • 6
    "can't get to work" means ??? (won't compile? won't run? turns your computer into a ball of flame?) – Jason S Sep 23 '09 at 16:08
  • it compiles, but outputs frequencies running from 0 to about 1024 – Niall Sep 23 '09 at 16:13
  • and what's wrong with that? Middle C is 440 Hz, so that range seems reasonable if sampling your mic. What frequencys do you expect? – AShelly Sep 23 '09 at 19:06
  • Take a look at the [FMOD library](http://www.fmod.org/). One of their samples does realtime pitch detection IIRC. The library is free for open source, and moderately priced for commercial applications. Even if you don't want to use the library, perhaps it will provide some insight. – Ryan Emerle Sep 23 '09 at 17:01

3 Answers3

11

Instead of using input from the mic, you should create data of a known single frequency and run that through the program and see if it gets you the correct result. Then you can add harmonics to it and see if that works. Real world data is just too variable for initial testing.

Dan Hook
  • 6,769
  • 7
  • 35
  • 52
1

Performous audio code has some optimizations, frequency limits and heuristics that make it only suitable for singing (and other similar tones). The optimal range is around 80-600 Hz.

Tronic
  • 10,250
  • 2
  • 41
  • 53
1

C/C++/Obj-C Real-time algorithm to ascertain Note (not Pitch) from Vocal Input

Check the accepted answer on this link.

I have scoured SO for an answer to this problem, and this is the most useful resource I have found.

It appears that Performous uses this algorithm, but it's hard to make out from the Performous code

EDIT: I have finally managed a working solution. e-mail me if interested sunfish|gmail|c0m

Community
  • 1
  • 1
P i
  • 29,020
  • 36
  • 159
  • 267