Dwarf Fortress

Dwarf Fortress

comfy_bruh Dec 10, 2022 @ 8:50am
Modding Music Frequency
So I've been really into the soundtrack for this game, but wouldn't you know it, the game barely plays the music.

I thought maybe I could go in an mod this to play it more frequently. And what I discovered in the sounds folder where the music be played at is that the cards(non OST) and music (ost) are both triggered by specific in game events. Years passing, battles raging, the death of a fort, the finding of deep metals. These are great! and I enjoy the level of work that has gone into it but I would really love for the cards and possibly some of the music to play more frequently.
However and I say this humbly I am out of my element on how to mod this. I found the folder and file where the EVENTS are tracked but I'm at a loss for how to make the tracks p[lay more frequently when I am not really able to know when these events occur, and there does not appear to be any other way to mark their playing.

Can a genius of the community please help.

ALSO: I know I can just play music on another program, but I am certain that will break immersion. I do not need Drink and Industry playing while a forgotten beast rampages through my fort. And truly want just the amount of music to be more frequent.

Thank you to anyone who takes the time to read this and I hope your fort doth prosper.
< >
Showing 1-6 of 6 comments
Draewa Dec 10, 2022 @ 9:52am 
Just spitballing here since I have no idea how exactly the new music system works, but in data\vanilla\vanilla_music\objects\ there's a file called "music_standard.txt" which defines the music tracks and tags them with different contexts and events that trigger them.

On Track 10 I found the tag [FREQUENCY:UNCOMMON] with the comment "can also play any time, half as often as the other candidates".

I have no clue what values this tag can have apart from UNCOMMON, but I'd start by copypasting this tag under all track definitions and taking a look at what that does ingame. Then maybe try changing UNCOMMON to COMMON to see if that does something,
Draewa Dec 10, 2022 @ 11:14am 
2
I've thrown together a small Workshop mod implementing the tags mentioned above - not 100% sure they have the expected effect, but the music does seem to be playing more frequently.

https://steamcommunity.com/sharedfiles/filedetails/?id=2900074461
comfy_bruh Dec 10, 2022 @ 11:30am 
Huge help thank you for the head start. Time to experiment.
Draewa Dec 10, 2022 @ 2:25pm 
Did some further testing... I suspect the [FREQUENCY] tag doesn't do what I thought it does, unfortunately. Seems to me like there's still huge periods of silence inbetween music tracks, it's just that when the game finally decides to play music, it now picks the tracks I tagged more often as the next track choice. I think the time inbetween tracks might be hardcoded, that is, not easily moddable. Might be addressable with DFHack at some point in the future, but at the moment I don't see another way to influence the playback frequency of music.

Some other observations:
  • I was able to verify that the [EVENT] tag does something. Cutting & pasting [EVENT:JUST_EMBARKED] from "Strike The Earth!" to "Koganusan" does indeed result in "Koganusan" playing on embark instead of "Strike The Earth!"
  • There's a number of musical interludes/cards (short pieces of music that play inbetween the main tracks) that don't have trigger definitions anywhere and seem to be hardcoded without any way to influence them
  • It is seemingly not possible to add new music tracks to the game. Tried modding in the classic DF gameplay song by putting its file into "\data\sound\tracks\classic_song" as "CL_Full.ogg" (sticking to the same folder structure & naming scheme as the vanilla tracks), then adding the following entry into music_standard.txt:
    [MUSIC:TRACK_15] [FILE:CLASSIC_SONG] [CONTEXT:MAIN] [EVENT:JUST_EMBARKED]
    No success, track does not play in-game on embark, and the game defaults to "Koganusan" instead which is track 01 in the trigger list. This is unfortunate because it means that for now the only way to mod the in-game music tracks is to replace the existing files with other ones.

Gonna stop experimenting for today because I'm getting frustrated, nothing about the music system is properly documented anywhere and I'm currently just throwing ♠♠♠♠ at the wall to see what sticks. It may be possible to increase the frequency at which music triggers by slapping [EVENT] tags for a very common event on all tracks... but the only event tags we know exist are FIRST_CAVERN_OPENED, DEATH_SPIRAL, MEGABEAST_ATTACK, FORGOTTEN_BEAST_ATTACK, TAVERN_MUSIC_PRESENT, TAVERN_DANCE_PRESENT, SIEGE & JUST_EMBARKED, so I'm not seeing that many good options apart from maybe the tavern ones.
comfy_bruh Dec 10, 2022 @ 7:16pm 
This is amazing work thank you again for all your help! This is very insightful and will be a huge part of immersion with total conversion mods and the like. This seems like something that would be a minor adjustment to the main devs however and would love to hear some feedback from kit fox. I was thinking of maybe looking up fmod and seeing if there is an easier way to decode how it works since that's the sound program used by DF.

Again this is amazing headway so far. Thank you for your diligence.
Draewa Dec 10, 2022 @ 10:37pm 
Originally posted by comfy_bruh:
I was thinking of maybe looking up fmod and seeing if there is an easier way to decode how it works since that's the sound program used by DF.

Hmm, I don't think that's gonna be fruitful. DF Premium uses the fmod API, yes, but unfortunately that doesn't mean there's something like an .fmod file somewhere in the game files that we can just open and tinker around with. It just means that within DF Premium's source code (which we don't have access to), fmod is being used as the sound engine. Not a viable avenue for modding.

I think the most probable solution to proper sound modding will be...
  1. Either DFHack gets updated to be compatible with DF Premium and fixes the current issues with gamelog.txt (a file that should contain a list of every event that happens ingame, but currently doesn't - many external utilities rely on it) or Kitfox/Toady get around to fixing it
  2. Once gamelog.txt works again, SoundSense (external utility that was used to play sounds and music in classic DF) and similar tools will work again
  3. Someone will write a modern version of SoundSense that works nicely with DF Premium
  4. We players will disable all the in-game audio and use that updated version of SoundSense instead, the status quo will have been restored and there will be much rejoicing

Bit disappointed with the way sound was implemented in DF Premium - I heard that it was gonna have "SoundSense-like features", got too hyped and expected too much. Was hoping that it would be more modding friendly, but now it looks like we'll end up exactly where we were with classic DF and have to use external utilities again to get the best experience. Oh well ¯\_(ツ)_/¯
< >
Showing 1-6 of 6 comments
Per page: 1530 50

Date Posted: Dec 10, 2022 @ 8:50am
Posts: 6