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

Initial support for CLAP plugins #7199

Draft
wants to merge 126 commits into
base: master
Choose a base branch
from
Draft

Conversation

messmerd
Copy link
Member

@messmerd messmerd commented Apr 7, 2024

This has been in the works for over a year now, so I'm really excited to share it.
There are a number of known issues (listed below) that I'd like to fix before it's ready to merge, which is why I'm marking this as a draft for now.

I've decided to create this draft PR because until now I've only been running this on Linux Mint, so I need people who can test it on Mac and Windows. Don't expect a finished product yet - there will be bugs and even crashes! - though many of the free CLAP plugins listed on https://clapdb.tech/ should run without major issues. On Linux at least.

Other than the parameter and events code, I don't see much significant refactoring needed, and I'm pretty satisfied with the current design. Because of this, feel free to leave code reviews if you'd like. Fortunately most of the code is isolated from the rest of the LMMS codebase, so that will make things a bit easier, though it's still quite a bit for one PR.

Features

  • CLAP instrument and audio effect support
  • CLAP extensions supported:
    • log
    • note-ports
    • params
    • preset-load
    • state-context
    • state
    • thread-check
    • timer-support
  • CLAP plugin discovery at startup
  • Integration within LMMS with a look-and-feel similar to LV2
  • CLAP preset support
    • Discovery, metadata loading, and storage
    • Preset activation
    • Loading and saving (WIP)
    • Simple preset selector widget modeled after Vestige's
    • Most importantly, it's a generic yet robust implementation that other plugin types (VST, LV2, LMMS-native, etc) can use in the future.
  • Generic L/R channel routing configuration
    • Currently used by mono CLAP plugins, though could be used elsewhere in the future
    • Has a combo box for users to pick the desired configuration
  • CLAP transport implementation (VST sync equivalent)
  • Partial GUI implementation (currently disabled)
    • Introduced WindowEmbed class and used it to improve some other parts of LMMS, though maybe that work should be moved to a separate PR
  • Pedantic sanity checks to ensure plugin and host logic is correct and API calls are performed on the correct threads
  • Environment variables
    • CLAP_PATH
      • Specifies additional CLAP plugin search paths beyond the system defaults
      • Part of the CLAP standard
    • LMMS_CLAP_PATH
      • List of directories that replaces all other CLAP plugin search paths in LMMS
      • export LMMS_CLAP_PATH= effectively disables CLAP support at startup
    • LMMS_CLAP_DEBUG=1
      • Enables verbose debug output
  • LoMMuS

Known Issues

  • Parameters are buggy!
    • I've barely touched them since I implemented them a year ago, so I need to revisit this
    • Crashes can occur during automation
  • Parameter and midi events may occur in the wrong order, possible threading issues, etc.
  • Some plugin-specific issues (see below)
  • Active preset doesn't carry over when cloning an instrument
  • Memory leaks - though it's often difficult to tell whether they are from LMMS or from the plugins
  • ...

Plugins with known issues

  • Crash / hang:
    • Regency (this didn't used to crash, so it's probably a recent regression)
    • Firefly Synth
    • ...
  • Parameter issues:
    • Odin2
    • MPaint
    • ...

TODO for this PR

  • Fix known issues (or at least the major ones) and any that come up during testing
  • Refactor/rethink event handling
  • Better parameter controls
    • Tooltips for controls other than CustomTextKnob
    • ComboBox for enum parameters
  • Implement the Save Preset functionality for saving presets to disk
  • The modifications I made to CustomTextKnob are pretty hacky - need to redo that
  • Better usage of note-ports?
  • Remove clap-helpers dependency?
  • Move preset discovery to a worker thread?
  • GUI??? (might depend on how difficult events from the plugin UI are to handle)
  • ...

TODO for future PRs

I don't plan for this PR to be the end of my contributions to CLAP support in LMMS.

In the future I'd like to add more features:

  • GUI (if I don't add it to this PR)
  • Thread pool extension
  • A proper parameter window
  • A proper preset browser to replace the simple QMenu currently in use
  • Per-note pitch bends and panning
  • MIDI MPE support
  • Sidechaining
  • Transport events?
  • ???

My goal is for CLAP support in LMMS to far outclass our VST support so that we have little reason to use VSTs again.

Testing

This branch has not been tested on any OS other than Linux Mint, so I'd appreciate testing on Windows and Mac.

If you find any bugs not listed above, please let me know either here or on Discord. Thanks!

Special thanks to

  • JohannesLorenz, whose previous work with LV2 was my guide for integrating this CLAP host into LMMS
  • The CLAP Team, for the excellent CLAP API and reference host

messmerd and others added 30 commits January 27, 2024 14:52
- Fix crash due to double free
- Implement the host's thread check CLAP extension
- Fix bug when a directory in the CLAP search path ends with ".clap"
- Set input audio buffers' constant_mask when unused
- Better audio port issue checking
- Add some thread checks
@messmerd messmerd linked an issue Apr 7, 2024 that may be closed by this pull request
Thanks to baconpaul for the fix
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.

feature request: CLAP support
1 participant