-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix audio resampling logic #7858
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
Draft
sakertooth
wants to merge
19
commits into
LMMS:master
Choose a base branch
from
sakertooth:fix-resampling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioResampler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After the
SampleBuffer
refactor in #6610,AudioResampler
was introduced, and the sample playback logic was refactored as well (now withinSample::play
). This left a couple of issues:Sample::play
was not safe to call in real-time since it needed to make an allocation up front to store a temporary buffer of the necessary size.AudioResampler
was not correct in a sense that it would not properly resample the signal. On each callback,AudioResampler
would process the chunk of input samples as is, but it not take into consideration the previous input samples that it didn't get a chance to resample in the previous iteration. I believe this was the reason for the artifacts if buffer margins weren't used, but buffer margins were not the correct way to fix this. I also think they caused problems with the audio quality inSample::play
, in particular near the high frequencies (just from my own observations).I addressed these two issues here. This is my second take at doing something like this after #7361, which was a nightmare on Windows builds, so any testing will be greatly appreciated. Note that unlike in there, I am not using the callback API, but still the full API in
AudioResampler
, just in a different way.AudioResampler
allows callers to specify a callback to write into a very smallSampleFrame
buffer, which it will then be fed into libsamplerate over time. The libsamplerate state inAudioResampler
is now correctly persisted across calls.TODO
SRC_LINEAR
(linear interpolation).AudioResampler
where libsamplerate is used directly if we aren't doing so already.