Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod-support and openmpt #357

Open
konsumer opened this issue Mar 17, 2023 · 1 comment
Open

mod-support and openmpt #357

konsumer opened this issue Mar 17, 2023 · 1 comment

Comments

@konsumer
Copy link

konsumer commented Mar 17, 2023

I would really like mod-support with soloud, in a couple places that would benefit from static compilation, I think:

  • nim - I made a nice soloud wrapper and it works great, but no openmpt support without the DLL. I would prefer to not load the DLL, if possible (easier distribution, etc.) The original work around this was a libretro core written in nim, and generally libretro cores are compiled statically, without any seperate DLLs.
  • I am making a web-host for my game-engine, and it works great. My thinking is that I can compile soloud to wasm, and hook into it for sound in js, for perfect parity with native-engine sound (TTS will sound same, etc.) Here is the start to this, which I think will be useful to lots of people needing fancy web-sound, and if I can get it working, I would be happy to make some nice demos for your website.

Expected behavior:

I am hoping to compile soloud + openmpt directly from C/C++ files, that can be used in nim or wasm. The FAQ mentions an old modplug version with looser licensing, but the code seems to do a dynamic DLL openmpt-load, now.

Actual behavior:

I got it building great for nim, and the wrapper works well for libretro, but I am using src/audiosource/openmpt/soloud_openmpt_dll.c to stub the openmpt functions, and without the DLL it will not work.

Similar, for wasm, I can remove the DLL stub, and end up with this when I compile soloud:

  "_openmpt_module_create_from_memory", referenced from:
      SoLoud::OpenmptInstance::OpenmptInstance(SoLoud::Openmpt*) in soloud_openmpt.cpp.o
      SoLoud::Openmpt::loadFile(SoLoud::File*) in soloud_openmpt.cpp.o
  "_openmpt_module_destroy", referenced from:
      SoLoud::OpenmptInstance::~OpenmptInstance() in soloud_openmpt.cpp.o
      SoLoud::Openmpt::loadFile(SoLoud::File*) in soloud_openmpt.cpp.o
  "_openmpt_module_read_float_stereo", referenced from:
      SoLoud::OpenmptInstance::getAudio(float*, unsigned int, unsigned int) in soloud_openmpt.cpp.o
  "_openmpt_module_set_repeat_count", referenced from:
      SoLoud::OpenmptInstance::OpenmptInstance(SoLoud::Openmpt*) in soloud_openmpt.cpp.o

If I include soloud/src/audiosource/openmpt/soloud_openmpt_dll.c, it builds, but wasm cannot dynamically load a DLL, so this will not work when I try to compile the library for wasm. I would really like to be able to just inline those functions from openmpt.

I can build openmpt on it's own as a DLL (running make in openmpt dir) but get a lot of errors when I try to inline all of it's C code. If this path makes sense, then I will keep at it, but it's a lot of errors like reference to 'BasicPathString' is ambiguous, so I am probably including the wrong openmpt C files. I could really use some help with that part, as I am not very strong with C/C++, especially around dep-management & tooling.

Steps to reproduce the problem:

git clone --recursive git@github.com:konsumer/soloud-web.git
cd soloud-web

cmake -B build
cmake --build build

This will build, but it currently uses soloud_openmpt_dll.c, which will try to dynamically load the openmpt dll. Even though it has web in the name, the output of that is a plain native dll. My plan is to use emcmake once I can compile a standalone DLL.

SoLoud version, operating system, backend used, any other potentially useful information:

I am using github-latest versions of soloud/openmpt:

  • soloud: 11574758
  • openmpt: d75cd3ea

I am on OSX Ventura 13.2.1 on arm64 & x86_64 chip (have built on 2 different macs.) My primary dev-machine is x86_64.

@konsumer
Copy link
Author

I have tried a lot of stuff, so my repro is maybe not as simple as it could be, but I am happy to do the leg-work to setup any combo that is helpful for troublshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant