Skip to content

Conversation

@messmerd
Copy link
Member

@messmerd messmerd commented Sep 2, 2024

All LMMS effects share some identical boilerplate code at the beginning and end of their process loop, such as an early return if the effect is not enabled and calling the checkGate method, but these tasks should not be the plugin developer's responsibility. So I created a wrapper method that handles these tasks and simplifies the process method for all effect plugins.

And along the way, I also made a few other minor changes.

Changes made:

  • Introduce processImpl and processBypassedImpl methods, and adapt each effect
    plugin to use them
  • Move plugin state checks, RMS out sum calculations, and checkGate calls to the processAudioBuffer wrapper method
    • Compressor and LOMM now use double instead of float for RMS out sum
    • checkGate now runs for GranularPitchShifterEffect
  • Minor changes to LadspaEffect
  • Remove dynamic allocations and VLAs from VstEffect's process method
  • Some minor style/formatting fixes

- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes
Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove the gate feature since it seems to generally be problematic for many plugins (as @LostRobotMusic mentioned), though I'm not sure what that would mean for backwards compatibility (maybe the risk is low enough since its rarely used I'm assuming?)

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Sep 3, 2024

I am planning to remove gate knob as a seperate PR. Informed it because there's chance of conflicts

@JohannesLorenz JohannesLorenz self-requested a review September 4, 2024 18:05
Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional review finished.

Outstanding reviews:

  • Style review (at least, I did not do it)
  • Testing review

When testing, different things should be tested:

  • Testing GranularPitchShifterEffect
  • Testing a LadspaEffect
  • Testing a Lv2Effect (if the respective comment will be changed)
  • Trying VstEffect with different (very high?) sampleRates

@PhysSong
Copy link
Member

PhysSong commented Sep 5, 2024

I think there was a suggestion to handle W/D mix and check output level in single place, rather than letting each plugin handles them. This might be in the scope of this PR as well.

@PhysSong
Copy link
Member

PhysSong commented Sep 5, 2024

Also, for sleepImpl: I think something like processBypassedImpl will match what the operation is commonly called.

@messmerd
Copy link
Member Author

I think there was a suggestion to handle W/D mix and check output level in single place, rather than letting each plugin handles them. This might be in the scope of this PR as well.

I like that idea, though I'm not sure if it can be easily done while keeping in-place processing of the buf audio buffer. So that could be left to another PR if it is feasible.

@messmerd
Copy link
Member Author

I think all the reviews have been addressed now.

I was able to move the outSum calculations into the wrapper method, and introduced the ProcessStatus enum to allow plugins to specify what they want to happen after the process loop (continue, continue if not quiet, or sleep). I took this idea from the CLAP API. It makes the interface really clean and avoids the -1.0 magic value.

Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rework checked, OK from that point of view.
Style checked.
Testing still to be done.

@bratpeki
Copy link
Member

I see this needs testing. I would be interested. How exactly does one test this?

@messmerd
Copy link
Member Author

@bratpeki This PR shouldn't change anything from a user's perspective, so testing would just involve using effects plugins (LMMS, VST, Ladspa, Lv2) and verifying that they still work as expected. If there are any regressions, it would probably affect the auto-off/gate

@JohannesLorenz
Copy link
Contributor

I see this needs testing. I would be interested. How exactly does one test this?

See also #7484 (review)

@bratpeki
Copy link
Member

Alright, I'll clone it, build it, and use it for a few days, reporting back on any mishaps, if they occur!

@bratpeki
Copy link
Member

LB302 seems to not produce sound.

@messmerd
Copy link
Member Author

LB302 seems to not produce sound.

It looks like it doesn't work on master either... strange. Not a bug from this PR fortunately

Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently looking into the regression reported by @bratpeki that seems to not be from this PR. This PR however looks good to me.

@bratpeki
Copy link
Member

bratpeki commented Sep 18, 2024

Also, please check if TripleOsc is louder than before.
This could just be my mind playing games with me!

It could also be unrelated to this PR, of course!

@messmerd
Copy link
Member Author

@bratpeki This PR doesn't affect any of the instrument plugins so you don't need to test them

@bratpeki
Copy link
Member

LADSPA works great, LV2 has also been tested, I'll look at some LinuxVSTs as well!

@bratpeki
Copy link
Member

I have done tested a few AirWindows LinuxVST plugins, and they sound perfectly fine! I've tested the audio with Air, Chorus, StereoChorus, ADClip, and a few other plugins from the suite.

I've left a somewhat detailed report and question on the Discord server.

In any case, the audio sounds just fine, so this LGTM, but I'll leave it to you. Please let me know if you would like me to conduct any more testing on this!

@messmerd
Copy link
Member Author

@bratpeki Thank you very much for testing! I'll look into what you mentioned on Discord, though I imagine it won't be an issue.

@messmerd
Copy link
Member Author

I couldn't find anything in the VST changes made by this PR that could explain the minor phase difference between this PR and master in the renders Peki shared on Discord.

With everything else in the testing looking fine, and with 2 approvals, I think this is ready to merge.

@messmerd messmerd merged commit 1825208 into LMMS:master Sep 21, 2024
@messmerd messmerd deleted the effect-process-wrapper branch September 21, 2024 02:03
JohannesLorenz added a commit to JohannesLorenz/lmms that referenced this pull request Oct 3, 2024
* Move common effect processing code to wrapper method

- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes

* Fix VstEffect regression

* GranularPitchShifterEffect should not call `checkGate`

* Apply suggestions from code review

Co-authored-by: saker <[email protected]>

* Follow naming convention for local variables

* Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect

* Revert "GranularPitchShifterEffect should not call `checkGate`"

This reverts commit 67526f0.

* VstEffect: Simplify setting "Don't Run" state

* Rename `sleepImpl` to `processBypassedImpl`

* Use `MAXIMUM_BUFFER_SIZE` in SetupDialog

* Pass `outSum` as out parameter; Fix LadspaEffect mutex

* Move outSum calculations to wrapper method

* Fix Linux build

* Oops

* Apply suggestions from code review

Co-authored-by: Johannes Lorenz <[email protected]>

* Apply suggestions from code review

Co-authored-by: saker <[email protected]>

---------

Co-authored-by: saker <[email protected]>
Co-authored-by: Johannes Lorenz <[email protected]>
mmeeaallyynn pushed a commit to mmeeaallyynn/lmms that referenced this pull request Oct 27, 2024
* Move common effect processing code to wrapper method

- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes

* Fix VstEffect regression

* GranularPitchShifterEffect should not call `checkGate`

* Apply suggestions from code review

Co-authored-by: saker <[email protected]>

* Follow naming convention for local variables

* Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect

* Revert "GranularPitchShifterEffect should not call `checkGate`"

This reverts commit 67526f0.

* VstEffect: Simplify setting "Don't Run" state

* Rename `sleepImpl` to `processBypassedImpl`

* Use `MAXIMUM_BUFFER_SIZE` in SetupDialog

* Pass `outSum` as out parameter; Fix LadspaEffect mutex

* Move outSum calculations to wrapper method

* Fix Linux build

* Oops

* Apply suggestions from code review

Co-authored-by: Johannes Lorenz <[email protected]>

* Apply suggestions from code review

Co-authored-by: saker <[email protected]>

---------

Co-authored-by: saker <[email protected]>
Co-authored-by: Johannes Lorenz <[email protected]>
messmerd added a commit to messmerd/lmms that referenced this pull request Aug 31, 2025
This is slightly more thread-safe since the lock now covers the calls to
`Effect::isSleeping()` and `AudioPorts::active()`, which matches what we
did prior to PR LMMS#7484.
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

Successfully merging this pull request may close these issues.

6 participants