1
0
Fork 0
Commit graph

309 commits

Author SHA1 Message Date
Robbert van der Helm 1d6a9aac74 Add a way to fetch a parameter's default value 2022-02-08 23:51:07 +01:00
Robbert van der Helm 19bf213204 Add alignment specifiers and soundness comment 2022-02-08 23:16:32 +01:00
Robbert van der Helm 0ddfae1dd3 Also mode the factory to its own module
Now you can finally find the thing you're looking for.
2022-02-08 22:32:54 +01:00
Robbert van der Helm 05b9d4dd0b Move the main VST3 wrapper to a module 2022-02-08 22:28:18 +01:00
Robbert van der Helm 08fe8e703e Explicitly guarantee no simultaneous editors exist 2022-02-08 20:16:04 +01:00
Robbert van der Helm 02115d5004 Use a patched {egui-,}baseview for X11 GL contexts 2022-02-07 21:58:59 +01:00
Robbert van der Helm 0fb8ce6f7e Add part of a Windows event loop implementation 2022-02-07 00:33:41 +01:00
Robbert van der Helm ce37ec288e Don't store a GUID in the factory
This isn't actually needed.
2022-02-07 00:19:05 +01:00
Robbert van der Helm c9a5818cb4 Fix Windows entry point names 2022-02-06 23:37:40 +01:00
Robbert van der Helm df76047419 Move the process context to its own module 2022-02-06 18:51:46 +01:00
Robbert van der Helm 37a8f529b0 Move WrapperView to its own module 2022-02-06 18:46:16 +01:00
Robbert van der Helm 9db4c0d691 Move inner wrapper to its own module
We'll need to do this with the other parts as well. Navigating this
module has become practically impossible
2022-02-06 17:50:15 +01:00
Robbert van der Helm 427c7674b9 Move VST3 pointer check macros to a module 2022-02-06 17:40:35 +01:00
Robbert van der Helm 556bec7c0b Move editor handling to its own struct
This makes the API much, much nicer (especially consuming the egui
wrapper), and it also avoids having to lock the plugin instance which is
obviously very bad if the plugin is also supposed to be processing audio
on another thread.
2022-02-06 17:12:57 +01:00
Robbert van der Helm 3ede5ed751 Move the TODO on GUI opening xruns 2022-02-06 15:32:54 +01:00
Robbert van der Helm 3bd3696abe Put the no_alloc guard around entire process call 2022-02-06 15:24:18 +01:00
Robbert van der Helm f644ae8df8 Don't require a write lock to create an editor 2022-02-06 15:22:30 +01:00
Robbert van der Helm 7000e9d42e Don't propagate parameter changes while processing
Let the host do this, this would solve all unsoundness issues and
potential collisions.
2022-02-06 14:15:43 +01:00
Robbert van der Helm 5017dad7d3 Add a semi-broken GUI example
This needs a lot of work. We need widgets that know how to deal with our
parameters, and also basic widgets for things like meters. Egui-baseview
also has a couple quirks left. Most notably it only updates when
actively moving over the GUI (which means VU meters look pretty janky)
and it randomly panics.
2022-02-06 13:16:28 +01:00
Robbert van der Helm 33ad2d0b15 Fix typo in buffer iterator 2022-02-06 12:59:29 +01:00
Robbert van der Helm c4b983baf8 Implement ExactSizeIterator for the buffer adapter 2022-02-06 12:45:13 +01:00
Robbert van der Helm 2486368d08 Use AtomicF32 for the smoothing
This should at least not have a big performance impact since we can use
relaxed memory ordering here. AtomicCell always uses acquire/release
ordering.
2022-02-06 03:43:59 +01:00
Robbert van der Helm 6db85c535f Move ParamSetter creation to its own struct
This cannot be called from the trait object.
2022-02-06 01:52:16 +01:00
Robbert van der Helm bf070fce5a Use atomics in the smoother
This is needed so we can share the params with the editor, but it isn't
great, is there a better alternative?
2022-02-06 01:33:19 +01:00
Robbert van der Helm 29a9c41389 Delay the process_wrapper() use
The other parts also don't allocate, but parking_lot doesn't play nicely
when spawning an editor thread. In that case its hashmap may get resized
on the audio thread which is not what we want, but it won't cause any
real problems.
2022-02-06 00:51:18 +01:00
Robbert van der Helm d35957db65 Require static lifetimes on GUI contexts 2022-02-06 00:22:15 +01:00
Robbert van der Helm 3c867f9305 Allow all platform constants to be unused 2022-02-06 00:22:15 +01:00
Robbert van der Helm 7a6bfa4573 Add a HasRawWindowHandle wrapper struct 2022-02-06 00:22:15 +01:00
Robbert van der Helm 4021b28155 Fix rustdoc links 2022-02-06 00:22:15 +01:00
Robbert van der Helm b1afe0b224 Downgrade raw-window-handle for baseview compat 2022-02-06 00:22:15 +01:00
Robbert van der Helm 7b14106505 Update local parameters when changing from GUI 2022-02-05 22:26:42 +01:00
Robbert van der Helm 83c3410736 Don't require Send+Sync on the editor 2022-02-05 20:48:21 +01:00
Robbert van der Helm 75435ecb4a Don't require a Drop bound on Editor
On second thought, unless you're implementing something completely from
scratch this will already be part of the library you're using.
2022-02-05 20:15:09 +01:00
Robbert van der Helm 9d20ca8106 Add an idea for how the IRunLoop can be integrated 2022-02-05 19:35:20 +01:00
Robbert van der Helm 7e240146b7 Implement IPlugView 2022-02-05 18:42:06 +01:00
Robbert van der Helm 895dada6f6 Add window type constants missing from vst3_sys 2022-02-05 18:41:54 +01:00
Robbert van der Helm 2a0fde2fd5 Create a plugview if the plugin has an editor
The plugview, however, is still filled with stubs.
2022-02-05 18:07:03 +01:00
Robbert van der Helm ea8edf2563 Move the editor to the IPlugView instance
This way the RAII make much more sense.
2022-02-05 18:06:52 +01:00
Robbert van der Helm 4c5622cf40 Implement GuiContext for the VST3 wrapper 2022-02-05 17:47:55 +01:00
Robbert van der Helm 640fe0ebd7 Make parameter pointers hashable
So we can use have generic APIs that take a `Param` implementation and
know how to map those to the parameter IDs used by the plugin API.
2022-02-05 17:43:15 +01:00
Robbert van der Helm e97082aba2 Implement the ParamSetter 2022-02-05 17:32:57 +01:00
Robbert van der Helm 0bc8f9b5b1 Move preview_{normalized,plain} to Param
We're going to need this for setting parameter values with a gneric API.
2022-02-05 17:32:06 +01:00
Robbert van der Helm 9d2ddf016a Add Editor and GuiContext stubs in VST3 wrapper 2022-02-05 17:15:07 +01:00
Robbert van der Helm b075d1b1bb Modify the editor API to use trait objects
The alternative isn't really feasible without specialization, and
NIH-plug should work on the stable compiler.
2022-02-05 17:12:03 +01:00
Robbert van der Helm e4c6c6c25b Update the documentation on the updated GuiContext 2022-02-05 17:10:17 +01:00
Robbert van der Helm 3e2dc92b22 Avoid destructuring assignment
Somehow the nightly compiler just lets you do this without needing to
opt in to the unstable feature.
2022-02-05 16:46:29 +01:00
Robbert van der Helm fe96b8572e Type erase GuiContext by splitting the safe API
These functions not being able to be made into an object was the whole
reason why we needed the associated type in the first place. This will
make everything much nicer to work with, since
specialization/overlapping instances is still not possible with the
stable compiler.
2022-02-05 16:30:33 +01:00
Robbert van der Helm 1f2029ecbe Replace spawn_unchecked with static lifetimes
These things don't need to hold references, so this gets rid of some
nasty c ode.
2022-02-05 16:09:59 +01:00
Robbert van der Helm 1e77a92285 Require plugins to be 'static
They can't contain any references anyways since they're default
initialized. If they don't have a 'static lifetime, then it won't be
possible to pass a trait object casted from the inner wrapper to the
plugin.
2022-02-05 16:03:16 +01:00
Robbert van der Helm 78a83d5051 Allow unused variables in trait defaults 2022-02-05 13:32:03 +01:00
Robbert van der Helm d2407db284 Replace editor close function with a Drop bound 2022-02-05 13:06:18 +01:00
Robbert van der Helm b901dac012 Disambiguate rustdoc link references 2022-02-05 12:56:03 +01:00
Robbert van der Helm 63d30d33e4 Fix rustdoc links 2022-02-05 12:52:34 +01:00
Robbert van der Helm 7ac1df0d8d Add stubs for editor handling 2022-02-05 12:46:26 +01:00
Robbert van der Helm bbc190c67f Hold the RwLock guard in the process context
This avoids having to constantly acquire a new lock.
2022-02-04 23:03:11 +01:00
Robbert van der Helm ce3da8ea44 Use a dedicated struct for the process context 2022-02-04 22:55:10 +01:00
Robbert van der Helm 209c19b74f Get rid of lifetime parameters for VST3 wrapper
This lifetime didn't make any sense anyways since these buffers don't
adhere to Rust's lifetime rules. Getting rid of these will let us make
nicer wrappers around the process context.
2022-02-04 22:54:28 +01:00
Robbert van der Helm cbd51b0c3a Monomorphize the context variables
For the parameter setting context functions we don't be able to use
trait objects.
2022-02-04 22:34:53 +01:00
Robbert van der Helm f2d3d987a0 Update the current MIDI support status 2022-02-04 22:31:43 +01:00
Robbert van der Helm a93ad650be Remove old todo 2022-02-04 19:04:36 +01:00
Robbert van der Helm 4c0031d7b3 Fix clippy lints 2022-02-04 18:42:42 +01:00
Robbert van der Helm 073fe743c2 Split up set_target and reset in smoothers
This makes it a bit less awkward to use in user code, if you need a
separate smoother there.
2022-02-04 15:17:42 +01:00
Robbert van der Helm 366deda83c Add MIDI support to the sine example 2022-02-04 15:17:42 +01:00
Robbert van der Helm fdfd1b01c2 Add a function for retrieving the next note event 2022-02-04 15:17:42 +01:00
Robbert van der Helm 0e67c61be0 Store timing along with the note events 2022-02-04 15:17:42 +01:00
Robbert van der Helm 02cf16e9c0 Accept incoming note events 2022-02-04 15:17:42 +01:00
Robbert van der Helm 51dace591d Add an event bus depending on ACCEPTS_MIDI 2022-02-04 15:17:42 +01:00
Robbert van der Helm aee3775c10 Add default implementations for most trait methods
Except for process()
2022-02-04 15:17:42 +01:00
Robbert van der Helm 74e0fa5964 Add defaults for some of the plugin constants 2022-02-04 15:17:42 +01:00
Robbert van der Helm f69fdcef5f Add another plugin constant for MIDI support 2022-02-04 15:17:42 +01:00
Robbert van der Helm c1f435d909 Refer to the gain plugin in the Params trait 2022-02-03 17:05:38 +01:00
Robbert van der Helm fc96bb4349 Fix channel map debug assertion 2022-02-03 17:03:33 +01:00
Robbert van der Helm dfb73f6902 Mention the 6 character overflow limit for IDs 2022-02-03 17:02:42 +01:00
Robbert van der Helm 30609c3ecd Add an is_smoothing() check 2022-02-03 16:51:41 +01:00
Robbert van der Helm 82dfee9313 Document the FTZ flags in the process function 2022-02-03 16:22:32 +01:00
Robbert van der Helm e642fb5ff8 Make sure FTZ is always enabled 2022-02-03 16:18:24 +01:00
Robbert van der Helm dfedd7b2c4 Enable assert_no_alloc in debug builds 2022-02-03 15:58:00 +01:00
Robbert van der Helm 2ca54d220d Add logarithmic smoothing 2022-02-02 23:00:17 +01:00
Robbert van der Helm 1ad477ee4f Add smoothing tests 2022-02-02 22:34:29 +01:00
Robbert van der Helm 1c80744989 nih_debug_assert_neq -> nih_debug_assert_ne 2022-02-02 22:29:14 +01:00
Robbert van der Helm da291175d1 Rename SmoothLinear to Linear
We'll rethink this when we get to sample accurate automation.
2022-02-02 22:00:00 +01:00
Robbert van der Helm 0ecec104fb Completely reset smoothing on init or restore 2022-02-02 21:41:20 +01:00
Robbert van der Helm 1336139a65 Update smoothers on init and state restore
Otherwise this would be filled with default values.
2022-02-02 21:33:20 +01:00
Robbert van der Helm e30a72888a Add an update_smoother() parameter method 2022-02-02 21:26:34 +01:00
Robbert van der Helm ea7dc2ffa3 Implement smoothing for integers 2022-02-02 21:26:20 +01:00
Robbert van der Helm 8f89754ba5 Add simple linear parameter smoothing 2022-02-02 21:26:13 +01:00
Robbert van der Helm fced4001c0 Access plain values using the method
Since we're also setting them using the method.
2022-02-02 20:39:04 +01:00
Robbert van der Helm a42649b2de Derive a Default instance for the Buffer
To make Clippy happy.
2022-02-02 20:37:06 +01:00
Robbert van der Helm 13369e4085 Reinitialize the plugin after restoring state
This lets you use the parameters to set fields on the plugin struct
during `initialize()`.
2022-02-02 15:39:55 +01:00
Robbert van der Helm c982ad9599 Avoid duplicate state restores 2022-02-02 15:32:21 +01:00
Robbert van der Helm c8cc6bd26b Re-export all user facing includes 2022-02-02 15:16:10 +01:00
Robbert van der Helm f44597df7c Move the buffer adapter to its own module 2022-02-02 15:01:41 +01:00
Robbert van der Helm 048d69213e Make the buffer own the output slices
This gets rid of a lot of lifetime casting and other unsoundness.
2022-02-02 14:41:35 +01:00
Robbert van der Helm fbadfe3e12 Fix clippy lints 2022-02-02 13:02:28 +01:00
Robbert van der Helm 6cde9cea0e Simplify spawn_unchecked lifetime transmute 2022-02-02 13:02:28 +01:00
Robbert van der Helm 58736f5cc8 Add a super unsafe channel buffer adapter
To avoid having to perform lifetime magic here, this buffer needs to own
the slices and be stored as part of the RwLock.
2022-02-02 13:02:28 +01:00
Robbert van der Helm 63e4a54d7c Center skewed parameters around the skew center
It's a bit awkward and you can completely lose some parts of the range
if you don't do this.
2022-02-02 00:06:07 +01:00
Robbert van der Helm 1202b2b9d6 Update unimplemented features list
These things are now all implemented.
2022-02-01 23:39:13 +01:00
Robbert van der Helm 7752ce6771 Add symmetrically and asymmetrically skewed ranges
This is super useful. I'm sure the symmetrical implementation can be
optimized a lot, but my math-fu was not strong enough today.
2022-02-01 23:37:28 +01:00
Robbert van der Helm 740868a10c Move parameter ranges to their own module
This module was too difficult to navigate with parameter types + ranges
+ implementation details.
2022-02-01 21:06:13 +01:00
Robbert van der Helm 27bef6fbbc Move the param trait up in the module 2022-02-01 21:02:58 +01:00
Robbert van der Helm 4aa85b43b4 Move parameter implementation details to a module 2022-02-01 21:01:28 +01:00
Robbert van der Helm bc60dc35b6 Fix rustdoc references 2022-02-01 20:53:20 +01:00
Robbert van der Helm 6bb83061dd Rename the params module to param
It's a heterogeneous module, and splitting the ranges to their own
module will be a bit weird otherwise.
2022-02-01 20:51:22 +01:00
Robbert van der Helm 15e0f6f21a Remove unnecessary import
I was going to add that set_parameter function in the next commit, but
that will need to wait a bit.
2022-02-01 19:54:35 +01:00
Robbert van der Helm 473447179f Handle idempotent latency changes 2022-02-01 17:17:10 +01:00
Robbert van der Helm e2e2c59d34 Pass the process context to the plugin 2022-02-01 17:09:23 +01:00
Robbert van der Helm 3a1fbed4c3 Mark MainThreadExecutor::execute as unsafe
This should only be called from the main thread. Otherwise the API's
threading guarantees will not be upheld.
2022-02-01 17:01:05 +01:00
Robbert van der Helm 459175b470 Call the component handler for restarts 2022-02-01 16:59:11 +01:00
Robbert van der Helm 223d0c3a90 Take a reference to the component handler 2022-02-01 16:52:55 +01:00
Robbert van der Helm d47aac25a1 Rearrange WrapperInner parameters 2022-02-01 16:40:51 +01:00
Robbert van der Helm 565d9259c3 Use weak references to the executor
So this cyclic reference can't keep it alive.
2022-02-01 15:31:16 +01:00
Robbert van der Helm 98076ff792 Use a custom .spawn_unchecked without nightly req
Courtesy of Yandros on the Rust Discord.
2022-02-01 15:04:36 +01:00
Robbert van der Helm 8a0e083168 Add a TODO and stub for parameter smoothing 2022-02-01 00:14:33 +01:00
Robbert van der Helm b15991a495 Add a todo and stub for setting parameter values 2022-02-01 00:01:52 +01:00
Robbert van der Helm 735cec4fba Update context docs 2022-02-01 00:01:43 +01:00
Robbert van der Helm f009384c2f Don't require Arcs for ProcessContext
It makes more sense to pass this as a reference, so the plugin cannot do
weird things with it.
2022-01-31 23:47:54 +01:00
Robbert van der Helm 22995df7ea Actually only calculate hashes once 2022-01-31 22:42:36 +01:00
Robbert van der Helm 7c57ac6737 Fix typo in hash overflow warning 2022-01-31 22:39:11 +01:00
Robbert van der Helm 5aec636f9f Format boolean parameters as On/Off by default 2022-01-31 22:36:58 +01:00
Robbert van der Helm 0aad790fd7 Fix deserializing boolean parameters 2022-01-31 22:32:20 +01:00
Robbert van der Helm 85db4d82df Fix param_id_to_hash name
These were swapped for some reason.
2022-01-31 22:24:07 +01:00
Robbert van der Helm 880ee92a47 Drop param_id_to_hash
As it turns out, it's redundant (and also had the opposite name).
2022-01-31 22:23:29 +01:00
Robbert van der Helm fe8f1d27d6 Use a stable ordering for the parameters
As the fields are specified on the parameters struct.
2022-01-31 22:20:09 +01:00
Robbert van der Helm 260d38580b Warn on parameter hash overflow 2022-01-31 21:34:36 +01:00
Robbert van der Helm 54bcf52912 Add Default implementations for parameter types 2022-01-31 21:19:40 +01:00
Robbert van der Helm 6fc733e029 Add callbacks for parameter changes 2022-01-31 21:02:47 +01:00
Robbert van der Helm 44172da94f Use Arcs for the callbacks
So it becomes possible to reuse one callback for multiple parameters.
This will be important for value change notifications.
2022-01-31 20:44:10 +01:00
Robbert van der Helm c883e0000d Move the PersistentField implementations 2022-01-31 20:41:46 +01:00
Robbert van der Helm 4734a51440 Move wrapper data to an inner struct
This fixes the soundness issue with the use of Arc. Moving a `Box` to an
`Arc` frees the old boxed data, and the internal reference counting
would also try to free that. As an added benefit, we no longer need the
unsafe Send+Sync implementation for the event loop.
2022-01-31 20:18:12 +01:00
Robbert van der Helm 6c518fad9d Add stubs for using the event loop in VST3 wrapper 2022-01-31 19:47:16 +01:00
Robbert van der Helm 2380768bad Add a Linux-specific event loop
Implementations for Windows and macOS should be fairly similar, but
using the OS' message loop instad of a thread.
2022-01-31 19:45:11 +01:00
Robbert van der Helm 4495064558 Redesign the wrapper's interiors for thread safety
There are a lot of locks needed now here, but none of them should be
contended. This is much better than potentially having RefCell's blow up
due to simultaneous mutable borrows, and the Arc is needed for the event
loop.
2022-01-31 19:44:02 +01:00
Robbert van der Helm b65158283a Support parking_lot mutexes and rwlocks 2022-01-31 19:42:35 +01:00
Robbert van der Helm 1a2c90fdfd Set the VST3 parameter step counts 2022-01-31 13:33:30 +01:00
Robbert van der Helm 6494d1ed5f Store persistent fields as plain JSON strings
On second thought, this is much better. The resulting file size will be
much smaller because only double quotes need to be escaped. It's also
easier to read at a glance.
2022-01-30 18:23:13 +01:00
Robbert van der Helm 3111d75b29 Serialize custom persistent fields as base64
This still takes up more space than plain JSON would, but I don't know
if serde_json would allow inlining that JSON. Presumably not. It would
get hairy quickly as a regular embedded JSON string due to the encoding.
2022-01-30 18:15:01 +01:00
Robbert van der Helm 29a0f83163 Add a TODO on packing stored state 2022-01-30 17:29:25 +01:00
Robbert van der Helm f0ea9e9451 Fix broken rustdoc links 2022-01-30 17:17:34 +01:00
Robbert van der Helm a4606f41cd Add more TODOs for parameters and persistence 2022-01-30 17:16:12 +01:00
Robbert van der Helm 64cf04a77d Add a todo about parking_lot 2022-01-30 17:10:42 +01:00
Robbert van der Helm 486fc67a4b Serialize persistent fields for VST3 plugins 2022-01-30 17:09:18 +01:00
Robbert van der Helm 221e424f78 Use thread safe interior mutability for persist
Sadly there's not really a safe way to do this otherwise, but if you
really want to have persistence this way and absolutely need it to be
lock-free (because you're going to use it from the GUI thread), then you
can implement your own PersistentField.
2022-01-30 17:07:50 +01:00
Robbert van der Helm 8ac036f6cc Add an API for persisting arbitrary fields 2022-01-30 16:14:52 +01:00
Robbert van der Helm c286958c63 Swap around trait bound order 2022-01-30 13:15:42 +01:00
Robbert van der Helm b76b6e4a9b Add boolean parameters 2022-01-30 02:17:40 +01:00
Robbert van der Helm 7feb8006ef Persist the bypass parameter 2022-01-30 02:04:35 +01:00
Robbert van der Helm 16238f1e00 Support VST3 parameter flushes 2022-01-30 01:50:22 +01:00
Robbert van der Helm 6ddae6a506 Handle the output channel map
I apparently committed this a bit too early.
2022-01-30 01:43:40 +01:00
Robbert van der Helm 0c24398234 Target vst3-sys fork with better pointer semantics 2022-01-30 01:37:10 +01:00