DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.29k stars 154 forks source link

Problem integrating my Sanguine Mutants plugin into Cardinal. #717

Closed Bloodbat closed 1 month ago

Bloodbat commented 1 month ago

Description

Hello!

I've been working on integrating my Sanguine Mutants plugin into Cardinal.

While the task has been mostly successful (Cardinal builds, I can see and use the Sanguine Mutants modules in Cardinal), a crucial feature in one of the modules has to be disabled in order to be able to build the plugin.

My Funes module is based on the 1.2 firmware for Plaits and, as such, it can load custom data for certain synthesis models.

Custom data loading is achieved using the osdialog.h function osdialog_file (with the OSDIALOG_OPEN parameter).

The problem is, when building the plugin for Cardinal, neither the function or the parameter are found.

I know the problem stems from Cardinal's desire to build a headless version that uses an osdialog stub.

Is there any way to fix the problem? Either avoid building Funes for headless versions; but build it for the versions with GUI, or detect headlessness so the proper code path can be taken when compiling?

What can I do to fix the problem? The rest of the modules are fine :)

Thanks in advance :)

falkTX commented 1 month ago

Cardinal intentionally doesnt use osdialog, not because of headless but because osdialog stuff are blocking operations. While the dialog is running the event loop doesnt reach Rack which is terrible design and specially a big no-no when running as a plugin.

In place of osdialog, Cardinal provides its own async API for file dialogs, just use one of https://github.com/DISTRHO/Cardinal/blob/main/include/common.hpp#L84 Code will be different when built against VCV Rack, so you can use USING_CARDINAL_NOT_RACK compiler macro in ifdef/else/endif way to have some small parts of code being different for each platform.

Bloodbat commented 1 month ago

Ahhh, I see :D

I was using my own define to skip stuff; but using the built-in one is way better :)

Thanks a lot, I'll update my plugin to use the async API and, hopefully, send a pull request with the integrated plugin :)

Bloodbat commented 1 month ago

That solved it and custom data can now be loaded in Cardinal as well. Again, thanks :)