XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

How to ensure all sounds stop?

Last post 29/10/2009 10:29 by MarkMacumber. 6 replies.
  • 27/10/2009 1:18

    How to ensure all sounds stop?

    I have a WPF application (not a game) that is utilising the XACT software, and I have many different cues that get played on certain stop/start events.

    When the Stop events occur, I stop the cue associated with the Start event that played the cue, via an IDictionary<UserObject, Cue> implementation.

    You can think of it like this:

    public void Startevent(UserObject obj) 
    //...get cue... 
    _cues.Add(obj, cue); 
     
    public void StopEvent(UserObject obj) 
    _cues[obj].Stop();
    _cues[obj].Dispose();
    _cues[obj] = null;
    _cues.Remove(obj)
     

    However, I cannot guarantee that the Stop event will get fired, (well I think thats the issue), and sometimes, there is a cue playing that should have stopped, but is still playing. I have debugged, and I know that it is not in the _cues collection either, but somehow its still playing (my cues repeat over and over).

    Is there a section of the API that I have not seen that will allow me to get all playing cues, check if they should be playing, and stop them if they should not be?

    Cheers,
    Mark
  • 27/10/2009 1:28 In reply to

    Re: How to ensure all sounds stop?

    You're using Microsoft.Xna.Framework.Audio correct?

    This is what I use to stop or pause.  The category is what's set up in the XACT tool.  I have two categories, Music and Default.  All my sound effects are in Default.

        AudioEngine audioEngine;  
     
     
        public void StopEffects()  
        {  
          AudioCategory c = audioEngine.GetCategory("Default");  
          c.Stop(AudioStopOptions.AsAuthored);  
        }  
     
        public void PauseEffects()  
        {  
          AudioCategory c = audioEngine.GetCategory("Default");  
          c.Pause();  
        } 
    Guardian is in playtest

    Blog | Willow Ridge
  • 27/10/2009 1:43 In reply to

    Re: How to ensure all sounds stop?

    Hi Dave,

    Thanks for that, Im not actually making use of the Categories at this point, but Im not sure they would be of use in my, somewhat, unique situation. You see based on rapid mouse movements over and around different elements, I want to start and stop cues. You could think of it like a piano or something similar, but sometimes the music notes dont stop playing... So, I dont necessarily want to stop all cues, just the ones that shouldnt be running.
  • 28/10/2009 9:07 In reply to

    Re: How to ensure all sounds stop?

    bump-a-roonie :)
  • 28/10/2009 9:27 In reply to

    Re: How to ensure all sounds stop?

    MarkMacumber:
    bump-a-roonie :)

    Please don't bump your posts, especially after only 1 day... it's not really allowed by forum rules.
  • 28/10/2009 19:18 In reply to

    Re: How to ensure all sounds stop?

    Have you tried _cues[obj].Stop(AudioStopOptions.Immediate); ?

    It's also worth noting that there is a current bug in XACT 3.0 where it will fail to Stop extremely small sounds on the XBox (PC works fine).

    Games Developed: QuadTrix
  • 29/10/2009 10:29 In reply to

    Re: How to ensure all sounds stop?

    Stopping individual sounds works... thats not a problem.

    I need a way of accessing all playing sounds, and stopping them "if they shouldnt be playing", can this be done?

    I appologise for the bumping...
Page 1 of 1 (7 items) Previous Next