I recently switched my project over from the development version of Monogame (220.127.116.119) to the stable release version (18.104.22.1685) and I’m having an issue with the following code:
Cue c = soundBank.GetCue(track);
c.SetVariable(“Volume”, 0.25); // <—“System.IndexOutOfRangeException”
Since switching to 3.6.0, calling “SetVariable” will trigger a System.IndexOutOfRangeException.
The code worked fine on the previous version, it’s used to independently control the audio levels of multiple tracks played at the same time to create effects like cross-fades and other transitions.
The game loads all tracks from a single XACT project containing 23 waves.
I also have some general questions about audio for a large project:
- Is there a way to dynamically load waves from a single XACT project? Currently my project uses 700mb of process memory at runtime because it front-loads all the tracks at the start of the game.
- Is this how XACT should be used? Should I be using a separate XACT project for each track?
- Is there a better way of controlling a cue’s individual volume?
- Should I even be using XACT for audio in a project that: Has a lot of music, requires multiple tracks to be played at once (with individual volume control), and aims to be cross platform (including consoles)?
I’ve been searching for ages for good information about using audio in Monogame correctly and I haven’t found anything that’s talked about these issues.
I’d really appreciate any help you could offer!
Thanks very much,