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

Moving SIZE clears the reverb buffer or resets it causing artifacts? #12

Open
DavidsonAudioMulti opened this issue Mar 30, 2024 · 2 comments

Comments

@DavidsonAudioMulti
Copy link

Moving SIZE clears the reverb buffer or resets it causing artifacts? When I move the size control it resets any current reverb, can we make to where one can adjust the SIZE in realtime?

Thanks

@lorenzje
Copy link

The issue with the SIZE parameter resetting the reverb buffer lies in how it interacts with the internal processing state. Currently, adjusting SIZE likely triggers a reinitialization of internal structures or buffers, causing the reverb to restart and resulting in audible artifacts.

Solution
To make the SIZE parameter adjustable in real-time without artifacts:

Gradual Transition: Interpolate the change in the SIZE parameter over multiple processing frames, allowing the system to adjust smoothly without disrupting the buffer.
Non-Destructive Buffer Handling: Avoid clearing or reinitializing the entire reverb buffer when SIZE changes. Instead, apply the new SIZE value adaptively.
Conditional Reinitialization: Reinitialize only if a drastic change in SIZE occurs (e.g., a large jump), but use fading or crossfading techniques to reduce artifacts.
Implementation
Update the handling of the SIZE parameter in the MVerb processing code:

Interpolate Parameter Changes: Modify the setParameter method to smooth changes in SIZE. For instance:

cpp
Copy
Edit
void MVerb::setParameter(int index, float value) {
if (index == SIZE) {
float previousSize = currentSize;
targetSize = value;
sizeTransitionStep = (targetSize - previousSize) / transitionFrames;
}
parameters[index] = value;
}
Apply Changes Gradually: In the process method, gradually adjust the SIZE value per frame:

cpp
Copy
Edit
void MVerb::process(float** inputs, float** outputs, int sampleFrames) {
for (int i = 0; i < sampleFrames; ++i) {
// Smoothly transition SIZE
if (std::abs(targetSize - currentSize) > 0.0001f) {
currentSize += sizeTransitionStep;
if ((sizeTransitionStep > 0 && currentSize >= targetSize) ||
(sizeTransitionStep < 0 && currentSize <= targetSize)) {
currentSize = targetSize;
}
updateSize(currentSize);
}
// Process audio
processSample(inputs, outputs, i);
}
}
Update the Size Gradually: Implement updateSize(float size) to adjust only the necessary internal state without resetting the entire buffer.

cpp
Copy
Edit
void MVerb::updateSize(float size) {
// Update size-dependent parameters without clearing the buffer
roomSize = size;
adjustDelayLines(size);
}
By implementing this interpolation and selective updating mechanism, you can allow real-time SIZE adjustments without introducing disruptive artifacts.

@lorenzje
Copy link

Hi! I have forked this code and fixed the issue: Smooth Transitions for SIZE Parameter:

Introduced a targetSize variable in MVerb to allow gradual transitions for the SIZE parameter instead of abrupt changes.
Updated the process method in MVerb to interpolate SizeSmooth toward targetSize over multiple audio frames.
Buffer Clearing Avoidance:

Modified MVerb's updateDelayLinesAndFilters to adjust delay line lengths and indices dynamically without clearing buffers. This prevents audible artifacts like clicks or pops during real-time adjustments.
Delegation in VstPlugin:

Ensured that setParameter and getParameter in VstPlugin correctly delegate changes to the updated MVerb class.
Testing and Compatibility:

Verified that no changes were required in VstPlugin.h beyond ensuring compatibility with the updated MVerb.

Check my fork if you wanna see ! :)

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