Compiling libopenmpt.dll

Started by 02FD, March 18, 2023, 23:29:39

Previous topic - Next topic

02FD

I've been trying for a while (read: 2 days of tireless on and off work) now to compile libopenmpt as a DLL with only PortAudio included (and no other dependencies), though I will describe my reasons for choosing this particular configuration later on in case I'm making a mistake.

I have never compiled a dll before, so it's been a struggle. I'm using MSYS2 MinGW-64 as my shell on Windows 11. I have libopenmpt and portaudio tarballs downloaded and extracted, but that brings us to my first question:

Where do I put the portaudio files so that running ./configure in the libopenmpt directory recognizes it?
and
What files do I need from the PortAudio tarball?

...I guess I'll start there. I'll probably have more questions as this thread goes on.

As for the context of all of this, I'm targeting an old version of RPG Maker (RMXP) as this is a hobby project (yes I'm aware there are better options, however, I do really want to see what I can do with such an archaic tool). You can load DLLs via the Win32API of Ruby 1.8.6 as that's what RGSS1 (the scripting language RMXP uses) is built on. I got to this point of trying to compile this configuration of libopenmpt because:

FMODEX.dll, which has a community script already written for it, is not as functional as I'd like (no subsong selection, mainly). It's also not open source and doesn't fully support tracker modules (.it has no stereo support)

Running a system() call and using openmpt123 creates a command line window (even if you specify --quiet) which isn't minimized. This is a huge issue for a game that requires... y'know, input from the player.

I wanted some amount of real-time control over the music in code, and libopenmpt seems to have good options for that.

Also, if anyone can make a list of steps to get libopenmpt in a dll with PortAudio compiled directly that would be much appreciated, though I get that may be a bit much to ask.

Thanks in advance!

manx

First off, I am not familiar with RPG Maker.

libopenmpt itself does not use PortAudio. libopenmpt itself is only concerned with loading and redering the module files to PCM data, and not with outputting that rendered PCM data to the soundcard via PortAudio (or other libraries). You will have to handle this part yourself, outside of libopenmpt.

For your use case, as you described it, there should also be no need to compile libopenmpt yourself. We provide already compiled libopenmpt DLLs in the development package (see https://lib.openmpt.org/libopenmpt/download/), so you would only need https://lib.openmpt.org/files/libopenmpt/dev/libopenmpt-0.6.9+release.dev.windows.vs2022.zip. The DLL we provide comes with its dependencies already included as separate DLLs, which you just put into the same directory. It also depends on the MSVC redistributable runtime, which you might need to install separately (but it is already installed on most systems by other software anyway): https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170.

I would recommend against compiling yourself for your use case, especially with MSYS/MinGW-w64, as you would have to deal with their assortment of toolchain runtime DLLs yourself if you want to use it outside of MSYS.

Loading the DLL itself shoud be straight forward, but, as said, you will need to handle the sound output yourself. RPG maker might already have some infrastructure for that. Or it might now (I do not know).

02FD

Thank you for your reply!

...I was afraid of that when I was reading the documentation. Unfortunately, RMXP uses winmm.dll to handle audio. I don't have a clue how to get a PCM audio stream to go through it, and the Audio class that it ships with isn't open-source (one of very few classes like this in the docs).

I will have to figure something out, maybe using PortAudio as an additional library instead of winmm. But thank you for your help. I guess that saves me a lot of trouble... just wish I hadn't spent so much time trying to compile it if it doesn't work that way...