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

Doesn't detect E string on bass #24

Open
JacobJT opened this issue Sep 10, 2019 · 14 comments · May be fixed by #26
Open

Doesn't detect E string on bass #24

JacobJT opened this issue Sep 10, 2019 · 14 comments · May be fixed by #26

Comments

@JacobJT
Copy link

JacobJT commented Sep 10, 2019

It seems that this stops at 40hz, it detects the F1 note on Bass just fine.

I'll be trying to dive in and see if I can figure out where this minimum threshold is coming from, but figured I'd post the issue to see if it's been spotted / you can give some advice on where to look.

Thanks for the tool!

@JacobJT
Copy link
Author

JacobJT commented Sep 10, 2019

I suppose this is because bass is tuned an octave lower than guitar?
https://en.wikipedia.org/wiki/Bass_guitar_tuning

So I assume the math was set up for guitar specifically. I want to use it for guitar and bass, so I'll probably implement a switch to select the instrument.

@peterkhayes
Copy link
Owner

I didn't specifically set any thresholds for guitar or any other instrument. However, it's totally possible that the algorithms break down at low enough frequencies. Can you verify that the error occurs for all of the different algorithms?

@JacobJT
Copy link
Author

JacobJT commented Sep 10, 2019

I actually couldn't get the ones other than YIN to work. I forked https://github.com/qiuxiang/react-native-tuner, and was playing around with modifying it.

What I did discover was removing line 46 bufferSize /= 2; from yin.js did the trick, and doesn't seem to have broken anything. I noticed that you were dividing again when setting yinBufferLength again below, and then bufferLength wasn't used again. E string is detected just fine now.

It functionally shouldn't do anything but widen the margin of pitches on the lower end, though tbh doubling was a bit unnecessary, it shouldn't have needed to be increased by that much since it picked up that F note.

It made the buffer length go from 512 to 1024. I do not know what would happen if I hit much lower notes, can only go so low on my instrument.

ETA - I'm sure they work, I just couldn't get it figured out. Trying to figure out how the whole thing is pieced together without breaking too much as I go haha.

@peterkhayes
Copy link
Owner

peterkhayes commented Sep 10, 2019

If you want to help, one thing you could do would be to make some more example data from real-world sources (as opposed to digital tones) that I could add to the test suite?

@JacobJT
Copy link
Author

JacobJT commented Sep 10, 2019

I.e. You want recorded samples of an instrument?

@peterkhayes
Copy link
Owner

Yeah, something that reproduces your problem

@JacobJT
Copy link
Author

JacobJT commented Sep 11, 2019

Best I can do at the moment is send you a sound recording of me plucking that E string using my phone, though that is what I was using to pick up the sound in the first place with that tuner app, so I'd imagine it should hit the test case.

Do you happen to have the YIN paper? I followed the link at the top of the file and the PDF link for the YIN paper was a dead link.

@peterkhayes
Copy link
Owner

I don't, sorry :/ I wrote this module awhile ago and haven't done any significant work on it in some time.

@marksyzm
Copy link

Yup, same on mine, usually even around 150hz I have issues. I can do a push request at some point if this fix mentioned works and run it against the tests if you like?

@marksyzm
Copy link

81Hz is best I can get from it on an iPhone via vocals but that may be down to how vocal tones are interpreted by the device

@marksyzm
Copy link

marksyzm commented Apr 24, 2024

Seems to be an issue with Yin type. I'm using pitchy these days which uses the McLeod pitch method:
https://github.com/ianprime0509/pitchy
https://github.com/sevagh/pitch-detection/blob/master/misc/mcleod/README.md

I imagine this should be fairly straightforward to translate into this library?

@peterkhayes Happy for me to do a PR at some point to implement the McLeod method?

@peterkhayes
Copy link
Owner

The Macleod method already exists I think - does it have issues?

https://github.com/peterkhayes/pitchfinder/blob/master/src/detectors/macleod.ts

@marksyzm
Copy link

Ah! I assumed it wasn't there as the readme didn't say so! I'd recommend this for the lower frequency issues people have mentioned

@peterkhayes
Copy link
Owner

Oh good call that it's not included in the readme! I think someone else added it awhile back but probably only did the code?

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 a pull request may close this issue.

3 participants