cwilso / PitchDetect

Pitch detection in Web Audio using autocorrelation
https://cwilso.github.io/PitchDetect/
MIT License
1.31k stars 440 forks source link

Certain Frequencies #5

Closed hellofishy closed 10 years ago

hellofishy commented 10 years ago

Various Frequencies such show the wrong pitch - especially higher frequencies. 880A does shows G - how does one go about fixing this?

cwilso commented 10 years ago

I'd need to debug. A-880 pitch of what?

hellofishy commented 10 years ago

Of a test oscillator so it should be exact. It works for 220 and 440. But random notes in the scales don't work. For example the E below 440 corresponds to a sharp C. This is true with many pitches

On Tue, Jul 1, 2014 at 4:01 PM, Chris Wilson notifications@github.com wrote:

I'd need to debug. A-880 pitch of what?

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47703111.

hellofishy commented 10 years ago

Let me know if you figure it out, really good work though!

On Tue, Jul 1, 2014 at 4:13 PM, Zack Cohen zcohen01@wesleyan.edu wrote:

Of a test oscillator so it should be exact. It works for 220 and 440. But random notes in the scales don't work. For example the E below 440 corresponds to a sharp C. This is true with many pitches

On Tue, Jul 1, 2014 at 4:01 PM, Chris Wilson notifications@github.com wrote:

I'd need to debug. A-880 pitch of what?

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47703111.

cwilso commented 10 years ago

OK, that should fix it. There was some crosstalk with further copies of the waveform, particularly when the waveform EXACTLY matched (modulo aliasing). Should work much better now. Also redeployed to webaudiodemos.appspot.com.

hellofishy commented 10 years ago

Great! It works a ton better. Still seems to be a few cents off. 440A reads as 441hz and 3cents off. 880A reads 882hz with 3 cents off aswell. Each note seems to be a few cents off. I don' t know if the algorithm you use is an approximation one but just letting you know.

On Tue, Jul 1, 2014 at 6:37 PM, Chris Wilson notifications@github.com wrote:

OK, that should fix it. There was some crosstalk with further copies of the waveform, particularly when the waveform EXACTLY matched (modulo aliasing). Should work much better now. Also redeployed to webaudiodemos.appspot.com.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47717472.

hellofishy commented 10 years ago

Im running a test oscillator through so it should be exact

On Wed, Jul 2, 2014 at 10:26 AM, Zack Cohen zcohen01@wesleyan.edu wrote:

Great! It works a ton better. Still seems to be a few cents off. 440A reads as 441hz and 3cents off. 880A reads 882hz with 3 cents off aswell. Each note seems to be a few cents off. I don' t know if the algorithm you use is an approximation one but just letting you know.

On Tue, Jul 1, 2014 at 6:37 PM, Chris Wilson notifications@github.com wrote:

OK, that should fix it. There was some crosstalk with further copies of the waveform, particularly when the waveform EXACTLY matched (modulo aliasing). Should work much better now. Also redeployed to webaudiodemos.appspot.com.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47717472.

cwilso commented 10 years ago

It's actually that I'm NOT approximating, that is, I'm not coping with the anti-aliasing. I'm playing around with a tweak that should help that by approximating the difference, but it's still going to have errors - the algorithm isn't perfect, and as the pitches get higher and higher you need to approximate quite a bit. (The difference in cycle length between 880Hz and 881Hz is 0.05 SAMPLES - so the interpolation between "best matches" becomes quite important.)

Keep in mind we're going well into the world of analysis; you can't expect, necessarily, that just because you're using a test oscillator you're going to get back PRECISELY what you put into it, because this is something like doing image analysis. The aliasing of going in to the time domain and coming back out will cause some noise.

On Wed, Jul 2, 2014 at 7:26 AM, zcohen01 notifications@github.com wrote:

Im running a test oscillator through so it should be exact

On Wed, Jul 2, 2014 at 10:26 AM, Zack Cohen zcohen01@wesleyan.edu wrote:

Great! It works a ton better. Still seems to be a few cents off. 440A reads as 441hz and 3cents off. 880A reads 882hz with 3 cents off aswell. Each note seems to be a few cents off. I don' t know if the algorithm you use is an approximation one but just letting you know.

On Tue, Jul 1, 2014 at 6:37 PM, Chris Wilson notifications@github.com wrote:

OK, that should fix it. There was some crosstalk with further copies of the waveform, particularly when the waveform EXACTLY matched (modulo aliasing). Should work much better now. Also redeployed to webaudiodemos.appspot.com.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47717472.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47782551.

hellofishy commented 10 years ago

Yeah, understandably.

Great Job! I have been playing with it a bit.

Now I am just trying to figure out how to get my audio to pick up an acoustic guitar and not spazz out and default to F. I think it may be picking up too much room frequency. Oh well.

Thanks for helping my understanding of tuners

On Wed, Jul 2, 2014 at 12:01 PM, Chris Wilson notifications@github.com wrote:

It's actually that I'm NOT approximating, that is, I'm not coping with the anti-aliasing. I'm playing around with a tweak that should help that by approximating the difference, but it's still going to have errors - the algorithm isn't perfect, and as the pitches get higher and higher you need to approximate quite a bit. (The difference in cycle length between 880Hz and 881Hz is 0.05 SAMPLES - so the interpolation between "best matches" becomes quite important.)

Keep in mind we're going well into the world of analysis; you can't expect, necessarily, that just because you're using a test oscillator you're going to get back PRECISELY what you put into it, because this is something like doing image analysis. The aliasing of going in to the time domain and coming back out will cause some noise.

On Wed, Jul 2, 2014 at 7:26 AM, zcohen01 notifications@github.com wrote:

Im running a test oscillator through so it should be exact

On Wed, Jul 2, 2014 at 10:26 AM, Zack Cohen zcohen01@wesleyan.edu wrote:

Great! It works a ton better. Still seems to be a few cents off. 440A reads as 441hz and 3cents off. 880A reads 882hz with 3 cents off aswell. Each note seems to be a few cents off. I don' t know if the algorithm you use is an approximation one but just letting you know.

On Tue, Jul 1, 2014 at 6:37 PM, Chris Wilson notifications@github.com

wrote:

OK, that should fix it. There was some crosstalk with further copies of the waveform, particularly when the waveform EXACTLY matched (modulo aliasing). Should work much better now. Also redeployed to webaudiodemos.appspot.com.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47717472.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47782551.

— Reply to this email directly or view it on GitHub https://github.com/cwilso/PitchDetect/issues/5#issuecomment-47795909.