Giter VIP home page Giter VIP logo

Comments (5)

sevagh avatar sevagh commented on June 25, 2024

Sure. Difference function and autocorrelation are quite similar.

In MPM, normalized square difference and autocorrelation functions are basically the same thing. I found in some exploration (https://github.com/sevagh/pitch-detection/tree/master/misc/mcleod#51---peak-picking-with-parabolic-interpolation---putting-it-all-together) that once you add the rest of the algorithm, autocorrelation and NSDF perform the same.

As a plus, I can use the same autocorrelation function in YIN (

difference(const std::vector<T> &audio_buffer, pitch_alloc::Yin<T> *ya)
{
util::acorr_r(audio_buffer, ya);
for (int tau = 0; tau < ya->N / 2; tau++)
ya->yin_buffer[tau] =
ya->out_real[0] + ya->out_real[1] - 2 * ya->out_real[tau];
}
template <typename T>
static void
cumulative_mean_normalized_difference(std::vector<T> &yin_buffer)
), except there, it's a different variant of autocorrelation - the cumulative mean normalized difference function/CMNDF. It needs some post-processing on the autocorrelation function, unlike MPM which can use the autocorrelation as a direct substitute of the NSDF.

from pitch-detection.

VadymBezdushnyi avatar VadymBezdushnyi commented on June 25, 2024

Thanks for explaining your approach in MPM.
Also, one more thing in YIN implementation remains unclear for me.

In the code above you are using:

ya->out_real[0] + ya->out_real[1] - 2 * ya->out_real[tau]; 

Why ya->out_real[1] is used here?

In my understanding this algorithm shoud look like:

T prefix_sum = 0;
for (int tau = 0; tau < ya->N / 2; tau++) 
{
    ya->yin_buffer[tau] = 2 * ya->out_real[0] - prefix_sum - 2 * ya->out_real[tau];
    prefix_sum += audio_buffer[tau];
}

So we add sum of all squares(ya->out_real[0]) and sum of all squares which start from tau(ya->out_real[0] - prefix_sum)

from pitch-detection.

sevagh avatar sevagh commented on June 25, 2024

I did that with trial and error.

You can see I used to have different code - similar to yours but missing the prefix_sum (maybe that's why it never worked): 521481b#diff-ec0aedadeb2a8475b194edb462daf8fcd235be1a347ae5d49feddbe7ede87559L112

from pitch-detection.

sevagh avatar sevagh commented on June 25, 2024

I would take a look at ya->out_real[1] (maybe print it). Perhaps by luck it's some approximation of the original algorithm.

from pitch-detection.

VadymBezdushnyi avatar VadymBezdushnyi commented on June 25, 2024

Thanks, for clarification. In the end, the best method is one which works :)

from pitch-detection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.