7
44
Fork
You've already forked nice-plug
22

Switch to vst3 crate #29

Merged
BillyDM merged 8 commits from davemollen/nice-plug:switch-vst3-crate into main 2026年06月02日 21:07:22 +02:00
Contributor
Copy link

I have moved this PR from the nih-plug repository to here. I have gone through Micah's comments over there.

I think a thorough review of these changes is still needed. A big chunk of this is from Micah's draft PR. All I did was try and get that to the finish line.

Some additional comments:

  • VirtualKeyCode parsing was recently added with this PR: #9. The vst3 crate also defines VirtualKeyCodes_ and KeyModifier_, and these are automatically generated. So I think it would be cleaner to use these bindings instead. But I left this out because changing this would probably be a breaking change.
  • The RunLoopEventHandler struct contained this comment:
/// Allow handling tasks on the host's GUI thread on Linux. This doesn't need to be a separate
/// struct, but vst3-sys does not let us implement interfaces conditionally and the interface is
/// only exposed when compiling on Linux. The struct will register itself when calling
/// [`RunLoopEventHandler::new()`] and it will unregister itself when it gets dropped.

According to this comment this struct could be redundant because we replaced the vst3-sys crate. I kept it in because I think it's actually nice to have this scoped to a separate struct. Since it's a linux only thing, and only then deals with the IEventHandler. But this comment might still be something to consider.

