Initialize BASS only when the Built-In Synthesizer is enabled

Synthesia is a living project. You can help by sharing your ideas.
Search the forum before posting your idea. :D

No explicit, hateful, or hurtful language. Nothing illegal.
Post Reply
KaleidonKep99
Posts: 58

Post by KaleidonKep99 »

Hello! It's been a while since I last posted something here! :lol:

I've been receiving some reports about the built-in synthesizer messing around with OmniMIDI, by either preventing it from opening a stream or by just making it crash the entire program (OmniMIDI fails to initialize the output and it crashes).

Would it be possible to only initialize BASS when the built-in synthesizer is enabled, and to free up the DLLs once it's not needed anymore?
That would fix the issue without actually requiring lots of code rework for both ends.

I tried making OmniMIDI not load its own DLLs and to just make it get a handle to yours through GetModuleHandle, but it still won't work properly.
Nicholas
Posts: 13135

Post by Nicholas »

If the built-in synth is already disabled when the app is launched, is it still loading the DLLs? It shouldn't be.
KaleidonKep99
Posts: 58

Post by KaleidonKep99 »

Nicholas wrote: 02-24-21 12:09 am If the built-in synth is already disabled when the app is launched, is it still loading the DLLs? It shouldn't be.
Yeah it is.
I disabled all the MIDI output devices, then restarted Synthesia, and it still loads the DLLs to memory.
Image

I know it's not OmniMIDI because both the DLLs are from Synthesia's folder, and OM loads some more DLLs other than BASS and BASSMIDI.
Nicholas
Posts: 13135

Post by Nicholas »

Ah ha, you are correct. It uses the presence of the DLL files on the search path (and whether each of the required methods can be resolved) to determine whether to even show the built-in synth in the list.

If you remove the DLLs from Synthesia's folder (and the rest of the search path), that should prevent them from being loaded. ;)
KaleidonKep99
Posts: 58

Post by KaleidonKep99 »

Yeah, but that's a "hack".
I honestly don't want to tell each user to remove the BASS libraries from Synthesia's main folder, just to get OmniMIDI to work.

You could check if the DLLs are valid on boot-up, then unload them once they're not needed anymore.
Nicholas
Posts: 13135

Post by Nicholas »

Unloading and re-loading the DLLs repeatedly to work around this issue also sounds like a hack. :lol:

VirtualMIDISynth doesn't appear to suffer from the same issue: I was able to have both loaded simultaneously without any trouble. Are you sure the bug isn't more of an OmniMIDI issue than a multiply-loaded BASS issue?
KaleidonKep99
Posts: 58

Post by KaleidonKep99 »

VirtualMIDISynth 2.x has a separate rendering process, so it won't be affected by the issue, since it will load BASS externally to the app.
You will definitely get the same issue by installing VirtualMIDISynth 1.x, which will try to load BASS and either have no audio or crash.

OmniMIDI seems to behave fine, it loads and unloads the libs as it should (or get a reference if GetModuleHandle finds them in memory, and of course OM doesn't call FreeLibrary on the pointers :lol:), but BASS doesnt know what to do during the OM initialization process because BASS_Init has been already called somewhere else.

I made OM free BASS (BASS_Free) before reinitializing it, but that still doesn't seem to fix the issue.
Nicholas
Posts: 13135

Post by Nicholas »

KaleidonKep99 wrote: 02-25-21 12:39 amVirtualMIDISynth 2.x has a separate rendering process, so it won't be affected by the issue, since it will load BASS externally to the app.
This sounds like a pretty useful scheme to avoid the problem. ;)

We both chose a library that should only be initialized once. I chose it for a stand-alone app. You chose it for one that hooks into other apps. (So presumably you'd run into the same trouble in every MIDI app if the user also had VirtualMIDISynth 1.x installed on the same machine, right?) It sounds like a separate rendering process for OmniMIDI would solve all possible versions of this problem in the future.
Post Reply