-
Notifications
You must be signed in to change notification settings - Fork 53
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
Half step down while using AMDF #40
Comments
I'm getting a frequency of 404Hz for an A4, both on my guitar and even when playing your test note 440_square. Using the same method as the original post. |
I have a guess here. Digital audio always has a sampling rate. This refers to the number of times per second that the amplitude of the sound wave is recorded. The most common sampling rate for digital audio is 44.1khz (44,100 samples per second). However, the second most common rate is 48khz. If you take audio recorded at 48khz, and read it with a program that is assuming it is 44.1khz, then you'll be playing it back at 91.825% speed. Slowed-down audio has a lower pitch, at the same ratio it was slowed down. Doing the math here, 0.91825 * 440 is 404.25. That would explain your discrepancy perfectly. |
As a solution, try initializing your detector with a const detectPitch = Pitchfinder.AMDF({sampleRate: 48000}); |
Genius! You were exactly right. Now it measures frequencies perfectly. Don't know why I have it set to 48k, but checked my settings and there it was. Thank you! To anyone using Web Audio you can get the sample rate from the context: https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/sampleRate |
It might be useful to update the examples to use that code to set the sampling rate... |
I am using the code described in the README to input a stream of WebAudio Buffer from a stream like this:
The function to convert pitch to note is something I found online and to be candid I don't understand the logic (I do get the math) and I do get the octave system and the standard guitar turning being in A440 Hz
The console shows the note half step down from what it is. I have cross checked by playing a note from virutal, real instruments as well as another app on Android.
I tried using YIN but that was showing all sorts of wild results, even in silence it was coming out to be arbitrary notes in Octave 10.
The text was updated successfully, but these errors were encountered: