0

I have implemented Yin Algorithm to detect pitch.

My issue is with the Performance of Difference Function(Equation 6)

Difference Function:

static std::vector<double> difference(const std::vector<double> &data)
{
    int index, tau;
    double delta;
    int yin_buffer_size = signed(data.size() / 2);
    std::vector<double> yin_buffer(yin_buffer_size, 0.0);

    for (tau = 1; tau < yin_buffer_size; tau++) {
        for (index = 0; index < yin_buffer_size; index++) {
            delta = data[index] - data[index + tau];
            yin_buffer[tau] += delta * delta;
        }
    }
    return yin_buffer;
}

where data contains the audio data for a specific window size.

As you can see this function gets slower as you increase the data size(window size).

Please let me know if there is an alternative to the Difference Function which is faster. I want to move ahead in the right direction.

I'm quite new to signal processing, Your help is greatly appreciated.

Jedi Nerd
  • 49
  • 8

1 Answers1

0

Alright, The Yin paper describes that we can use Equation 7 instead of Equation 6. Equation 7 can be arrived at using FFT which is much faster.

A simple search online provided lots of implementation examples to achieve this.

An implementation in JAVA can be found here done by a user called JorenSix. JorenSix, If you are reading this, Thank You.

Jedi Nerd
  • 49
  • 8