-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Add audio plugin hosting via Carla #8919
Conversation
81ea6f9
to
096ac5d
Compare
on macOS the artifacts from OBS org actions have the same issue I had locally, making it impossible to load and thus test any plugins. example output:
guidance for this is appreciated. |
for the windows build, at least under wine, it fails to load/find the carla-bridge plugin and there are no debug messages printed about it. dont know why yet, will try with a real windows system later in the week. |
The checkbox is mostly meant for developer documentation if libobs/frontend APIs are changed, so I don’t think it really applies. That said, we’d probably want to have some user documentation in the knowledge base come release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- List of VST3 folders is not configurable for now, it will just use the common folders from VST3 spec
From a quick test, the Flatpak does not show VST_PATH plugins (I have a LinuxAudio extension that provide VSTs (2 and 3)), the plugin must rely on such env vars since those are mostly the only way on Flatpaks.
The manifest then needs to be updated to support VST 3, it requires me a pull the branch and modify the manifest to test then. |
Just checked on Windows, there is a crash when loading the carla-bridge plugin, but not really sure what it means just yet.
The EDIT: this has been fixed now, there was a buffer overflow |
#include <obs-module.h> | ||
#include <util/platform.h> | ||
|
||
#ifndef CARLA_MODULE_ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these macros required? Only use macros if there is no other language feature to achieve the same (e.g. const character array for constant strings).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macros allow to reuse the same code for other OBS plugins, which I already have written for testing but are not part of this PR. The idea is to build a few other variants that reuse the same base, but are separate OBS plugins.
One of them is "carla patchbay" which brings the full GUI along as seen in https://user-images.githubusercontent.com/1334853/235544415-6ae2c9e5-3cbf-47b2-8fc0-013f0ec8276d.png
I also dont know if calling it "Carla" is okay or not, you might prefer something more like "OBS audio plugin".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macros allow to reuse the same code for other OBS plugins, which I already have written for testing but are not part of this PR. The idea is to build a few other variants that reuse the same base, but are separate OBS plugins. One of them is "carla patchbay" which brings the full GUI along as seen in https://user-images.githubusercontent.com/1334853/235544415-6ae2c9e5-3cbf-47b2-8fc0-013f0ec8276d.png
Understandable, but this code is targeted to become part of the obs-studio codebase and should be designed for that. If this were a 3rd party "audio plugin" template, then this would make sense, but for a core plugin this configurability is not needed and should be removed.
I also dont know if calling it "Carla" is okay or not, you might prefer something more like "OBS audio plugin".
I don't mind keeping the name of the technology in place, maybe others have an opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that I already pushed the 2 OBS modules in this PR, so what I said above regarding carla-bridge and carla-patchbay reusing the same code already applies.
the same code is built twice, but uses a compiler macro to tweak it just enough to be different. the alternative is to have duplicate files where they only differ for 2-3 simple strings. is that better than the current approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit that the entire architecture of this plugin goes above my head right now because there's multiple binaries, libraries, modules - it goes beyond the complexity of any other plugin we have right now.
Do you have an overview of all these moving parts somewhere and what the differences between them are? Because I don't currently understand why we need 2 plugins with the same code and what their differences would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the confusion, this is just reusing some files for a common api adjusting obs <-> carla, then implementing that for both carla-bridge and carla-patchbay plugins.
the way to deal with getting audio from OBS, optionally putting it in a buffer, feeding that buffer into an audio plugin (lv2/vst3/etc) and then getting that audio back to feed it back into OBS... all this is something that both carla-bridge and carla-patchbay have to do, so it makes sense to share the base details or their implementation.
we basically have here:
- carla-bridge
- carla-patchbay
the carla-bridge
is the main target of this PR and the old bounty, it allows OBS to load VST3 plugins but because carla handles more than that we get CLAP, LADSPA, JSFX and VST2 all in one. while other OBS things exist that deal with LV2 or VST2 plugins, they do not always work the best and are fairly limited.
my approach is to consolidate it all into a single nice package.
this OBS plugin has its own frontend code in order to deal with a proper plugin dialog with a searchbar, filters, favorites etc.
carla-utils
is used for handling the plugin scanning (which internally calls the discovery tool as needed, audio plugins are skipped if previously scanned and in cache) and also to deal with some of the IPC details.
we still need to do some of the heavy lifting, sending and receiving IPC messages, but the actual complexity is mostly handled on carla side, including the audio plugin processing.
the carla-bridge
handling is quite simple in its handling, in terms of what it can do. the plugin scanning and dialog can be a bit complex, but all processing is just dealing with IPC, then a bit of code for exposing parameters and saving plugin state.
but if you mostly meant to ask about code, well most of it is shared and the GUI parts are a bit "extra" as they are unique.
I would divide the code into 4 sections.
- common code
- common.c/h - common C code between the plugins
- qtutils.h/cpp - small qt utilities not exposed through OBS APIs, plus any other needed Qt/C++ related bits
- carla-wrapper.h - provides a sort of "base" API,
- carla.c - bridges the
carla-wrapper.h
API into OBS, alike a Carla <-> OBS translation. these last 2 are the important files on the common code
- carla-bridge only code
- carla-bridge.hpp/cpp - this implements the carla IPC bridge, in a way suitable for OBS. it is almost a generic implementation though, could be thought as a kind of "private API"
- carla-bridge-wrapper.cpp - this implements the "base" specified on point 1, calling into bridge details
- carla-patchbay only code
- carla-patchbay-wrapper.c - similar to
carla-bridge-wrapper.cpp
above, but implements the public carla plugin API instead of handling bridge details. this code does nothing special by itself, it simply calls an API exposed by carla
- carla-bridge GUI code
- pluginlistdialog.cpp/hpp/ui
- pluginrefreshdialog.hpp/ui
this is just the UI code to deal with the plugin dialog, no audio processing happens here, and it is all based on Qt code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the write-up, will read this carefully later tonight or tomorrow.
I think I found the issue on Windows, an out of bounds write, fixed in 691e6df And hopefully next build is fully working for flatpak, I imported the same code that other parts of OBS use to check if it is running under flatpak. |
good news, can confirm plugins work under flatpak! but with a big caveat - it now needs some setup in order to see system installed plugins. can we ping the person(s) responsible for the OBS flatpak stuff please? |
Not at all, it would be the same outside of a Flatpak, just
The RPATH is "forced" Flatpak or not, it is how the CMake works. Flatpak do nothing custom, it just builds inside a runtime that is not the host. |
Nice, thanks for testing. I think I know why the windows bridge is not found, can push that soon but dont have a windows machine to verify such changes at the moment. can someone from OBS please tag a release on https://github.com/obsproject/obs-deps so we can begin to have this PR officially working? |
The project managers are in vacation. There'll be a tag when they're back in a few days. |
good to know, thanks. |
Hi falkTX, great work here, I recently moved my daily driver to Pop! OS, and now I'm testing out your Carla host! Glad to see that JSFX support is here! I've encountered some issues: It seems that JSFX plugins are still loaded from |
Signed-off-by: falkTX <falktx@falktx.com>
Signed-off-by: falkTX <falktx@falktx.com>
Signed-off-by: falkTX <falktx@falktx.com>
I dont quite follow this.. there is no setting for specifying the path of the plugins, it will use the defaults as defined by the plugin spec. for JSFX there is no spec so it uses the reaper's home folder. If you set that path to something else in the Carla tool, that won't apply here as it is not Carla, it is just a plugin list dialog that was originally based on it. |
Signed-off-by: falkTX <falktx@falktx.com>
Signed-off-by: falkTX <falktx@falktx.com>
Signed-off-by: falkTX <falktx@falktx.com>
Signed-off-by: falkTX <falktx@falktx.com>
Did a refresh of the PR against latest master branch, aligning with the requested changes so far too. I am not able to get the bridge tools/binaries to end up being part of the windows package though. I see stuff in there like |
no worries, it was a bit confusing, but all my issues with JSFX have been resolved - I can place the plugins in that folder, or use the Patchbay plugin to change OBS Carla's paths. Am hoping that the latest commits will remove some of the carla related issues I've encountered (instability). |
After fairly lengthy and difficult internal discussions, we have decided that using Carla as a host for VST3 (and other) plugins is not the right path forward for the project. In the interests of maintaining full transparency, we have spoken with falkTX and are paying out partial bounty on this for the work and effort, and want to publicly thank them for their patience on this. We will be posting an update to the bounty itself soon, and will reopen for new submissions at that time. |
Thanks for reaching out and getting a sorta conclusion to this PR. I do not want to have the effort go to waste though, so at some time later this year I will revive this PR as its own external OBS plugin. That way it still lives on, and also allows for direct inclusion of carla as git submodule which was rejected early on (much easier to deal with regarding packaging). Thanks again and best wishes to the OBS project team. |
Description
Adds support for audio plugins to OBS (focus is on VST3 for now, as per the bounty in #5074).
As requested in the bounty, all plugins are loaded in a separate process with communication done via shared memory (with semaphores for synchronization).
The plugin support is done mostly through Carla, but everything is directly integrated into OBS.
While the focus is on VST3, the same code can be used for loading LADSPA, LV2, VST2, CLAP and JSFX plugins.
Motivation and Context
Having access to audio plugins within OBS simplifies a lot of complex setups that before hand had to rely on external tools, or keep only using VST2 plugins through the "old" obs-vst plugin.
See #5074 for discussion around the VST3 feature request.
How Has This Been Tested?
I have tested mainly on Linux during development, with occasional switching to Windows 10 and macOS to check on their status.
Do note the plugin bridging as used by Carla is already in use in other applications like zrythm, so aside for new bugs due to new OBS-related and VST3 hosting implementation I expect most things to just work.
On Linux I regularly checked through valgrind to catch for runtime memory issues and leaks.
(I did not check debug the remote plugin process much though, but have tested the same hosting code running non-bridged)
Types of changes
This PR adds a new "input source" and "input filter", for now called "Audio Plugin" but I am welcome to a more OBS-branding-like name.
These 2 come from the same binary and code, the "input source" creates its own thread for the audio while "input filter" uses the typical
filter_audio
method. They also both work the same way, with the same exact options.Note that in regards to the bounty only the filter is necessary, but I find allowing generator plugins as sound source to be extremely useful.
Plugin options
By default there will be 4 widgets:
If a plugin is loaded that provides a custom UI, a "Show custom UI" button will be shown too.
After these buttons OBS will show plugin parameters, if any are exposed by it.
Changes in parameters from OBS side will be transmitted to the plugin and vice-versa.
Screenshot for reference, using master_me:
Checklist:
Assuming the PR gets merged at some point, where is the official place for documentation that needs to be updated?
Current status
This pull request is pretty much complete. With a few things worth noting:
Feedback welcome, also regarding the UI/UX. I am open to tweaking names, labels etc to fit things better in OBS.