Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: I wrote a partial re-implementation of DirectMusic (github.com/gothickit)
91 points by lmichaelis on June 9, 2024 | hide | past | favorite | 20 comments
DirectMusic[1] is a deprecated Windows API for playing dynamic music scores authored using DirectMusic Producer[2]. It was originally released as part of DirectX in 1999 and discontinued with the release in Windows Vista around 2009-ish.

Due to my involvement with projects[3] re-implementing an old game engine for the early 2000's games Gothic and Gothic II[4], I came to notice that existing solutions[5] were incorrect and hard to use. Thus, I was tasked with writing a new, correct re-implementation of the API.

Today, my re-implementation is able to (mostly) play back so-called style-based segments[6] and is fully tested against both the Gothic and Gothic II soundtracks. I am actively working on getting the Lego Island 2 soundtrack working as well.

There are many features of DirectMusic which the library does not currently support, simply because I have not been able to find or test soundtracks using them, so if you want to contribute, I'd love to know about software shipping with DirectMusic soundtracks!

[1]: https://en.wikipedia.org/wiki/DirectMusic

[2]: https://www.vgmpf.com/Wiki/index.php?title=DirectMusic_Produ...

[3]: Specifically GothicVR (https://github.com/GothicVRProject/GothicVR) and OpenGothic (https://github.com/Try/OpenGothic) through my ZenKit library (https://github.com/GothicKit/ZenKit)

[4]: https://en.wikipedia.org/wiki/Gothic_II

[5]: There is libdmusic (https://github.com/libdmusic/libdmusic) which is unmaintained and an embedded implementation in OpenGothic (https://github.com/Try/OpenGothic)

[6]: https://documentation.help/DirectMusic/howmusicvariesduringp...



Good work. You may want to consider contributing code to the wine porject.

Apparently Unreal 2, Final Fantasy 8 (original) and Midnight Club II use DirectMusic.


On an unrelated note I’ve been hoping someone would reimplement DirectPlay. There’s a childhood game that barely works on modern Windows as it is, and it has a networking component that allowed for either LAN or public internet play.

The server was never made available and even if it was, I wouldn’t want to host a DirectPlay server from over 20 years ago online.

Caveat is here I would prefer to write the server in C#.

So if there was ever an open source implementation of DirectPlay for emulation/preservation reasons, I’d jump on the opportunity to get the game working again.

Well it’s either that or I try do some reverse engineering of packets with wireshark…


Could you mention the name of that game?


Lego LOCO


Hi! Original author of libdmusic here -- kudos for the effort, I feel like I'm one of the very few people who know the struggle of getting useable audio out of original DirectMusic files :)


I chatted with the music producer for One Must Fall: Battlegrounds years ago during development. He mentioned using direct music. https://en.m.wikipedia.org/wiki/One_Must_Fall:_Battlegrounds


> I'd love to know about software shipping with DirectMusic soundtracks!

The Creatures series used procedural music for their MNG format[1] starting with Creatures 2, but I don't know if it's backed by DirectMusic. It may be on Windows, but I never did any disassembly to check.

Regardless, thank you for posting something procedural which isn't backed by LLMs!

[1]: https://creatures.wiki/MNG_files


It is not backed by DirectMusic - the mng files just play wav files via whatever DirectSound equivalent for the platform (source files for the games are available in certain places)


Hello again, and thank you for checking!

It's been a while since I've worked on anything Creatures-related. Are you still working on getting old things working on more recent platforms?


> I came to notice that existing solutions[5] were incorrect and hard to use.

Didn't see you mentioning wine, are you not aware of it?


I do know about the implementation in Wine, but sadly that one is not really useful for someone wanting to add support into a cross-platform app. Wine's implementation is tightly integrated with the Windows APIs it tries to recreate, so it has things like IUnknown and other Windows idiosyncrasies that aren't suitable for deployment as a library.


IUnknown is just a vtable. It isn't even code. There are cross platform projects that have used it.

That said, I'm not knocking you for that, there likely are some win32 dependencies.


Wine's first release containing very limited support came out in September 2023. Wine 9.0's release earlier this year contained "The foundation of several of the DirectMusic modules is implemented" which still sounds quite limited.


I just felt this is a missed opportunity to work collaboratively. Unless the author knows about wine and nonetheless chose to start a new project. Which is completely fine too.


WINE doesn't allow contributions from people who know too much about actual Windows implementations iirc, so that could be a problem.


I was thinking about contributing to Wine, but I am not experienced with Windows native APIs. There is also a difference in how my library works and how DirectMusic worked originally.

My library uses a "pull"-model, meaning the application must call a function to render more music. DirectMusic was more of an unattended "push"-model where you'd just tell it to play something and it'd set up playback automatically. It'd just play the music in a background thread (maybe even on hardware) and your application could subscribe to certain events (like get a callback on every beat).


What are some of the libraries games use nowadays for game soundtracks?


FMOD[1] is a really big one being used in many modern games and Wwise[2] is also available.

[1]: https://www.fmod.com/

[2]: https://www.audiokinetic.com/en/wwise/overview/


In the last 10 years I'd say the majority of the projects I worked on used WWise. The audio people love it.


Man Gothic was such a good game. One of my all time favorites




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: