Tag Archives: .Net

Mods, Mods, Mods: A few updates

I’ve been publishing some small projects lately, so I thought it was a good time for an update on them and how things are going.

My health is still not good. I think the progression of my illness has slowed slightly as I’ve become more aware of how it functions and how to manage it.  However, I’m still not aware of what it is.  I’m still researching and analyzing and fighting to figure it out, though.  But it is probably some kind of rare genetic metabolic disorder.  Regardless, I have to take things slow and put any energies into smaller, less-intense projects.

Mod Music Conversion

One such project was converting all my old mod music into MP3s so I could listen to them more conveniently.  I’ve been manually converting small batches of mods for years and found through that process that many automated ways of transcoding mods had issues.  Either metadata would be left out or certain bits wouldn’t sound right or the volume was too low or the frequency balance would be muddy sounding.  This is why I would always just playback the mod in ModPlug Player (my player of choice) and directly record the output into Audition, tweak the volume, save to MP3, and done.  You can’t reasonably do this for a library of over 400 songs, though.

The first problem I wanted to tackle was getting as much metadata out of a module file as possible and putting it into an MP3 file’s ID3 tags. I started looking into libOpenMPT as a way to open the four major mod formats and grab their metadata in a standardized way.  It’s a decent library, but the documentation could use some work. I had to read through its source code for hours until realizing that it returns strings as UTF8. This was only a problem because .Net can only marshal strings from unmanaged memory that are ANSI or UTF16 by default, which seems pretty weird given UTF8 is so common.  But one custom UTF8 marshaling function later and I was in business.

The next problem was that the mod metadata ended up being not the greatest. Almost all mods have a title and a field for what tracker software was used, but modification date only became a feature by the Impulse Tracker format, and none of the main formats have artist fields.  I had to use a lot of regex magic to even get a fraction of the date and artist metadata from the song comments.  The comments, by the way, are another quirk of the mod formats.  Artists typically put notes about their work in the comments; however, only Impulse Tracker had a specific field for this. The earlier formats used either sample names or instruments for these notes.  Being that I wanted to preserve all of this in the extracted metadata, I just concatenated all three fields together with some delimiters between them.

Luckily, getting the extracted metadata into an MP3 file is a bit more simple as there are a number of ID3 libraries for .Net.  TaglibSharp is the most popular one, but it is not without its quirks as well.  Particularly, trying to delete specific user text frames (TXXX) is not the least bit straightforward.  But in the end, I came up with an imperfect little tool to copy module metadata to an MP3 file (or output to text if necessary for your purposes) that I put up on Github.  Thankfully, ID3 is a much better tagging format than what module files used. 😄

As I was trying to figure out how to work with libOpenMPT, though, I discovered that ffmpeg also uses this library to load module audio. Given that libOpenMPT was basically the evolution of ModPlug, I thought that the playback might be comparable between the two. I did some test runs converting a few songs to MP3 and found the results to be promising.  Obviously, the aforementioned muddiness of the sound persists, but I then found that ffmpeg has quite a vast library of audio filters to utilize. One EQ later and that issue is fixed right up.

What was more of a struggle was how to balance the volume of the songs.  Naturally, you don’t want to risk clipping the audio data by doing a straight up amplify.  ffmpeg does include a hard limit filter to avoid clipping, but how do you know how much to amplify?  You can’t normalize a song’s audio without having the whole song to analyze and ffmpeg only works in streams of audio data.  It’s a problem I have yet to find a straightforward way to tackle. In the end, I used the loudnorm filter to extract the loudness of the song, calculated the amplitude needed to reach about -10 LUFS, and then did a second pass including the desired hard limit.  More information on the whole conversion process can be found on the Github page for the metadata extractor.

Ultimately, I’m fairly pleased with the results of this project. I did get my entire mod library converted to MP3 with some snazzy album art and good sound.  But I also did end up having to manually adjust a lot of the artist names and titles in MusicBrainz Picard to catch all the missing artists and make them all uniform, so that was a bit of a drag. Also, there are a few songs that seem to have minor issues with conversion accuracy, primarily Necros songs coincidentally.  I may still end up manually recording a number of the songs ultimately, but what I’ve got so far is pretty damn good.

Mods MP3 library in Dark Audio Station

Mods MP3 library in Dark Audio Station

Deus Ex Soundtrack v2

Given that I was already binging old mods, my conversion of the Deus Ex Soundtrack—which was originally in the mod format—kept coming up on shuffle.  However, I was getting pretty annoyed at how quiet the songs were as I had stupidly only normalized the volume instead of hard limiting it.  I thought it would be a quick couple day project of loading up the original wave recordings and tweaking the volume levels, but I soon found lots of other lingering issues with those recordings.  It was mainly just clicking from bad sample loops or poorly recorded/encoded samples.  I imagine this was due to a combination of time crunch and crude audio tools during the soundtrack’s original creation, so I can’t fault Alex Brandon too much.  Coincidentally, if you need to go insane, try finding the right loop points that make an audio sample not click and sound decent. 😛

Eventually, I ended up re-doing from scratch about a third of the soundtrack as I had also stupidly not saved the intermediate mod files from the original conversion. 😄  So, every one of the those bad 8-bit samples had to be cleaned up again.  To be fair, I think I did an even better job with that as audio editors have gotten a bit more advanced in the interim.  I’d like to redo the entire soundtrack, but many of the songs were pretty decent already and I’m kinda burnt out on it for now. But maybe in the future…

At this time, I’ve already uploaded the MP3 version of the new soundtrack conversion to its page.  I’m still working on getting a new FLAC version done as it has a different tagging format.  And I’m also thinking about making the intermediate mod files available for download, although obviously that would only include the tracks I redid recently.  These files would be Impulse Tracker format with all the samples cleaned up and other fixes and new outros included.  Additionally, I’m also exploring the possibility of copying the cleaned up samples back to the original UMX files to improve the game music as well.

Deus Ex Soundtrack Cover Art

Deus Ex Soundtrack Cover Art

Diablo 2 Mods

And in another kind of modding, Diablo 2 mods!  Yes, I am still modding this old ass, janky game.  However, that may be changing soon with the imminent release of the Remastered version of the game.  Blizzard said modding is still possible in the new release, but I highly doubt it’s as comprehensive.  I would be delighted to hear they switched the data format away from TSV text tables, though.  I’d think something more object-oriented where you could define a default item, inherit and change what needs to in child items, and modify some of the raw functions would be the dream.  But, I’d be pleased with at least a switch to JSON for the data definitions.

Regardless, I haven’t done too much modding this time around. I just overhauled how the respec and socketing mod works.  I realized that I could just add the Token of Absolution—an item which resets your skill and stat point allocation—right to a vendor instead of continuing to use the Horadric Cube recipe.  It’s a little janky this way as I had to change its item type to that of a potion to get the tooltip to work, but right-clicking on the ToA still gives the desired result, albeit with the drawback that the game crashes if you try to give the vendor more than one to sell, it can be put on your belt, and its cost changes based on what level the character is.

I also realized that I should include a recipe for adding sockets to items in the mod as there already is one but it’s crazy high-level and convoluted.  Tangent, but, isn’t it lame how you have to “remember” all these cube recipes to play the game.  We’re all looking them up on a wiki anyways and that’s not fun.  I’m glad Diablo 3 got rid of that aspect.  Anyways, I changed the recipe that adds sockets to something more reasonable but still balanced.  And I also discovered that there was an unused recipe function that allowed gems to be removed from sockets without destroying them, so I added a new recipe for that as well.  However, both of these recipes require gems to perform.  I’ve been thinking about adding a new rare crafting material that could be used in the socket recipes, but it seems like a lot of work plus would take valuable inventory space even if the mats stacked.

I’m also thinking about removing the Magic Find attribute from my drops mod.  It’s kind of a counter-productive stat to have on items, like it doesn’t help you survive or kill monsters but you want it maxed out so you can find the best loot.  I just feel like the loot drops should always be good—in a fun and balanced way.  So I might just remove magic find and increase the drop chances even more, but it’s a tough one because it needs lots of testing before release.

Final Thoughts

I hope you enjoyed this developer diary of a post.  My apologies for not doing more awesomeness in recent years, but… it’s something at least.  I think next I might try to give this site an overhaul; I’ve been neglecting to add proper mobile support for many years and the WordPress theme is like a decade old.  I’m still dreaming of doing an update to Cursor Lock, though; I think it’s passed about a half-million downloads across all sites now.  However, I’d really love to do a major update on File Lister as it’s the program of mine that I use the most.  It’s just so crazy useful for doing batch operations and management on files, and I’d like to extend that capability.

Take care, everyone.  Stay safe and don’t get the ‘rona!

Posted in Media, Miscellaneous, Modding, Programming | Tagged , , , , | 9 Comments

A Full Month of Doings

I’ve been working on so much stuff lately that it’s hard to decide what to devote each day to. Of course, practically everyone I know doesn’t give a shit about the awesome stuff I do and rather I just jump into the rat race. But anyways, here’s an overview of what I’ve been working on…

Not long after my last post, I updated my mod for the Age of Empires 3 expansion The Asian Dynasties called Gatling Guns for All!. Previously, you could only use the mod with a specific unmodified version of TAD, but I wanted the mod to be usable by all versions of both The Asian Dynasties and The Warchiefs expansions even if they’ve been previously modded. Thus, I had to create an installer (similar to the one I did for Stalker) that would modify only the aspects of the game that I changed. Originally (as I did in the Stalker mod installer), I tried to use regular expressions to find the appropriate setting to change. However, being that the game data is stored as XML, Regex had problems matching certain XML formatting quirks. So, I moved to a query language that I’d never used before called XPath, which is basically XML hierarchy-aware Regex. Though getting some of the nodes in AOE3’s settings files to match was still tricky, XPath in .Net did the job perfectly.

When I went to package the new version of the mod, I actually found out that I had incorrectly archived an essential file in the wrong path in the first versions of the mod. Thus, nobody that downloaded it would have gotten the mod to work as intended :( . And only one person called me on it, though I thought he was a noob at first. But all has been rectified now.

Next, I started working on a script for this site that would color-code programming language syntax and elements so I can attach beautified code to some columns. The script uses a PEAR PHP library called Text_Highlighter to do the color-coding on the fly. However, at the moment, my part of the script still presents certain security risks that I will have to mitigate before it goes live.

news269

Lego Indiana Jones

That project was interrupted by a visit from Kaylen that turned into non-stop gaming in the form of Lego Indiana Jones 😉 . Although the game was littered with some annoying little bugs (having just been released), we did manage to get 100% completion. As most reviews have said, it wasn’t really as fun as Lego Star Wars–how can you beat lightsabers and the force? Though bazookas and bushes you can jump into come close.

The next week, following a concern from a user, I began working on a major new feature for Cursor Lock. Though not really having anything to do with multimonitor gaming, the feature is a natural progression of the existing code. It allows the user to select whether to lock the cursor into the current screen (what it did originally), the selected window, or the selected window interior (client area). Locking the cursor into the window interior is particularly useful for playing windowed 3D games. While I was at it, I decided to completely overhaul the setup GUI to be much more intuitive, separating the selection of the different modes with pretty, graphical buttons. It’s looking rather nice already and should only take a few more days of testing and fixing bugs until public release.

Last week, I got distracted when randomly deciding to replay Deus Ex: Invisible War and then subsequently desiring to mod out some of the major flaws in the game. Only a few changes would make the game much more palatable to the PC fanbase. One of the mod ideas I had was to combine the various proximity and thrown variants of grenades (EMP, scrambler, gas, and concussion), which would return the grenades to their vanilla Deus Ex functionality and give the player a lot more inventory space. So apparently, the developer of Deus Ex, Ion Storm, only decided to release the Thief: Deadly Shadows editor and not the Invisible War one, even though the games were made concurrently on the same engine (Unreal Warfare). I tried for days to get the Thief editor to work for Invisible War, but I don’t see it ever working out easily; there are far too many hardcoded elements of the games in both the editor and the game executables. The best I could do was to get the DX2 packages to load in the Thief editor after it had loaded the core Thief packages first. Then, I could get the DX2 packages to save after some simple modifications, but that made it so there were both Thief and DX2 classes mixed together, making a good number of DX2 objects break ingame (e.g. inventory, particle emitters). In other words: Epic Fail. 😕

However, while I was poking around in Invisible War’s resources, I found the plaintext files containing the secret area’s developer quotes. I decided it’d make a good contribution to my Deus Ex column, despite not being from vanilla Deus Ex. Then, whilst I was formatting the quotes for HTML, I got the crazy notion of using the game’s font for the text. Unfortunately, the font was not in a TrueType or comparable format, but rather it was merely a texture and an accompanying text file (DX2_FONT.cel) of comma-delimited texture character widths (in pixels) that were ordered corresponding to their ASCII value. The texture character height was understood to be 23 pixels, so that a width of -1 in the text file meant to go to the next row. Using a quickly thrown together program, I turned the width values into a Paint Shop Pro script (macro) that would cut out all the characters into individual bitmaps. Finally, I manually pasted them into a font editor to complete the conversion. The font can be downloaded here, and then can be tested on the aforementioned DX2 quotes page.

Posted in Modding, Programming, Website | Tagged , , , , | Leave a comment