-
Notifications
You must be signed in to change notification settings - Fork 269
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
Allow Pedalboard instances to be used as plugins. #68
Conversation
…ould be cleaner, though.
12afd91
to
83a5bbe
Compare
} | ||
|
||
protected: | ||
std::vector<std::shared_ptr<Plugin>> plugins; |
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.
So the use of shared_ptr here may turn into a performance penalty since shared_ptrs come with thread locks. If you can pass around Plugin& and initialize from your PluginRegistry, you may have a better time (pun intended)
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.
That'd definitely remove the need for a shared_ptr
here, but we don't actually have a PluginRegistry or similar - plugins' lifetimes are managed in Python, and the switch to shared_ptr
here was in order to bridge more cleanly with Python's reference counting semantics.
My understanding is that shared_ptr
only uses a lock when changing the reference count, though; and in our case, that should only ever happen in three places:
- in the constructor of each plugin (implicitly via
pybind11
when returning frompy::init
) - in Python (when objects fall out of scope)
- when modifying the list of plugins in a
PluginContainer
(which should only be triggered by a Python operation to begin with)
We do release the GIL to allow for multithreaded processing when actually rendering audio, but at that point, we're not going to trigger any of the three situations above; hence this shouldn't cause any locks to get hit, and we should end up with no performance penalty.
Oh boy, this is a big one. This PR:
PluginContainer
on the C++ side to represent a plugin that internally delegates to zero or morePlugin
instances.PluginContainer
:Mix
, which mixes the outputs of multiplePlugin
instances in parallelChain
, which runs plugins in series (as thePedalboard
class does now)Pedalboard
class a subclass ofChain
, allowing it to be used as a plugin itselfREADME
sample_rate
parameter fromPedalboard
instances, which may be a breaking API change for some usersstd::shared_ptr
under the hood (to allow for better alignment with Python's reference counting)