I have moved this PR from the nih-plug repository to here. I have gone through [Micah's comments over there](https://github.com/robbert-vdh/nih-plug/pull/263).
 I think a thorough review of these changes is still needed. A big chunk of this is from [Micah's draft PR](https://github.com/robbert-vdh/nih-plug/pull/243). All I did was try and get that to the finish line. Some additional comments: * VirtualKeyCode parsing was recently added with this PR: #9. The vst3 crate also defines `VirtualKeyCodes_` and `KeyModifier_`, and these are automatically generated. So I think it would be cleaner to use these bindings instead. But I left this out because changing this would probably be a breaking change. * The RunLoopEventHandler struct contained this comment: ``` /// Allow handling tasks on the host's GUI thread on Linux. This doesn't need to be a separate /// struct, but vst3-sys does not let us implement interfaces conditionally and the interface is /// only exposed when compiling on Linux. The struct will register itself when calling /// [`RunLoopEventHandler::new()`] and it will unregister itself when it gets dropped. ``` According to this comment this struct could be redundant because we replaced the vst3-sys crate. I kept it in because I think it's actually nice to have this scoped to a separate struct. Since it's a linux only thing, and only then deals with the IEventHandler. But this comment might still be something to consider.

So I think it would be cleaner to use these bindings instead. But I left this out because changing this would probably be a breaking change.

Actually it's necessary to have our own definitions of VirtualKeyCodes and KeyModifier because nice-plug needs to still be able to compile without the "vst3" feature enabled.

> So I think it would be cleaner to use these bindings instead. But I left this out because changing this would probably be a breaking change. Actually it's necessary to have our own definitions of `VirtualKeyCodes` and `KeyModifier` because nice-plug needs to still be able to compile without the "vst3" feature enabled.
Author
Contributor
Copy link

True, I was thinking we could expose/export the vst3 VirtualKeyCodes and KeyModifier types only when the "vst3" feature is enabled. But thinking about it some more the vst3 crate types are not really suited for this use case anyway. So it's fine to have some "duplication" then

True, I was thinking we could expose/export the vst3 `VirtualKeyCodes` and `KeyModifier` types only when the "vst3" feature is enabled. But thinking about it some more the vst3 crate types are not really suited for this use case anyway. So it's fine to have some "duplication" then
Contributor
Copy link

Works fine for me on Mac, tested most of the example plugins and couldn't find any issues.

Works fine for me on Mac, tested most of the example plugins and couldn't find any issues.

Alright, I got Windows 11 dual boot set up and testing the plugins. They all worked correctly in the DAWs I tested! (FL, Reaper, Bitwig).

I also ran the plugins through pluginval on both Linux and Mac, and they all pass.

Could one of you please run the plugins through pluginval on MacOS?

https://github.com/Tracktion/pluginval/blob/develop/docs/Testing%20plugins%20with%20pluginval.md

Alright, I got Windows 11 dual boot set up and testing the plugins. They all worked correctly in the DAWs I tested! (FL, Reaper, Bitwig). I also ran the plugins through pluginval on both Linux and Mac, and they all pass. Could one of you please run the plugins through pluginval on MacOS? https://github.com/Tracktion/pluginval/blob/develop/docs/Testing%20plugins%20with%20pluginval.md

Running cargo clippy produces quite a few warnings. Could you fix those please?

Running `cargo clippy` produces quite a few warnings. Could you fix those please?

Though I imagine that the "unecessary cast" warnings from clippy might actually be platform-specific (as in the integer types might be different on different platforms). So you could slap #[allow(clippy::unnecessary_cast)] on those if that's the case.

Though I imagine that the "unecessary cast" warnings from clippy might actually be platform-specific (as in the integer types might be different on different platforms). So you could slap `#[allow(clippy::unnecessary_cast)]` on those if that's the case.
Author
Contributor
Copy link

Clippy warnings have been fixed. Some casts were actually unnecessary. And in some cases it's like you said; the integer types are sometimes different on different platforms.

Clippy warnings have been fixed. Some casts were actually unnecessary. And in some cases it's like you said; [the integer types are sometimes different on different platforms](https://github.com/coupler-rs/vst3-rs/blob/master/src/support.rs#L208-L212).
Author
Contributor
Copy link

I ran pluginval on macOS for all the plugins in this repository. There is no regression.

But there are some issues that are also present on the main branch. I will list them briefly here. I can open some separate issues and add more detailed descriptions there. The issues are:

  • byo_gui_gl crashes immediately on load
  • byo_gui_softbuffer doesn't look right compared to byo_gui_wgpu. But or is it supposed to look like this? See the attached screenshots.
I ran pluginval on macOS for all the plugins in this repository. There is no regression. But there are some issues that are also present on the main branch. I will list them briefly here. I can open some separate issues and add more detailed descriptions there. The issues are: - byo_gui_gl crashes immediately on load - byo_gui_softbuffer doesn't look right compared to byo_gui_wgpu. But or is it supposed to look like this? See the attached screenshots.

Yes, the softbuffer example is supposed to look like that (I pulled the example rainbow gradient from the "hello world" example in the softbuffer repository.) I should probably add some screenshots of those examples so people know what it's supposed to look like.

What happens when you run byo_gui_gl in standalone mode? (cargo run --package byo_gui_gl)

Yes, the softbuffer example is supposed to look like that (I pulled the example rainbow gradient from the "hello world" example in the softbuffer repository.) I should probably add some screenshots of those examples so people know what it's supposed to look like. What happens when you run `byo_gui_gl` in standalone mode? (`cargo run --package byo_gui_gl`)

But yeah, byo_gui_gl crashing could be a separate issue.

I'm happy to merge this PR if everyone else is!

But yeah, byo_gui_gl crashing could be a separate issue. I'm happy to merge this PR if everyone else is!
BillyDM left a comment
Copy link

Oh actually, there's one more small thing I want clarified.

Oh actually, there's one more small thing I want clarified.
@ -53,2 +53,4 @@
}
unsafeimpl<P: Vst3Plugin>SendforWrapperGuiContext<P>{}
unsafeimpl<P: Vst3Plugin>SyncforWrapperGuiContext<P>{}
Owner
Copy link

I noticed you added unsafe Send + Sync implementations for WrapperGuiContext and WrapperInner. Is this necessary?

I noticed you added unsafe Send + Sync implementations for `WrapperGuiContext` and `WrapperInner`. Is this necessary?
Author
Contributor
Copy link

That's a good question. I copied this from Micah's work.

The Send + Sync traits are necessary. WrapperInner is shared across threads. See the schedule_gui function for instance: https://codeberg.org/davemollen/nice-plug/src/branch/main/crates/nice-plug/src/wrapper/vst3/inner.rs#L415-L441.
But to be honest; I don't fully understand how this used to work without Send + Sync before.

That's a good question. I copied this from Micah's work. The Send + Sync traits are necessary. `WrapperInner` is shared across threads. See the schedule_gui function for instance: https://codeberg.org/davemollen/nice-plug/src/branch/main/crates/nice-plug/src/wrapper/vst3/inner.rs#L415-L441. But to be honest; I don't fully understand how this used to work without Send + Sync before.
Owner
Copy link

Aha! Found the issue. It's a little bit involved to fix, so I'll just fix it myself after merging this PR.

Aha! Found the issue. It's a little bit involved to fix, so I'll just fix it myself after merging this PR.
Owner
Copy link

Oh yeah, forgot I can just push changes to the PR myself, I'll do that real quick.

Oh yeah, forgot I can just push changes to the PR myself, I'll do that real quick.
BillyDM marked this conversation as resolved
Author
Contributor
Copy link

@BillyDM wrote in #29 (comment):

Yes, the softbuffer example is supposed to look like that (I pulled the example rainbow gradient from the "hello world" example in the softbuffer repository.) I should probably add some screenshots of those examples so people know what it's supposed to look like.

What happens when you run byo_gui_gl in standalone mode? (cargo run --package byo_gui_gl)

Alright, good to know the softbuffer example looks like it's supposed to. I assumed it would be the same UI as the wpgu example. Never assume...

Running cargo run --package byo_gui_gl gives the same error. I opened this issue for it.

@BillyDM wrote in https://codeberg.org/RustAudio/nice-plug/pulls/29#issuecomment-16201091: > Yes, the softbuffer example is supposed to look like that (I pulled the example rainbow gradient from the "hello world" example in the softbuffer repository.) I should probably add some screenshots of those examples so people know what it's supposed to look like. > > What happens when you run `byo_gui_gl` in standalone mode? (`cargo run --package byo_gui_gl`) Alright, good to know the softbuffer example looks like it's supposed to. I assumed it would be the same UI as the wpgu example. Never assume... Running `cargo run --package byo_gui_gl` gives the same error. I opened [this issue](https://codeberg.org/RustAudio/nice-plug/issues/32) for it.

Ok, I'm thinking it's good to merge now. Thanks for all your help!

Ok, I'm thinking it's good to merge now. Thanks for all your help!
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RustAudio/nice-plug!29
Reference in a new issue
RustAudio/nice-plug
No description provided.
Delete branch "davemollen/nice-plug:switch-vst3-crate"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?