Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tDualPitchDetector Broken or Unclear #17

Open
BOBONA opened this issue Feb 19, 2024 · 1 comment
Open

tDualPitchDetector Broken or Unclear #17

BOBONA opened this issue Feb 19, 2024 · 1 comment

Comments

@BOBONA
Copy link

BOBONA commented Feb 19, 2024

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);
@spiricom
Copy link
Owner

spiricom commented Feb 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants