Closed dalatant closed 4 years ago
I do not think that @cwilso is actively accepting pull requests at this time, seeing that this previous pull request has not yet been accepted. Might I suggest you apply your pull requests here? That is, if your work is applicable, as I know that @markmarijnissen has made quite a few changes himself.
Also, can you make it more descriptive?
Also, I am - I've just been very busy. Will take a look over break.
On Sun, Dec 4, 2016 at 3:30 PM, Dawid Pregel notifications@github.com wrote:
Also, can you make it more descriptive?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cwilso/PitchDetect/pull/23#issuecomment-264740606, or mute the thread https://github.com/notifications/unsubscribe-auth/AAe8eVcAxWRKVM_uHSj5HU0j739mMY8Kks5rE0z9gaJpZM4Ks9Em .
Hello again! I've been really afk.
trimming cuts the edges of the signal so that it starts and ends near zero. This is used to neutralize an inherent instability of the autocorrelation version I use.
autocorrelation is just autocorrelation. The original version.
find first dip / find max are self descriptive.
interpolation is parabolic interpolation. It helps with precision. We suppose that a parabola pass through the three points that comprise the peak. 'a' and 'b' are the unknowns from the linear equation system and b/(2a) is the "error" in the abscissa. Well x1,x2,x3 should be y1,y2,y3 because they are the ordinates.
I hope that helps.
I tried your version dalatant, but I had errors in two spots:
buf = buf.slice(r1,r2);
and
var c = new Array(SIZE).fill(0);
The errors were both "undefined is not a function" on my emulator, but when I ran it on chrome it worked perfectly fine. Why is it coming up with these errors? Thanks for reading!
@aworld1 fill() is a new javascript method that gained support the past 1-2 years. slice() is quite older, but as you figured out it is a matter of where you run it.
@dalatant The new algorithm is also very cluttered with for loops. It is impossible to run something in the background as six for loops are repeated over and over. Is there a way to condense the code, so everything runs faster and smoother, without interrupting the accuracy of the algorithm? I would greatly appreciate it!
Haven't looked at the code, but perhaps webworker is an option?
Op vr 6 jan. 2017 06:42 schreef aworld1 notifications@github.com:
@dalatant https://github.com/dalatant The new algorithm is also very cluttered with for loops. It is impossible to run something in the background as six for loops are repeated over and over. Is there a way to condense the code, so everything runs faster and smoother, without interrupting the accuracy of the algorithm? I would greatly appreciate it!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cwilso/PitchDetect/pull/23#issuecomment-270836034, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOmDfA2fh9yntMZDztRLibAXREz1NIIks5rPdRYgaJpZM4Ks9Em .
Really where did you run it aworld1? I doubled the buffer because it was so fast in my pc that I couldn't read the indications, and I use an intel p4 that I bought in 2003. Condensing the code doesn't mean optimizing.
@dalatant I ran it on Intel XDK, with other code running at the same time, and it was very laggy when I spoke to the mic.
Edit: Oh my god. I edited buflen and everything worked. On every browser. Thanks @dalatant !!! I will use your algorithm.
Also keep in mind that it could work even with the big buffer. A big candidate for the lag is the way the algorithm is recurring inside the app.
I was so thrilled about this app but time passed. And I'm still thrilled! :p Check out my implementation
@dalatant, thesis for? Just curious, my BSC's dissertation was in Greece and relevant to digital sound processing. Math or CS background?
@fllprbt I studied information and communication systems engineering in Samos, a 5yr school. Ye we had dsp and signal processing and all that painful stuff :).
This algorithm has given me far better results in all of my tests, especially for low notes. Thanks for this! I hope it gets committed at some point, because this is excellent!
Just a naïve question: Can't we just simply use a native ConvolverNode, as the autocorrelation can be expressed in terms of convolution. If we define ⦻ the correlation operator and * the convolution operator, we have: Correlation vs Convolution:
Autocorrelation:
@qnp the only difference between correlation and convolution is that in convolution the 2nd signal is time-reversed. So if you convolve a signal with its reversed copy (as impulse response) that will be an autocorrelation.
I've never used ConvolverNode before, but if it can convolve two given signals then yes you can do it that way.
@dalatant thanks to this PR I am experiencing an improved detection on a side project of mine. Thanks x 💯** 💯!
Any chance this PR gets merges, @cwilso? :) I have a web audio app and was looking into options to add Karaoke mode in it, googling pitch detection got me here.
question, what sort of instruments did you use to test this?
I use it with an harmonica
@Meleeman01 Hmm nice question. Οnly an acoustic and an electric guitar. And also my voice. I actually don't have any other (musical) organ. Also good to know that it works on harmonica hehe.
Well I mean... when live testing the application... If you talk about the recorded samples that I mentioned, that was: guitar, piano, clarinet and bassoon.
While doing my thesis on pitch detection, I came up with this utterly simple technique that boosts up autocorrelation performance. The algorithm you use right now has a 30% error rate while this one gives 3.7% tested over a 1500-sample database of 4 instruments that I collected from web.
It works quite well. It may seem unstable but it is only due to high resolution in cents. The low strings of an electric guitar have a natural ±0.3hz ≈ 5cents average fluctuation in their fundamental frequency during a pluck, according to spectrogram. So this is rather normal.
Thesis is in Greek but I am preparing a website with details in English. Thanks to the Web Audio API and this demo I also managed to translate this into a web app. Thanks for sharing.