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

'Best' method to play only half of a wave file

Last post 5/31/2009 11:13 PM by WolRon. 2 replies.
  • 5/31/2009 9:18 PM

    'Best' method to play only half of a wave file

    To save storage space and to make my program more efficient (as well as give me more versatility), I'd like to play only part of a sound.   Can it be done with existing commands (XACT or SoundEffect) or do I have to write something myself from scratch?

    Let's say I have a wave file that has two distinct parts.  Sometimes I'd like to play the whole file.  Sometimes I'd like to only play the first half.

    If I do have to write my own custom routines, would it be easier to:
    1) Load a complete wave and write code that stops the sound while playing before it plays the second half
    2) Load two separate waves and write code that plays the first one and then occasionally plays the second wav once the first has finished

    Please give me your thoughts.
    Frighten your friends and family with: Scare Me

    Help customers using GRENADES?!?: GoonyCru: Day One

    BASIC Programming Tutorial
  • 5/31/2009 9:32 PM In reply to

    Re: 'Best' method to play only half of a wave file

    It would probably be easy to write a timer function that plays the wav for a specific number of seconds. Also look up the AttackTime and ReleaseTime variables in XACT:

    http://msdn.microsoft.com/en-us/library/bb172310(VS.85).aspx
    Released Games: The Review Channel , Beat IT! Christmas Edition, Beat IT!,
  • 5/31/2009 11:13 PM In reply to

    Re: 'Best' method to play only half of a wave file

    EASIEST turned out to be creating an RPC (Runtime Parameter Control) to drop the volume using AttackTime from 0dB to -96dB at the exact moment I wanted the sound to stop playing.  Technically, the sound doesn't stop playing (it's just mute) but this turned out by far the easiest solution.

    Thank you very much!
    Frighten your friends and family with: Scare Me

    Help customers using GRENADES?!?: GoonyCru: Day One

    BASIC Programming Tutorial
Page 1 of 1 (3 items) Previous Next