google / google/oboe

Reusing an instance of the resampler (MultiChannelResampler).

Open
#2,139 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
4.1k
Forks
639
Avg merge
2d 23h
Merged PRs (30d)
8

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.