Commit Graph

792 Commits

Author SHA1 Message Date
Robbert van der Helm 503d8248c2 Refactor VST2 serialization primitives
Bundle all serialization function with the structs whenever possible to
simplify the serialization function, and add `Foo::Response` types so we
can make the `passthrough_event()` function slightly more type safe.
2021-06-10 13:13:01 +02:00
Robbert van der Helm cacfc0b379 Fix serializing VST2 speaker arrangements 2021-06-10 13:05:47 +02:00
Robbert van der Helm 5a38a2e482 Lock mapped shared memory for audio buffers 2021-06-10 01:35:43 +02:00
Robbert van der Helm a3aaeaa9a9 Mention that busses and channels are zero indexed 2021-06-09 20:47:52 +02:00
Robbert van der Helm 2210cb4fc3 Implement move semantics for shared audio buffer 2021-06-09 20:35:47 +02:00
Robbert van der Helm 9d11b501cd Add a shared memory based audio buffer
We'll be using this to reduce the amount of copying we have to do during
audio processing.
2021-06-09 20:06:57 +02:00
Robbert van der Helm e36a7e7e72 Add the effSetProcessPrecision opcode 2021-06-09 18:41:34 +02:00
Robbert van der Helm 70d18edce2 Fix version strings when building from tarball
When that tarball has been extracted in an (unrelated) git repository.
2021-06-09 16:19:01 +02:00
Robbert van der Helm c97595a391 Mark Vst{2,3}Sockets as final
Since we're calling a virtual method during the destructor.
2021-06-09 13:04:51 +02:00
Robbert van der Helm 7c9cd7b9e5 Fix uninitialized timed caches
This could prevent resizeable plugins from being resizeable in Ardour if
the initialized timestamp just happened to be greater than the current
time, since the returned result would then likely be some invalid value.
2021-06-09 12:31:03 +02:00
Robbert van der Helm a7496fae77 Add thread names 2021-06-06 23:45:47 +02:00
Robbert van der Helm 3baccf885d Remove old todo 2021-06-01 18:18:44 +02:00
Robbert van der Helm 5f4ffed90b Prevent allocations in Vst3Logger::log_query_interface
String constants will be converted to `std::string` because it's not
constexpr yet, and that will allocate for longer strings. Since this
function only prints something when `YABRIDGE_DEBUG_LEVEL` is set to 2
or higher that seems like a waste.
2021-05-31 18:07:19 +02:00
Robbert van der Helm 2bf1c4c5eb Use C++20 [[unlikely]] instead of BOOST_UNLIKELY 2021-05-31 17:50:02 +02:00
Robbert van der Helm 6a047497bc Only print query interface messages on log level 2 2021-05-31 17:44:43 +02:00
Robbert van der Helm 70467a31dc Fix compilation under GCC 11 2021-05-30 17:54:45 +02:00
Robbert van der Helm b3d5a39001 Fix debug builds after small vector optimization 2021-05-30 00:05:36 +02:00
Robbert van der Helm b4c9f53bcf Fix typo in the in place std::variant<> extension
We of course want to do this for non-trivial types as mentioned in the
comment above, not for trivial types...
2021-05-28 14:17:35 +02:00
Robbert van der Helm f533dd40ce Make the in place std::variant<> extension smarter
With the suggestions to use `std::get_if<>` and to only do this for
nontrivial types from
https://github.com/fraillt/bitsery/issues/76#issuecomment-850371533.
2021-05-28 14:11:50 +02:00
Robbert van der Helm 0d3850e837 Add a function for fetching the RTTIME limit
We can use this to more easily diagnose issues caused by PipeWire.
2021-05-27 13:58:19 +02:00
Robbert van der Helm 4d5b2fcb12 Add missing quotes in IEditController::getParamValueByString() log message 2021-05-23 19:45:29 +02:00
Robbert van der Helm 1464ec2ab0 Use text2b instead of container2b for u16string
Should be equivalent. The only reason why we use container2b in some
places is because strings based on `Steinberg::char16` arrays will have
an incorrect length on the Wine side, because character traits for
`wchar_t` is still reflects Linux instead of Windows there.
2021-05-23 19:33:27 +02:00
Robbert van der Helm 95de9ea0bf Set a better maximum on text in strings in events 2021-05-23 19:30:34 +02:00
Robbert van der Helm 0b9b1330ad Make sure effProcessEvents() also never allocates
This basically changes the default small vectors during VST2 event
processing from 256 bytes to the size of a `DynamicVstEvents`
object (which also includes a small_vector to hold MIDI events without
allocating) and makes them thread local. We already have a similar
optimization for VST3. There it's a bit neater since we already had to
separate audio processing functions from non-time critical functions.
Here we don't have that separation, so we just made these buffers thread
local, large enough to hold our predefined number of events, and we then
just shrink them to fit if these buffers grow even more (which can only
happen after reading or writing chunk data).

