-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Enhancement Summary
The design of multi-stream instruments prevents them from working with the pin connector (#7459) and complicates the plugin API, which is a big problem.
To explain briefly, "multi-stream" instruments are those that receive NotePlayHandles with buffers that they use to render an individual note to. Most native LMMS plugins are multi-stream plugins. So if 10 notes are playing at once, there are 10 NotePlayHandles - each with a buffer - and each note's audio is rendered to their respective buffer during the Instrument::playNote() method.
The purpose of all these buffers is to allow ADSR to be applied to each individual note, which is why only multi-streamed instruments have an "Envelope, filter & LFO" tab. If the audio for all notes was mixed together into a single buffer like it is for single-streamed instruments, the host would not be able to apply ADSR.
The problem with the current multi-streamed plugin API is that no other audio plugin API chooses to implement support for ADSR this way. It requires allocating a buffer for each note and creates a weird discrepancy with how the other plugin types function. This discrepancy complicates how multi-streamed plugins are used on both the plugin and host sides.
Implementation Details / Mockup
I believe today's multi-streamed instruments could use a single buffer like all other plugins, but the host should communicate the ADSR information to them so they can apply ADSR themselves as they mix each note into the single buffer. That way there is no craziness of buffers being allocated and deallocated all of the time and a lot of the weirdness in the plugin API can be removed, but the same ADSR functionality should remain.
In other words, instead of having the plugin pass each individual note's buffer back to the host for the host to apply ADSR, the host should pass the ADSR settings to the plugin for the plugin to apply ADSR.
I haven't seriously looked into implementing this yet, so there may be complications, but I'm sure we can solve the problem somehow since no other plugin API (VST, CLAP, etc.) does what we do with a buffer for each note.