Closed DarylPinto closed 1 year ago
🐸x 🦀
Just adding on some notes and context to DRL's amazing work to get music back into the game.
In order to facilitate using a Rust lib, I had to make some changes to the Dolphin codebase and build process. A general changelog is below but can expand on anything as needed:
Externals/SlippiRustExtensions
. It gets built into a dylib that is shipped with the app(s) and linked at runtime, etc.ffi
module in Externals/SlippiRustExtensions
exposes the "public" API for this. Auto-generated C headers can be found in Externals/SlippiRustExtensions/ffi/includes
.SlippiEXIDevice
that's held by the C++ CEXISlippi
class; this is intentional so that the lifecycle on the Rust side meshes well. This is currently blank except for holding the Jukebox, but I figured doing this is useful in case there's a desire to continue doing things in Rust - it provides a sane structure for iterating here.Memory
and ExpansionInterface
so that Memory
is always around when ExpansionInterface
is started or destroyed. This appears to be fine but should be confirmed again in the Mainline move.LogContainer
class has been modified to hold its own LogType
and to accept a flag marking it as sourcing logs from the Rust library. If that flag is true
, a LogContainer
will register itself with the Rust side in order to handle ferrying logs across.tracing-subscriber
that interops with the above change to dispatch logs to their correct container.ffi
module README on this, as well as how to add new logging containers.AudioCommon
GetVolume
function that is passed in to the Rust library for the Jukebox to use.(Edit) one more bit of context:
(@eigenform may be a good candidate for extra eyes on this with regards to the C++/C/Rust interactions)
What is this?
In a nutshell, this feature brings music back to Slippi Online. By checking the following box, game music will be restored:
How does it work?
When the checkbox is toggled on, a pair of threads that are completely detached from emulation are spawned. These threads read from game memory to determine which music tracks should be played. When a track should play, a chunk of the iso containing the song is loaded into memory, decoded into audio and played back over the default audio device. No external audio files are used and nothing is ever written to disk.
Features
Alternate stage music has a 12.5% chance of playing. Holding triggers to force alternate tracks to play is not supported.
In some 1P modes, stage music will differ from vs mode. This behavior is not supported by jukebox. Additionally, the following songs will not play:
Limitations
Technical Details
The code that adds music support can be found here:
This pull request includes the addition of a Rust submodule, a first for the project. See this comment for details about Rust's integration into Slippi.