The change doesn't specifically target `effProcessEvents()`, but that's
where you would see the differences. This is also relevant for
`audioMasterProcessEvents()`.
2021-05-23 17:37:09 +02:00
Robbert van der Helm 77d43e4f08 Increase the default serialization buffer size
Setting VST2 plugin parameters would sometimes result in allocations.
2021-05-23 16:45:01 +02:00
Robbert van der Helm 0b2ce6a05f Reduce duplication in VST3 audio buffers
Using C++20 templated lambdas.
2021-05-23 16:08:19 +02:00
Robbert van der Helm d2965e048d No longer zero out VST3 audio buffers
Apparently we also never did this for VST2 plugins, so this should be
safe. Filling the vectors with zeroes here had a non-negligible
performance impact according to perf.
2021-05-23 15:55:29 +02:00
Robbert van der Helm 4e81c1c2b3 Reuse request on Wine side during VST2 processing
The object was constantly being recreated, resulting in memory
allocations caused by creating and destroying the audio buffer vectors.
2021-05-23 15:02:53 +02:00
Robbert van der Helm 6f321649c4 Do small vector optimization for all communication
I once read years ago somewhere on Stack Overflow that `std::vectors`
with that are preinitialized to a default size would allocate the
initial capacity on the stack. This of course doesn't make any
sense (run time sized stack allocations can cause all kinds of issues),
so we were still allocating with our default 64-byte sized buffers, but
just not as often.
2021-05-23 14:43:02 +02:00
Robbert van der Helm a5ba3bdf33 Also define type erased small_vector extension
So bitsery knows how to handle small vectors that don't have a compile
time known size as well.
2021-05-23 14:27:55 +02:00
Robbert van der Helm df93944f3b Prevent allocations caused by Logger::log_trace
C++ would always construct an `std::string` from the string constant
every iteration. Since this also happened when `YABRIDGE_DEBUG_LEVEL` is
not set to 2, this ended up causing unnecessary allocations.
2021-05-23 00:21:21 +02:00
Robbert van der Helm cf2fbf602c Increase number of preallocated VST3 events to 64
To match the VST2 version. I found that 32 was slightly too low when
feeding a plugin with something that starts to resemble black MIDI.
2021-05-23 00:10:50 +02:00
Robbert van der Helm e700678a11 Also preallocate small buffers for VST2 events 2021-05-23 00:10:03 +02:00
Robbert van der Helm 095ca11535 Add alignment hints to types stored in containers 2021-05-22 23:45:52 +02:00
Robbert van der Helm da8f4aae19 Preallocate small vectors for VST3 queues
Events, parameter changes, and the individual queues contained within
the parameter changes all use dynamic memory allocation. Preallocating
some memory for those things inside of the objects may prevent latency
spikes when they those objects are first filled. This is especially
useful for the parameter changes since there's no way to reserve memory
in a vector of vectors.
2021-05-22 23:38:31 +02:00
Robbert van der Helm 90338abe6d Add bitsery trait for Boost.Container small_vector
I was going to implement these myself since we don't need them to be
contiguous like Boost's implementation is, but this is much easier of
course.
2021-05-22 23:25:36 +02:00
Robbert van der Helm 7c49fe739d Use our new custom std::variant bitsery extension
This prevents reinitializing `std::variant`s when the variant we want to
deserialize is already active. We store audio buffers in variants, so
reinitializing them results in a lot of unnecessary memory frees,
allocations and writes during every processing cycle.
2021-05-22 17:51:01 +02:00
Robbert van der Helm 6ee905c79f Add a realtime-safe bitsery extension for variants
I blindly assumed the original implementation also did this, but this
version `std::variant<Ts...>` objects from being reinitialized if we're
deserializing a variant that's also currently active in the object we're
deserializing into. For simple structs this won't make any difference,
but in yabridge we often use variants to differentiate between things
like single precision and double precision audio buffers. Those buffers
are allocated on the heap, so recreating the objects every time we
deserialize them adds a lot of unnecessary overhead.
2021-05-22 17:27:54 +02:00
Robbert van der Helm 88a45e6178 Prevent unnecessary copies during audio processing
We did a ton of work earlier to make sure we can reuse these objects,
but `auto` implies the type is never a reference type, and we were thus
unnecessarily creating copies every iteration, kind of defeating the
purpose of doing all of this in the first place. We could do some
template trickery here, but it's also safe to just make the persistent
object thread local since the actual objects aren't that large.
2021-05-22 16:07:11 +02:00
Robbert van der Helm 549306b295 Include effString2Parameter in opcode list
We don't need any special handling for this since our default argument
detection will handle strings, but it might be useful for log output if
a host ever uses this. At the moment there don't seem to be any hosts on
Linux that use this.
2021-05-21 02:03:27 +02:00
Robbert van der Helm 0e3a4f6d54 Move EventResultPayload to Vst2EventResult::Payload 2021-05-20 15:55:39 +02:00
Robbert van der Helm bd0dd63ad2 Rename the EventResult struct to Vst2EventResult 2021-05-20 15:53:16 +02:00
Robbert van der Helm 2bf41c6fe1 Move EventPayload to Vst2Event::Payload 2021-05-20 15:52:40 +02:00
Robbert van der Helm b1c9d75112 Rename the Event struct to Vst2Event 2021-05-20 15:50:09 +02:00
Robbert van der Helm 808cca3cb2 Always use static const instead of const static 2021-05-20 15:12:44 +02:00
Robbert van der Helm 3e6bf3adfd Allow overriding sending behaviour for VST2 events
Now we can implement mutual recursion for VST2 plugins. Wish we didn't
have to.
2021-05-20 14:49:11 +02:00
Robbert van der Helm ccfda51a69 Clarify the DefaultDataConverter method names 2021-05-20 14:49:11 +02:00
Robbert van der Helm 06bae784a8 Update documentation in passthrough_event()
There were some glaring typos in there. I probably replaced them with
new ones.
2021-05-20 14:31:59 +02:00
Robbert van der Helm 8bfaade2a6 Change wording in the MessageReference bitsery ext
I had to reread the docstrings to remember what `deseerialization_store`
was, so it probably needed a better name.
2021-05-20 14:31:59 +02:00
Robbert van der Helm c2186fa55b Use the std::derived_from concept when applicable
This probably makes things much clearer at a glance instead of using a
blanked typename.
2021-05-20 14:31:59 +02:00