JohnGlassmyer / UltimaHacks

Patches which add features to, and improve the usability of, the 1990s video games Ultima VII (BG and SI) and Ultima Underworld (I and II), along with a program to compile and apply these patches.
https://johnglassmyer.github.io/UltimaHacks/patcher-site
MIT License
123 stars 6 forks source link

Is there any chance to get mp3 or ogg vorbis support for the background music? #28

Open Xerardo opened 1 year ago

Xerardo commented 1 year ago

Hi, do you know if it would be generally possible to implement functionality to play external mp3 or ogg vorbis files instead of the igame midi as background music? Should it be possible I would like to ask for it as a feature request.

PS: Thank you for your great work with UltimaHacks!

JohnGlassmyer commented 1 year ago

my first impression is that that would be such a herculean undertaking that i find the suggestion somewhat interesting.

i would guess that there is no existing free/open source mp3 or vorbis decoder for the 16-bit x86 platform. i'm also vaguely aware that mp3 decoding (and probably likewise vorbis decoding) would take a significant fraction of the processing power of the sort of 386 or 486 PC that these games run on (either real hardware or DOSBox emulation).

it might be fun to write a basic mp3 or vorbis decoder in 16-bit x86 assembly, but doing that and then trying to tie it into the sound and music playing framework would be an awful lot of work.

would probably make more sense to have the user decode the mp3 or ogg to some uncompressed format like WAV or VOC in advance, to mod the game engine to stream that digitized sound instead of MIDI music. that would spare the game the processing burden of decoding mp3 or vorbis in real time, and could make use of existing capability in the game executables to use such digitized sound files.

i remember that Ultima VII sometimes streams digitized speech during gameplay (the Guardian's taunts). it might not be extremely difficult to repurpose that as a form of music.

Underworld plays digitized speech during cutscenes, but not during gameplay if i remember correctly. i don't know how hard it would be to have it play digitized sound continuously during play.

it's an interesting idea. it would be a very large undertaking that i would not do any time soon. but maybe some day.

anyway, were you asking about for Ultima VII or for Ultima Underworld?

JohnGlassmyer commented 1 year ago

perhaps some config text file, then, with 1 line per music track, specifying

Xerardo commented 1 year ago

Thank you for your quick and detailed reply!

I'm asking for Ultima Underworld. I just released a music mod for Ultima Underworld Unity (UnderworldExporter by Hank Morgan) on Nexusmods. The mod consists of HQ remakes of the original music made by the YouTube channel 'Pieces of 8-bit's HQ Remakes'.

You can find the mod here: https://www.nexusmods.com/ultimaunderworldunity/mods/1

You can listen to the music on YouTube: https://www.youtube.com/playlist?list=PLe4GPzW9S9fN8dgcv-8KbNNVBf_RxBMfA

Or hear it in this video ingame: https://www.youtube.com/watch?v=pyP3Cq9eeuQ

Providing the music as WAV or VOC would be no problem. I only asked for mp3 or ogg, since I use those formats most often, but your explanation of why WAV or VOC would be better makes perfect sense.

Even though I'm asking specifically about Ultima Underworld, the artist Pieces of 8-bit has also reworked the music of Ultima III, IV, V, VI, and VII (VIII is unfinished so far). So all these soundtracks would also be available if needed.

it's an interesting idea. it would be a very large undertaking that i would not do any time soon. but maybe some day.

If there is any way to support this potential endeavor, let me know. I would love to help, especially if there is any tedious work that needs to be done for it.

JohnGlassmyer commented 1 year ago

do all of the tracks have A-B pairs of time points at which they could be looped indefinitely without audible noises or artifacts? how did you handle looping when adding the music into the Unity port?

Xerardo commented 1 year ago

As long as you are unarmed the tracks "Wanderer", "Dark Abyss" and "Descent" repeat. I think they are on shuffle with the last track played being forbiden as the next one. At least I have not noticed yet that one of them came twice after each other.

When you are armed the track "Armed" plays but does not repeat and no other track starts automatically. (By clicking the map you can always activate the track "Maps & Legends" and when you leave the map the track "armed" will start again)

When you kill an enemy the track "victory" is played with a subsequent pause of 5 seconds before the next track starts (either "Armed" or one of three main background themes).

do all of the tracks have A-B pairs of time points at which they could be looped indefinitely without audible noises or artifacts?

Tbh I don't know. When Po8 made these in 2021 we were not planning to create a music mod yet. I think back than I wasn't even aware of the existence of the UnderworldExporter. But should the tracks need to be loop-able, we can get that done. Po8 remade the soundtracks of Doom 1 and 2 last year specifically for music mods and made all tracks loop-able.

Xerardo commented 7 months ago

Hi @JohnGlassmyer just wanted to check in and let you know that this feature would still be awesome. 🎵🎶

Best wishes!

KarlClinckspoor commented 7 months ago

Could this be achieved by modifying the game to save the current track info to a .txt file, and then have an external program monitor that and play the appropriate music? I know of some mods to GTA San Andreas that do something like that.

JohnGlassmyer commented 7 months ago

@KarlClinckspoor if i wanted to do that, i would want to think more broadly about types of events to announce through the same mechanism. and alternatives to using a txt file per se. a general stream of game state..

anyway, how complicated would it be to have to setup and run that program together with running the game executable? how does that balance against the motivation of wanting different music?

does the GTA mod just play different music, or does it add other features in addition?

KarlClinckspoor commented 7 months ago

I imagined something as simple as possible. I could try to make a c#. Net program that does only that. Chatgpt make it look easy. It would just monitor the txt file for a number, and play the song associated with it. I personally wouldn't use it because I'm so used to the original music, but xerardo looks really proud of his remixes :)

That functionality in gta is a part of a larger mod. It gets the dialog subtitles from user made missions (dyom) using a live updated text file, submits it to Google translate for a translation and voice-over, then overlays both on screen during play.

Xerardo commented 7 months ago

@KarlClinckspoor Pieces of 8-bit deserves all credit for the remade music. I just commissioned the remakes. I like your idea with the secondary tool monitoring the game state and playing the fitting music. Reminds me of the soundsense tool that was used for Dwarf Fortress prior to its Steam release.

@JohnGlassmyer I think, at present, the best way to experience Ultima Underworld is by playing the original game enhanced with UltimaHacks. This is particularly true for newcomers to the game. For first-time players, the option to switch the soundtrack from the MIDI version to high-quality remakes can elevate the overall gaming experience further.

With a general stream of game state, depending on the capabilities of the secondary tool, it would be possible to add more triggers for music as well. For example, a specific tune could be triggered when interacting with a shrine on a specific level. I could compile a music pack with fitting high quality remakes from the soundtracks of Ultima Underworld 2, Ultima III - VIII and Ultima Online. Ultima VII had individual music for the shrine of each virtue. Those could for example be used as shrine music for the different levels.

Some interesting additional triggers could be:

These are just some examples. If it will be possible to add more music for specific game contexts like these, I will make sure that players have a suitable music pack available for download.

KarlClinckspoor commented 7 months ago

Just wanted to chime in I have a prototype. It accepts a .json file that maps an int to the path to a song file, and a .txt file that has a single number in it (track number), and plays that song on repeat, and changes the song when the file changes.