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.

  • \$\begingroup\$ Are you already using compressed audio formats (WAV instead of MP3)? \$\endgroup\$ – George Clingerman Feb 5 '12 at 16:22
  • \$\begingroup\$ 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 \$\endgroup\$ – George Clingerman Feb 5 '12 at 16:30
  • \$\begingroup\$ 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. \$\endgroup\$ – 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.

  • \$\begingroup\$ Thanks, that has helped, but still when I play sound sometimes it stutters. Its as if it only keeps one or 2 cues in memory, then stutters if I get it to play one it doesn't have. \$\endgroup\$ – George Duckett Feb 4 '12 at 18:51
  • \$\begingroup\$ @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. \$\endgroup\$ – David Gouveia Feb 4 '12 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.