Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pitch detection is inaccurate #11

Open
j-funk opened this issue Aug 7, 2015 · 3 comments
Open

Pitch detection is inaccurate #11

j-funk opened this issue Aug 7, 2015 · 3 comments

Comments

@j-funk
Copy link

j-funk commented Aug 7, 2015

Not too sure about the maths for the pitch detection portion, but I decided to generate various oscillators to test the pitch. I noticed that most of the notes are not detected accurately even when generating an oscillator at a fixed frequency (even the live instance is off by a cent for the default A4).

When you reach B6 it is quite drastic with pitch being detected incorrectly by 49 cents (flat).

sourceNode.frequency.value = 1976; // set the oscillator's frequency to B6
pitch_off

var notes = [];
/* C C# D Eb E F F# G G# A Bb B*/
notes[0] = [65.41, 69.30, 73.42, 77.78, 82.41, 87.31, 92.50, 98.00, 103.8, 110.0, 116.5, 123.5]; //2

notes[1] = [130.8, 138.6, 146.8, 155.6, 164.8, 174.6, 185.0, 196.0, 207.7, 220.0, 233.1, 246.9]; //3

notes[2] = [261.6, 277.2, 293.7, 311.1, 329.6, 349.2, 370.0, 392.0, 415.3, 440.0, 466.2, 493.9]; //4

notes[3] = [523.3, 554.4, 587.3, 622.3, 659.3, 698.5, 740.0, 784.0, 830.6, 880.0, 932.3, 987.8]; //5

notes[4] = [1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976]; //6

@Pranoy1c
Copy link

Pranoy1c commented Feb 1, 2018

I agree with j-funk. Unfortunately, I found this to be extremely inaccurate with my Piano at least. Pressing the A4 (440) shows A4 for a tiny millisecond but then jumps around to E and then disappears. Testing others notes (C4, F4 etc) don't even show correctly and just jump around. So I would not recommend this.

@Tymski
Copy link

Tymski commented May 13, 2018

This is as consistent as tuning my guitar to a random number generator.

@MrRedBeard
Copy link

MrRedBeard commented Dec 3, 2018

@j-funk @Pranoy1c @Tymski @cwilso @webnard

If you comment out return sampleRate/(best_offset+(8*shift)) under else if (foundGoodCorrelation) the returned frequency is way more stable and accurate at least for notes closer to 440.

} else if (foundGoodCorrelation) { // short-circuit - we found a good correlation, then a bad one, so we'd just be seeing copies from here.

//return sampleRate/(best_offset+(8*shift)); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants