This repository provides an example of real-time Godot 4.3 sound generation by integrating the libxmp-lite module-decoding library in a custom AudioStream
with the GDExtension system.
It is mostly a proof of concept, but I'm open to PRs if this proves useful to someone. Note that a pure GDScript module player exists (Godot Mod Player).
Code is based on gdextension-custom-audiostream. Have a look at that project for more details about GDExtension, debugger usage...
This repository includes libxmp as a submodule, in conformance with its MIT license. Scons will include it to the GDExtension library during build.
Public Domain module files are included with this module for testing purpose; see game/CREDITS
for details.
After cloning and building the extension (see below), open game/project.godot
in Godot Project Manager, and run it. You'll hear a module being played.
If you test this in the editor, by setting the Playing
property to true
there, you may get audio glitches. This is due to the fact that editor windows are running with default priority.
This will not happen with a script/game, since those are run with a higher priority (as can be seen here).
Since this project includes godot-cpp
and libxmp
as submodules, you'll have to clone it with git clone --recurse-submodules
.
To compile the extension you need to follow these steps:
-
Make sure you cloned the extension recursively as described above
-
Go to the top level of the project
cd gdextension-module
- Compile the extension
scons # this will use the default values such as target=template_debug
For the initial build you can run the vscode task initial-build-extension
. This compiles both godot-cpp
and the extension. For all subsequent builds, you only need to run the task build-extension
.
Check out the godot-4.2.1-stable
tag for a Godot 4.2 compatible version.