Following some example code, the author calls "AudioManager.Submit" when creating the sound, but never calls "AudioManager.Remove". Is the latter call necessary? Will the sound be automatically removed from the AudioManager when it is finished playing?
Here's my code for creating the sound:
rocket.Sound = new AudioSource(sound)
{
AudioType = AudioType.Ambient,
Loop = false,
PlayWhenLoaded = false,
Radius = 100f,
UpdateType = UpdateType.Automatic
};
rocket.Sound.Play();
sunburn.AudioManager.Submit(rocket.Sound);
Hi boinst,
Container managers -- managers that contain scene elements like entities, objects, audio sources, lights, ... -- act as scenegraphs for specific scene element types. For the scene elements to be visible, heard, updated, ... they must be submitted to the appropriate manager.
However each element type can be disabled / enabled while still in the scenegraph (in a manager) - with audio sources you can stop playing the sound, lights can be disabled, and objects can be set to not render. So it's really your choice whether or not to remove the elements when inactive.
That said, for abandoned elements I definitely suggest either removing or better yet recycling them. As an example if you kick off an audio source for a single shot, it's a good idea to recycle the now unused source when playing the same sound again (instead of creating another new source).
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Thanks JohnK, that tells me exactly what I wanted to know.