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

Reusing an instance of the resampler (MultiChannelResampler). #2139

Open
Gilianp opened this issue Jan 16, 2025 · 0 comments
Open

Reusing an instance of the resampler (MultiChannelResampler). #2139

Gilianp opened this issue Jan 16, 2025 · 0 comments

Comments

@Gilianp
Copy link

Gilianp commented Jan 16, 2025

I am using resampler::MultiChannelResampler to simulate pitch shift with duration modification on small audio clips (piano). It works well when I instantiate a new resampler every time I want to play a note, but I would like to avoid this overhead and reuse the resampler instance. However, whenever I reuse it, I hear a click/pop at the beginning of playback, which is probably due to the resampler still having leftover data from the last use (playback can be stopped before the clip finishes completely). I would like to know if there is a way to clear the internal data of a resampler without needing to instantiate a new one.

I use the example from the Oboe resampler doc. So, when I press a key, the resampler is filled with frames, and I wait for the resampler's output when this happens. As here: https://github.com/google/oboe/tree/main/src/flowgraph/resampler

int outputFramesLeft = numOutputFrames;
while (outputFramesLeft > 0) {
    if(resampler->isWriteNeeded()) {
        const float *frame = getNextInputFrame(); // you provide this
        resampler->writeNextFrame(frame);
    } else {
        resampler->readNextFrame(outputBuffer);
        outputBuffer += channelCount;
        outputFramesLeft--;
    }
}

After using this resampler, which can stop being filled at any moment (when releasing the piano key), I want to reassign it to a new note that is pressed. However, when using the same instance, a click/pop occurs in the first frames of the new audio clip, which I imagine is due to leftover data from its last use. Therefore, I would like to know how to clear the resampler so it can be reused without this issue.

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

1 participant