Skip to content

tDualPitchDetector Broken or Unclear #17

@BOBONA

Description

@BOBONA

This is a really neat library and I'm hoping to use the pitch detector algorithm. The regular tPitchDetector seems to work as expected (though I did find the API a bit confusing). I wanted to test tDualPitchDetector to see if it is more accurate, but it doesn't seem to work at all. I don't really understand how the algorithm works but it seems like tPeriodDetection is not finishing its work and returns a period of 0, which is a problem in this line Lfloat f1 = 1.0f / tPeriodDetection_getPeriod(&p->_pd1);

I'm assuming this is an issue in the way I'm using the algorithm, however my code does work fine when I use tPitchDetector:

LEAF leaf;
tDualPitchDetector pitchDetector;

const size_t memorySize = 50000;
char memory[memorySize];
LEAF_init(&leaf, float(sampleRate), memory, memorySize, []() -> float { return Random().nextFloat(); });
tDualPitchDetector_init(&pitchDetector, 50, 20000, &leaf);
for (int i = 0; i < numSamples; i++)
{
    bool ready = audioBuffer->getNumChannels() == 2 ? 
        tDualPitchDetector_tick(&pitchDetector, (audioBuffer->getSample(0, sampleStart + i) + audioBuffer->getSample(1, sampleStart + i)) / 2.f) :
        tDualPitchDetector_tick(&pitchDetector, audioBuffer->getSample(0, sampleStart + i));
    if (ready)
        break;
}
pitch = double(tDualPitchDetector_predictFrequency(&pitchDetector));
tDualPitchDetector_free(&pitchDetector);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions