Simon van Luxemburg
STSharedAudioLib / LCSoundRandomizerMod
"A standalone Component storing Lists of AudioClips to access from different mods."
"Randomize the sounds and songs of tons of items and enemies!"
I'd made a handful of audio mods replacing individual sounds. However, some original game assets do not take multiple sounds. Mods were clashing with each other, and I wanted to solve that.

STSharedAudioLib: a self-made library with the purpose of cross-mod compatibility for scripts with one audioclip parameter to play multiple sounds

Old way mods usually replace sounds, of which only one gets played
STSharedAudioLib
The solution was found in defining what these problems shared in common: Unity AudioClip parameters, and only taking one asset at a time.
Choice of Library:
And from my early days of modding, when I relied on other people's mods, I knew you could import their libraries to have a centralized solution to the problem of mod-incompatibility.
So, the solution I saw before myself was:
Make a usable library that can be accessed from different projects, that relies only on Unity's Components and AudioClips.
Defining Requirements:
I started with creating some tests, trying to think of: What kinds of questions should this library answer? What objects will I need? And how will I make it?

The first question I answered by going back to my own demands: multiple mods want to add sounds to one object, or multiple sound clips are trying to be the same parameter.
So, I started by making my custom Component hold a List of AudioClips. This Component could be attached to a GameObject, then the Component could be gotten, and sounds could be added to it.
New way I wanted mods to replace and play sounds, having multiple to pick from
Further Functionality:
This answered the very specific question of adding sounds. So then, I looked a bit broader at how to remove sounds, as well as loop- and shuffle-functionality.
So, I did more research, and the next methods involved getting an AudioClip's index in the List and picking the next index, or getting a random index. I also added weights to influence the randomness's chances.
Video demo of multiple sounds being added to scripts that otherwise usually only play one AudioClip

Methods in the library have overloads to take either the specific AudioList to search, or the general GameObject to search, to lower the bar of entry when wanting to add or retrieve sounds
List of Playlists:
Then, knowing that people want more control, I put the AudioClips not in the Component, but let the Component hold a ScriptableObject AudioList, which could be referenced by name and given a random weight.
This answered the second question of what kinds of objects I needed, as I now had the structure of Components holding Lists holding AudioClips. This allowed for a lot of micro-control. And I wrote all methods so that you could get any one of these three objects if you had access to another one.
Finishing Touches:
Then, to finalize these methods, I got in touch with programmers who could help with specific problems.
I stated what I wanted the end result to look like, explained where I got stuck, and asked if they knew a solution.
Using this clarity, we were quickly able to add the shuffling of AudioClips and removing Clips and Lists during runtime.

AudioClips can be given weight, to have a higher chance of being picked when picking by weight

AudioClips can also be removed at runtime, which LCGoldScrapMod does for one unlockable
LCSoundRandomizerMod
Now that this library worked very well, I just needed to demonstrate its capabilities in gameplay.
That's how I got to LCSoundRandomizerMod. This mod collects almost every AudioClip in the game and registers them into four different AudioLists (AllAudioClips, Length, Footsteps, and Collections), to then randomly redistribute them to objects again.
Video demo showing randomization of sounds, such as airhorns and enemies, or not randomizing sounds, such as turrets players can't see

Example code of randomizing an enemy's AudioClip: it takes a password to determine which AudioClip to replace, and an integer to quickly get a clip using that index in the AllAudioClips List
Intentional Division:
AllAudioClips allowed me to get the index of a randomly rolled sound and send it across the netcode, so that the randomized shuffling stayed consistent across players.
Length divided the sounds by length, allowing me to replace long audio clips with other long clips, so that looping sounds don't get very repetitive.
Collections compiled similar sounds into separate lists, so that enemies with lots of sounds played random similar sounds too, instead of being *completely* randomized, which was experienced as annoying.
Horror-Comedy:
And finally, Footsteps was a hilarious addition that holds the player's and enemies' footstep sounds. This to make enemies play a random set of other footsteps when walking around, tricking people into thinking they're dealing with a completely different monster, which inspired LCBeatBoxerMod.
The Footsteps AudioList allows for tricking players into thinking there are no enemies or other enemies than there really are
Overall, this library was a huge success for me. It answered my demand of making cross-mod-compatible playlists, made my life easy because I created so many different methods for so many different use cases, and even lead to the creation of one of my funniest mods. And what's better than fun?
Look at STSharedAudioLib, LCSoundRandomizerMod, and LCSimonTendoPlaylistsMod with these links.

