# Avoiding lag when playing sound for first time using Cue.Play

In my code I'm using SoundBank.GetCue("cuename") and Cue.Play() to play my sounds.

On the xbox whenever I first play a cue I get lag of about about one second.
How can I avoid this?

I'm thinking I probably have to do something like call GetCue (without playing it) for every Cue I'm going to use, however I don't have a central place where I list all cues I'll want to play, so is there an easy way to do that?

Update: It seems calling GetCue for all sounds i want to play doesn't work. I'm still getting stuttering in various places in my game when i call GetCue....Play.

• Are you already using compressed audio formats (WAV instead of MP3)? – George Clingerman Feb 5 '12 at 16:22
• Also make sure that your SoundBank type is set to InMemory instead of Streaming. That was some advice I found here -> forums.create.msdn.com/forums/p/2677/13360.aspx#1336000 – George Clingerman Feb 5 '12 at 16:30
• I'm using WAV files, I had it as InMemory, I've also tried Streaming which did actually help a bit, i just have a slight delay the first time i play something, but the whole game doesn't stop. – George Duckett Feb 5 '12 at 20:03

I've tried introspecting the SoundBank class hoping to find some way to know which cues are stored in it, but found no way to enumerate over all cues other than by name. The class is pretty much just a wrapper that delegates all method calls to the lower level XACT3 engine.
So I'll have to suggest that you go with your current train of thought, by creating your own list of cues, for example in a txt file, and doing a preload step in your game where you enumerate over all names in the list and call GetCue for each of them.
• @GeorgeDuckett I've never used the SoundBank class before so I'm not sure... But maybe it's related to the remark in this link. In particular the the Cue is marked to be disposed by the garbage collector part. – David Gouveia Feb 4 '12 at 19:16