vst.net icon indicating copy to clipboard operation
vst.net copied to clipboard

Sending several simultaneous events to VST

Open SirLyoshyk opened this issue 2 years ago • 3 comments

Describe the bug Hello. I'm trying to create a simple multichannel VST host and found an issue that doesn't allow me to use vst.net properly. When I'm sending several events at once to pluginContext.PluginCommandStub.ProcessEvents some of the events don't reach the VST plugin. These cause missing notes or notes that sound forever as noteoff event wasn't received. This issue especially hurts on pad tracks where we have a lot of simultaneous notes. It looks like ProcessEvents doesn't send events immediately to VST plugin, but sometimes keeps these events in some kind of buffer, because when we are sending next events, sometimes missing events are sent too.

To Reproduce Steps to reproduce the behavior:

  1. Load vst with VstPluginContext.Create(VSTPath, hcs)
  2. Send 4-8 noteon events and after some time the same 4-8 noteoff events using pluginContext.PluginCommandStub.Commands.ProcessEvents(vstEvents)
  3. Sometimes some of notes will stuck

Expected behavior All events must be passed to VST plugin as soon as received so notes will stop playing properly.

Additional info Visual studio communiti 2022 v.17.2.2 VST.NET2-Host 2.0.3 midiMonitor x64 1.3

SirLyoshyk avatar Aug 28 '22 15:08 SirLyoshyk

Not important. I've switched to another framework.

SirLyoshyk avatar Sep 11 '22 12:09 SirLyoshyk

@SirLyoshyk Out of curiosity, witch framework did you switch to ?

fgoulet avatar Sep 11 '22 12:09 fgoulet

I still want to research this.

obiwanjacobi avatar Sep 19 '22 07:09 obiwanjacobi

I have tested this by adding a 'Process Midi' button to the Host Sample and loading in an unmanaged midi monitor plugin (not the exact same as described - couldn't find a working download for that one). I send 2 batches of 10 note on/off messages and repeated that test a couple of times. I could not find any problems.

I have examined the code that is responsible for the marshaling of the managed vst events to the unmanaged plugin. I could not find any obvious problems there either. It is true that these events are stored because they (their memory) must remain valid for the entire processing cycle.

The only way that I can imagine the processEvents could go wrong is if you're "sending several events at once" by means of multi-threading: calling the same plugin at the same time from different threads. But I don't think that is what he meant.

If anyone runs into this problem, please let me know.

obiwanjacobi avatar Nov 30 '22 15:11 obiwanjacobi