Autocorrelation method for pitch determination: what is the input data form?

Posted by harsh on Stack Overflow See other posts from Stack Overflow or by harsh
Published on 2010-03-14T10:52:33Z Indexed on 2010/03/14 11:05 UTC
Read the original article Hit count: 275

Filed under:
|

I have read a code for pitch determination using autocorrelation method. Can anybody please tell what would be the input data (passed as argument to DetectPitch()) function here:

double DetectPitch(short* data)
{
    int sampleRate = 2048;

    //Create sine wave
    double *buffer = malloc(1024*sizeof(short));
    double amplitude = 0.25 * 32768; //0.25 * max length of short
    double frequency = 726.0;
    for (int n = 0; n < 1024; n++)
    {
        buffer[n] = (short)(amplitude * sin((2 * 3.14159265 * n * frequency) / sampleRate));
    }

    doHighPassFilter(data);

    printf("Pitch from sine wave: %f\n",detectPitchCalculation(buffer, 50.0, 1000.0, 1, 1));
    printf("Pitch from mic: %f\n",detectPitchCalculation(data, 50.0, 1000.0, 1, 1));
    return 0;
}

© Stack Overflow or respective owner

Related posts about automation

Related posts about c