Skip to content

wrong results with different buffer sizes in the sinewave example #72

Closed
@jeychenne

Description

@jeychenne

I tried to play with the sinewave example, changing the buffer size and sampling rate. Perhaps I'm missing something obvious, but it looks like depending on the buffer size, the results are wrong. Here is the test I ran, using the current master version of FFTS:

    std::cerr << "Expected pitch: 250 Hz" << std::endl;

    auto d = sinewave(2048, 250, 16000);
    auto p = pitch::yin<double>(d, 16000);
    std::cerr << "pitch with 2048 samples @ 16000 Hz: " << p << " Hz" << std::endl;

    d = sinewave(256, 250, 16000);
    p = pitch::yin<double>(d, 16000);
    std::cerr << "pitch with 256 samples @ 16000 Hz: " << p << " Hz" << std::endl;
    
    d = sinewave(4096, 250, 16000);
    p = pitch::yin<double>(d, 16000);
    std::cerr << "pitch with 4096 samples @ 16000 Hz: " << p << " Hz" << std::endl;

    d = sinewave(2048, 250, 22050);
    p = pitch::yin<double>(d, 22050);
    std::cerr << "pitch with 2048 samples @ 22050 Hz: " << p << " Hz" << std::endl;

    d = sinewave(4096, 250, 22050);
    p = pitch::yin<double>(d, 22050);
    std::cerr << "pitch with 4096 samples @ 22050 Hz: " << p << " Hz" << std::endl;

    d = sinewave(8092, 250, 22050);
    p = pitch::yin<double>(d, 22050);
    std::cerr << "pitch with 8092 samples @ 22050 Hz: " << p << " Hz" << std::endl;

    d = sinewave(8092, 250, 48000);
    p = pitch::yin<double>(d, 48000);
    std::cerr << "pitch with 8092 samples @ 4800 Hz: " << p << " Hz" << std::endl;

    d = sinewave(4046, 250, 22050);
    p = pitch::yin<double>(d, 22050);
    std::cerr << "pitch with 4046 samples @ 22050 Hz: " << p << " Hz" << std::endl;

    d = sinewave(4046, 250, 48000);
    p = pitch::yin<double>(d, 48000);
    std::cerr << "pitch with 4046 samples @ 4800 Hz: " << p << " Hz" << std::endl;

And here is the output on my machine (debian x64):

Expected pitch: 250 Hz
pitch with 2048 samples @ 16000 Hz: -1 Hz
pitch with 256 samples @ 16000 Hz: 1781.45 Hz
pitch with 4096 samples @ 16000 Hz: -1 Hz
pitch with 2048 samples @ 22050 Hz: 286.617 Hz
pitch with 4096 samples @ 22050 Hz: 1100.9 Hz
pitch with 8092 samples @ 22050 Hz: 250.226 Hz
pitch with 8092 samples @ 4800 Hz: 250.356 Hz
pitch with 4046 samples @ 22050 Hz: 250.337 Hz
pitch with 4046 samples @ 4800 Hz: 250.626 Hz

Can you confirm this problem, and do you have an explanation for it? Thank you!

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