vadymmarkov / Beethoven

:guitar: A maestro of pitch detection.
https://github.com/vadymmarkov
Other
827 stars 146 forks source link

YIN algorithm, conversion of GuitarTuner example to Swift 3 #39

Closed glaurent closed 8 years ago

glaurent commented 8 years ago

The GuitarTuner example has also been changed to use the YIN algorithm, which, from the testing I've done (electric and acoustic guitar), gives better results than HPS. The correct note is found on the whole range of the instrument.

PCrompton commented 8 years ago

@glaurent @vadymmarkov Thanks for all your work on this! I've been caught up in other projects right now but I'm excited to get back to my project involving this framework. I'd love to contribute to this project at some point but I need to better learn the concepts behind the code. Do you recommend any books or other resources that will help me understand how to parse sound waves? I have a music degree but aspire to get into the software development field professionally, and my dream is to help develop software for musicians and music education. Thanks again!

glaurent commented 8 years ago

@vadymmarkov You're welcome. Thank you for your work on Beethoven, it has helped me immensely too.

As for your question, yes this could be a struct with static func, I'm not sure how much of a difference that would make as far as the language is concerned. I wrote it this way because the original C++ code is written that wayl, and it feels somewhat more natural to me too. I noticed you seem to prefer structs to classes, though :)

BTW, is there a reason to have the TransformStrategy user-settable in the Config class ? As far as I can see, the EstimationStrategy implies a TransformStrategy, so setting it should suffice, and from it the Config would set the TransformStrategy...

glaurent commented 8 years ago

@PCrompton To be honest, what you ask is a bit like asking how to play a Jazz solo having hardly ever touched an instrument. I only have vague recollection of basic signal processing classes from college, I could implement this algorithm only because I had two sample implementations that I could use as reference, and even then there was a whole lot of guesswork. Computing pitch information from a soundwave is actually still a research topic, and pretty hard to do, there's a lot of complex math involved. Get the basics of iOS development first, then you might want to tackle this kind of problems.

vadymmarkov commented 8 years ago

@PCrompton If you are familiar with iOS/Mac development basics, you can read about Core audio and AVFoundation to understand the concepts of working with audio. As for pitch detection, you can start with Wikipedia, there is a list of references that could possibly put you into the right direction. But it's a research topic, as @glaurent said, so normally I'm trying to discover the particular problem by reading different kinds of resources and/or exploring existing implementations in other programming languages.

vadymmarkov commented 8 years ago

@glaurent Yeah, I tend to use structs whenever it's not necessary to have a reference type 😄 I agree with you that the transform strategy is probably redundant in Config. At first I though it could be more flexible, but it seems like transformation and estimation go together anyway, so it might be something that I'd like to refactor.

vadymmarkov commented 8 years ago

I'm going to merge this PR. Will do some refactoring, as I mentioned before, and will make a new release straight after that. Great job @glaurent !

glaurent commented 8 years ago

@vadymmarkov I tend to start from the opposite viewpoint (which AFAIK is more common) : you use classes unless it's necessary or convenient to have a value type. Anyway in this case it doesn't make much of a difference.

Thanks for the merge, you're welcome :). I'll let you close the pullreq.