Closed Boscop closed 3 years ago
Better don't use reaper-high
. The high stands for highly unstable ;)
You can do that in a much more stable way using the medium-level API: ReaperSession::plugin_register_add_csurf_inst()
. This method also has an example doc.
Not sure why yours didn't work but getting the control surface stuff to work in Rust was quite some effort because it's interfacing with C++ virtual classes.
Thanks for the quick reply :)
So it seems like I then only need to impl set_track_list_change
and ext_set_fx_change
to be notified whenever a track or effect is added/removed/renamed?
If you don't mind which track, yes. REAPER calls set_track_list_change
in many situations. You need some more elaborate mechanism to detect what has been changed. This is only in reaper-high
at the moment. You can have a look here to see how it works: ChangeDetectionMiddleware
.
Thanks, and which value should I return from ext_set_fx_change
?
Before reaper-rs existed I wrote a VST plugin that I now want to port to using reaper-rs.. I've been using my own hacky Reaper API bindings, and they worked well for calls but I couldn't figure out how to get notified when the configuration of tracks or effect plugins changes. I had tried to register my VST as a control surface but it wasn't being called for some reason. (This was my attempt at writing a Rust API for registering a control surface, and then in my VST state I'd have a member
surface: MyControlSurfaceHandle<MySurface>
and this impl:But it logged nothing when I loaded the VST in Reaper.. Any idea why it didn't work?)
How would it be done with reaper-rs? I see that in the readme you have an example like this:
rx.track_removed().subscribe(|t| println!("Track {:?} removed", t));
But that's part of the unreleased crate for which there is no doc. It looks like the relevant events are all handled already: https://github.com/helgoboss/reaper-rs/blob/faf49999c7a76cb82a613c80f73334c225c9f823/main/rx/src/control_surface.rs#L33-L36 So I guess my main question is: How can I use this? / Where should I get therx
handle from? :) And is there anything else I need to take into account (e.g. regarding when those events are sent)?