Recently I've been spending a lot of time working in Unity, learning about how to program in it and tackling some creative problem solving in relation to game audio. I ended up creating a class of functions that have been very useful to me and I thought they'd be worth sharing here in case anyone else finds them useful.
Note: All code here is written in C# and due to the limitations of Squarespace, my website host, I suggest you copy and paste the code into your favourite text editor to enable syntax highlighting, making it easier to read.
Non Linear Transforms
I recently watched a video from the GDC Vault entitled "Fast and Funky 1D Nonlinear Transforms" and it was incredibly informative. If you have GDC Vault membership, I highly recommend watching it (link here). These functions allow you to apply a curve to a range of values, useful when changing things like volume or frequency in real time. A couple of these functions are from that video, and the inverse ones are the same principle applied using different curves. I've put the code, followed by an image of what that curve looks like when the value used for n is 2. Increasing the input n steepens the curve.
Note: The GDC talk says that using Mathf.Pow (or similar) isn't as computational efficient as doing the multiplication by hand e.g. t * t * t * t but for the cases I'm using this for in Unity, optimal efficiency is not a priority, so the use of Mathf.Pow was fine.