mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-13 20:09:59 +02:00
Use the small buffer optimization for VST3 SysEx
We apparently didn't do that yet. SysEx should be super rare (outside of octave switching on Arturia keyboards), but there's still no reason not to do it.
This commit is contained in:
@@ -24,9 +24,12 @@ YaDataEvent::YaDataEvent(const Steinberg::Vst::DataEvent& event) noexcept
|
||||
: type(event.type), buffer(event.bytes, event.bytes + event.size) {}
|
||||
|
||||
Steinberg::Vst::DataEvent YaDataEvent::get() const noexcept {
|
||||
return Steinberg::Vst::DataEvent{.size = static_cast<uint32>(buffer.size()),
|
||||
.type = type,
|
||||
.bytes = buffer.data()};
|
||||
static_assert(sizeof(decltype(buffer)::value_type) == sizeof(uint8));
|
||||
|
||||
return Steinberg::Vst::DataEvent{
|
||||
.size = static_cast<uint32>(buffer.size()),
|
||||
.type = type,
|
||||
.bytes = reinterpret_cast<const uint8*>(buffer.data())};
|
||||
}
|
||||
|
||||
YaNoteExpressionTextEvent::YaNoteExpressionTextEvent() noexcept {}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
/**
|
||||
* A wrapper around `DataEvent` for serialization purposes, as this event
|
||||
* contains a heap array.
|
||||
* contains a heap array. This would presumably be used for SysEx.
|
||||
*/
|
||||
struct YaDataEvent {
|
||||
YaDataEvent() noexcept;
|
||||
@@ -50,12 +50,18 @@ struct YaDataEvent {
|
||||
Steinberg::Vst::DataEvent get() const noexcept;
|
||||
|
||||
uint32 type;
|
||||
std::vector<uint8> buffer;
|
||||
|
||||
/**
|
||||
* We'll just abuse the standard library's Small String Optimization to
|
||||
* avoid allocations for small messages, just like we do for VST2 SysEx
|
||||
* events.
|
||||
*/
|
||||
std::string buffer;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value4b(type);
|
||||
s.container1b(buffer, 1 << 16);
|
||||
s.text1b(buffer, 1 << 16);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user