-
Notifications
You must be signed in to change notification settings - Fork 23
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
Any plans to implement a VST host in rust? #7
Comments
This is definitely doable, it would essentially involve wrapping a dynamically loaded library (the plugin) in a some type of struct that handles passing VST opcodes between the host rust program and the plugin. If you (or anybody else) wants to try this, it'd probably look something like this: struct Plugin {...}
impl Plugin {
pub fn load(...) -> Plugin {...}
// For example
pub fn init(&mut self) {
// Send OpCode::Initialize to loaded library via vst2::api::AEffect::dispatcher
let opcode = vst2::plugin::OpCode::Initialize.into();
self.effect.dispatcher(self.effect_ptr, opcode, 0, 0, ptr::null_mut(), 0.0);
}
// Rest of VST opcodes ...
} I don't have any plans at the moment to support this but if I have some free time I might be able to cook up a prototype |
What are your thoughts about the process of showing the editors of hosted plugins from the DAW? Do you think it's possible? Easy? What would your instincts be about the first steps? |
I think it'd be actually fairly simple as the VST API only really requires a window pointer to be passed to the plugin. It would have to be a platform specific window pointer though, e.g. X11, WinAPI or Carbon on OS X (optionally Cocoa if the plugin and host both support it). Pretty sure this library would only have to open the platform specific editor window and pass it to the plugin for that to work. It gets a little bit more complex if you're building a plugin, as to actually interact with the editor window you need to use platform-specific APIs. That is a bit of a pain especially in rust, so there could potentially be another library built off this one that handles the platform specific stuff |
I'm actually only interested in the VST host part, so that sounds awesome! Any chance you might take a swing at it? I'd be happy to donate a few bucks! |
Yeah for sure, if I get some time this week/next week I'll try and get a working implementation |
Hey @overdrivenpotato if you can get a rust VST host working that can show client VST GUIs and process audio, I'll send you $50 via PayPal |
@ZECTBynmo any example plugins you'd like to load? |
@overdrivenpotato how about: |
Alright that seems doable, I'll update you when I get something running |
Awesome! Looking forward to it |
Just a quick update: most of the VST-related programming for this to work is finished, and I have been able to load and play around with Ozone 5. The only remaining problem is passing a window pointer to the plugin. I've gotten this to work via a forked version of glutin but I'm currently just writing a simpler stripped down window library to give more flexible options. It might just be a submodule in rust-vst2 as it is fairly specific but I'm debating just creating a new repository and pushing it to crates.io. |
Wow that is so cool @overdrivenpotato!!! I'm super excited to see it! |
Hey @overdrivenpotato, I'm also very interested in a VST host in Rust! |
I was using glutin initially as the window library, but with most of the functionality removed and with modifications to allow plugins to properly draw. I'm currently just writing a really small module to do exactly what glutin did but tailored to the VSTAPI. |
@overdrivenpotato do I owe you $50 yet? :) |
@ZECTBynmo everything except the editor should be functional. It ended up being a lot of work to get a window working (cross platform, OpenGL, key/mouse events, etc). If anybody is interested in resurrecting this project with me, I could pick it back up again but I haven't had the need to get an editor open in my own projects. |
@overdrivenpotato: I'm interested in this as well. I haven't done a host yet but I've worked on the plugin editor GUI. It would be useful if you can put your host on github, so we can collaborate.. I would really appreciate if someone could look into this so we can debug this, if we can debug this, we can use glutin with glium to render beautiful opengl UIs with shaders etc. |
The WIP window handling that I have is very rough and has no support for win32. I figured I'd get it working on OSX first, and then focus on win32 / X support. Using glutin I was able to load up a few iZotope plugins, but the module I began writing was never completed and I left it in a dysfunctional state. The documentation gets a little hazy when it comes to native window APIs, and Glutin had some issues with screen refreshes so the UI was very inconsistent. I guess we could proceed by using a glutin fork, but I have no easy access to a windows machine right now so I can't help out with debugging any errors that aren't OSX. @Boscop It seems that you're looking into creating UIs for plugins, the fork I mentioned was supposed to create windows for loaded plugins to use. As an aside: |
Usually the host runs the UI in a separate thread from the audio anyway, because ASIO needs the lowest latency (some say, don't even allocate in the ASIO thread, but the way we did the midi event handling allocates... Usually a preallocated buffer is used that should be large enough for all midi events that could happen in a frame). |
Maybe there is a way of using Electron from GitHub to do the gui? |
Something like electron would be perfect, but I don't think electron is designed to be embedded on it's own. If we could get CEF working with a rust-vst API to communicate control changes and audio information, that would allow plugin developers to design professional UIs really quickly with existing tooling. I have a test project with electron that looks like this at the moment: Let's move discussion over to #9 |
Having gone pretty far down this road for C++ VST plugins, embedding CEF in
a useful way as a pure control surface is easy, but getting hooks into the
chromium audio loop is very difficult. Chromium has no hooks to give
external applications access to lower level audio streams, and there's no
reliable way to capture page audio via injected client side JS. If there's
a workaround or some new audio hooks I'd love to hear about it, but IMHO
this is more difficult than it sounds.
…On Thu, Jan 26, 2017 at 8:52 PM, Marko Mijalkovic ***@***.***> wrote:
Something like electron would be perfect, but I don't think electron is
designed to be embedded on it's own. If we could get CEF working with a
rust-vst API to communicate control changes and audio information, that
would allow plugin developers to design professional UIs really quickly
with existing tooling.
I have a test project with electron that looks like this at the moment:
[image: electron]
<https://camo.githubusercontent.com/4585d84b75e52221a8de57d88f21015a6b6a976b/687474703a2f2f692e696d6775722e636f6d2f6f4268323464712e706e67>
But I have a feeling that integrating CEF will be a lot of work. Perhaps
we could create another library which uses the exposed editor trait in this
one, to keep the VSTAPI guts separated from a CEF UI.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKo2E6YOsuIgN0kyfhoH4O6WwFOAPGPks5rWU3wgaJpZM4GDmE8>
.
|
You don't need to get hooks into the chromium audio loop though. You just use a library that will talk directory to the machines audio. Something like PortAudio which is a well know audio API and has bindings for Rust. The CEF window would serve only as a control surface for an underlying application. Or in the case of VST plugins you would only have to have the window communicate with the plugin because the VST is being hosted by a program that takes care of the audio io for you. |
@zyvitski Unfortunately hooking into system audio is also difficult to do (at least on OSX). Things like PortAudio can monitor samples for existing audio inputs/outputs, but they can't get a hook into the global system output (which is where Electron audio would go). Products like SoundFlower exist to create an additional output device that acts as you'd want, but they work by patching the kernel, so it's a very high-touch solution. |
I think there are 2 different discussions going on here. CEF would only be
useful for plugin creators.
When it comes to DAW development, we only need a window opened via native
system APIs, no CEF involved. The rest is up to the loaded plugin. This
library should be able to integrate into any DAW without imposing UI
restrictions.
Regarding creating plugins, if we use CEF we would need some sort of
channel to communicate control changes, but the actual audio processing
would still be written in rust. It would be up to the DAW loading the
plugin to provide us with an audio buffer we have to fill.
…On Fri, Jan 27, 2017, 3:22 PM Mike Vegeto ***@***.***> wrote:
@zyvitski <https://github.com/zyvitski> Unfortunately hooking into system
audio is also difficult to do (at least on OSX). Things like PortAudio can
monitor samples for existing audio inputs, but they can't get a hook into
the global system output. Products like SoundFlower exist to create an
additional sound output that acts as you'd want, but they work by patching
the kernel, so it's a very high-touch solution.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE_5eop6wRO4VX0RLQ_S7dg3yOH-9BrVks5rWlH0gaJpZM4GDmE8>
.
|
Agreed on all points - CEF isn't relevant to opening existing plugin UIs, and if a CEF UI library is built keeping processing in Rust would dodge questions about the Chromium audio loop. On the topic of opening Ozone, I'm almost positive that iZotope plugins (and likely others) will crash if they're not instantiated on the host's main thread. That may have been one of the issues preventing it from working as expected. |
My point though is that in regards to the creation of a DAW or even a minimal VST host. You wouldn't need to be able to create it destroy virtual audio devices, all you would need is the ability to interface with an existing device. If the user wanted to interact with a different device then they could use something like sound flower to create one which should be recognized by a library like portaudio as a valid device and thus giving the ability to connect to it. |
Excuse me if I'm being dense (I'm still starting out with Rust & VST development), but wouldn't something like Electron cause a lot of unnecessary overhead? Apps that utilize HTML frameworks like Slack/Discord tend to feel very sluggish compared to native stuff. I might be wrong, though! Screenshot looks really cool @overdrivenpotato :) |
@piedoom there would most likely be extra overhead using electron. But the important things to note would we that the overhead would not be tied to the audio processing thread so there wouldn't be any performance differences to the actual audio and that the using web UI tech would make creating GUI's much easier. So it's somewhat of a trade off. It's also worth noting that the scale of the application being written does factor in, for a simple UI Electron may perform just as well as a native UI. It all depends on how complex the UI is and how much animation is being used, etc... |
Maybe integrate servo, to shift the rendering to the GPU ;) From my experience, it's much easier to make nice GUIs with web technologies than with hardcoding stuff. Separation of concerns. You can iterate much faster if you develop the GUI outside of the plugin because building and linking the plugin dll takes forever. But with browserSync you hit save in the editor and the Browser reloads the page.. It also makes it possible to easily have resizable / scalable vector GUIs like Meldaproduction. As for the audio, the host needs to open the audio device, not the plugin. The host can use something like portaudio, RtAudio, or any platform-specific api like ASIO directly to open devices. |
Any updates on this? I've been looking around for something like https://github.com/teragonaudio/MrsWatson in Rust! |
@cdbattags I think this project is orphaned, take at look at this fork github.com/rust-dsp/rust-vst that is actively developed. |
I would LOVE to see that happen!
The text was updated successfully, but these errors were encountered: