Fading sound.`

Hi folks.

I’m working with the Monogame internal sound classes and have a need to fade a looping sound in and out. The sound may take a second to fade in from 0 to 1 and fade out would be about the same.

I know the ‘best practice’ would be; write a load of code to Play then increase the volume, then a load of code to fade and Stop.

But, is there any reason why I shouldn’t just Play the loop at the start of the game and fade it in and out when I need it? That way I can avoid all the state checking code and starts and stops.

Yes, I know it’s lazy, and I’ll end up doing it properly in the end anyway. Just wondering how other people would approach it.

Cheers.

So, Im doing it like this:

because im composing all my sound myself, i just make an fading version :smiley: