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

Fix low range pitch detection of YIN detector #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JacobJT
Copy link

@JacobJT JacobJT commented Sep 11, 2019

Fixes #24

@@ -39,7 +39,6 @@ module.exports = function(config = {}) {
// Set buffer size to the highest power of two below the provided buffer's length.
let bufferSize;
for (bufferSize = 1; bufferSize < float32AudioBuffer.length; bufferSize *= 2);
bufferSize /= 2;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done below as well with const yinBufferLength = bufferSize / 2;

While I couldn't test too low, this did not seem to cause any issues for me and I was immediately able to detect the low E.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this makes the comment on line 39 incorrect, unfortunately, and that comment came from the paper, so I'm hesitant to make this change

@JacobJT
Copy link
Author

JacobJT commented Sep 11, 2019

I looked at the time difference, and this added significant time to YIN tests. As mentioned in PR, I don't think it strictly needs to be doubled since it gets really close to being able to detect that E. It can detect the F, gets within a few Hz. The added time of creating the extra elements of the array + checking them when there's no pitch seems to be hurting. Looking at the algorithm, I don't see anything that makes it strictly necessary to be a power of 2 in size.

@marksyzm
Copy link

Looks like you'll have to update all the tests for a change like this - it somewhat affects the accuracy

@chrisspen
Copy link

It would be nice if this were merged. I'm having this issue as well.

@chrisspen
Copy link

@JacobJT Btw, thanks for the fix. I've tested this and it seems to work pretty well. Previously, nothing at D2 or below was detected at all for me. Now it reliably detects D2. It still has trouble with A1, which is usually thinks is A2, but that's still better than detecting nothing!

I see no regressions with detection at higher pitches.

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

Successfully merging this pull request may close these issues.

Doesn't detect E string on bass
4 participants