vst-rs
vst-rs copied to clipboard
Lifetime of (SysEx)Event
I was writing a VST for a HW synth to convert CCs to SysEx automation and vice-versa (while letting irrelevant msgs through unchanged).
Due to the lifetime on Event
/SysExEvent.payload
I couldn't just map
incoming msgs to outgoing msgs, but had to push those msgs that should be mapped to SysEx to a separate vec, and then send that one afterwards (so I have two calls to send_buffer.send_events
, one for the filtered input events and one for the payloads vec mapped to SysExEvent
s).
But I want to preserve the ordering between the input and output msgs, i.e. not change the order of the param automation.
So this requires being able to return SysExEvent
s where the payload's lifetime comes from a vec outside of the map
ping closure.
But currently it's not possible, I get:
error: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements note: ...so that closure can access
payloads
note: first, the lifetime cannot outlive the lifetime'_
as defined on the body at 336:44... note: but, the lifetime must be valid for the method call at 336:17... note: ...so that a type/lifetime parameter is in scope
The lifetime that the incoming events have comes from this: https://github.com/RustAudio/vst-rs/blob/d7d5b6f0c049bac923c87ab9d49ca743a8adcb6a/src/api.rs#L454-L457
Any thoughts what the best approach would be, to make this kind of use case more convenient?