I'm sure there's companies out there selling high-tech solutions, but you already come equipped with a pair of incredibly sensitive instruments attached to your head. A comfortable listening volume is a comfortable speaking volume, so pop an earbud out and talk to yourself! If you feel you'd need to raise your voice to be heard over your game/music, it's too loud for extended listening.
[Edit] Per liminalsunset I should be referring to this as Dynamic Range Compression or DRC
[1]https://support.apple.com/en-ca/HT211218
[2] https://support.apple.com/en-ca/guide/ipad/ipade8c21895/ipad...
The better place to implement this (in my opinion) is in the games themselves. I've seen a few games (wish I remembered which) recently that offered a few choices in their audio settings so that you can request reduced range for more consistency in noisy listening conditions or full dynamics for people with nicer setups.
As far as software goes, that's where it gets tricky.