keijiro / MidiJack

MIDI input plugin for Unity
697 stars 113 forks source link

Any way to throttle/debounce MIDI Messages? #64

Open thornebrandt opened 1 year ago

thornebrandt commented 1 year ago

I've been doing some profiling for some CPU overload during performance and found that this plugin is causing a CPU spike and bottleneck whenever there is a steady MIDI CC, like an auto-knob fade. image

The steady stream of CC messages comes from a DAW or Midi controller (pictured: Ableton) when there is a ramp used such as this: image

A slower staircase ramp of Midi CC, like the following screenshot, removes the performance hit and MIDIJack CPU usage drops. image

I've tried different workflows and approaches and refactoring my code, debouncing the CC messages going out, but I'm hitting a wall.

I'm wondering if you can recommend a way to debounce the incoming CC messages within MidiJack. I've tried a few hacks but I'm not having luck - there's still a heavy hit to the CPU during a knob fade. ( unless the Update() _callback is commented out of MidiStateUpdater.cs )

keijiro commented 1 year ago

Honestly saying, I have no idea about the issue. I haven't touched MidiJack over 7 years, so I can't remember anything about it.

I only use my newer MIDI plugin Minis these days. My recommendation is migrating to Minis.