mikeoliphant / neural-amp-modeler-lv2

Neural Amp Modeler LV2 plugin implementation
GNU General Public License v3.0
202 stars 25 forks source link

write_current_path() from :work_response didn't work #57

Closed brummer10 closed 7 months ago

brummer10 commented 7 months ago

Hi

While working on the GUI for neural-amp-modeler I found a small issue. neural-amp-modeler tries to send the patch_Set message from the worker response thread. https://github.com/mikeoliphant/neural-amp-modeler-lv2/blob/main/src/nam_plugin.cpp#L180 That didn't work. The related port is only valid during run, means you could only send messages from the process thread. What could be done is setting a flag in the worker response and check that flag in the process, then send the message, when needed, from the process thread. I'm using std::atomic<bool>for such flags in my plugs, as they are very cheep in computation and been thread save.

regards hermann

mikeoliphant commented 7 months ago

This came up before, and was the matter of some contention. I believe the current method was required for it to work properly with MOD UI, but I'm not sure. @falkTX?

falkTX commented 7 months ago

worker response and worker end happen during run/processing, and the same approach is present on official lv2 plugins. so that is not an actual issue. (I believe I use the same approach in dpf too, not sure now)

in what host is this failing?

brummer10 commented 7 months ago

Fail in ardour, jalv and Reaper. And as far I remember as well in Carla. However, my workaround for this is to send a pathGet message from the UI (after some iterations to fetch the state.

falkTX commented 7 months ago

we have been through this before, https://github.com/lv2/lv2/blob/master/plugins/eg-sampler.lv2/sampler.c#L243 is a clear example of this being done in an example plugin.

the worker response and end run are called within the audio thread context, same as the run method.

in fact the end run is typically the place where an atom forge "frame pop" would be placed, as it is the end of the run after all events have been handled.

maybe the issue is something else?

brummer10 commented 7 months ago

I tested with jalv.gtk -d, added some printouts in the modeler, and see that the modeler send the message, but, in jalv.gtk -d the message didn't appear.

brummer10 commented 7 months ago

Okay, my bad. I do some more tests and it turned out it works in jalc, ardour and carla as expected. Only Reaper doesn't forward the message from the work response thread. So, sorry for confusion will close this issue now.

mikeoliphant commented 7 months ago

👍