tags:

views:

724

answers:

1

Hello world.

This question borders between the world of the audio designer and the programmer. While this question might have to be partially answered by that domain of an audio designer, it is sure a problem for the programmer. In our project, we want to loop a sound (background music) while the game timer is greater than one minute left. When this time is hit, we wish to stop the music as authored, and then immediately continue with ending segment. I have been looking into XACT, and it seems to have support for different events. Unfortunately the documentation is lacking, and the application is somewhat alien to me as a programmer.

What I am looking to do is something along these lines (different approaches):

  1. When the music stops, I want to tie an event to play another sound immediately
  2. When a marker is triggered in the music, I want to play another sound immediately
  3. I would also like to know in my application when some of these events happen

The problem is that I haven't been able to find any mechanism to auto-play sound when another sound begins and that I can't find a way to hook up with the events made in the XACT project to C#.

If this can't be done (i.e. XACT/XNA lacks support for these operations), please gather your ideas on how to solve this problem with minimal cross-sound time errors. Preferably I would be able to control as much as possible of this in C# with calls to XNA.

+3  A: 

I think I've solved it now

Here's how I did it.

  1. Select the Cue which you want to change sound after it has been stopped in XACT.
  2. Set Playlist Type to Interactive.
  3. Open Cue Transitions.
  4. Select View by Destination.
  5. Select the Cue in the (stop) node visible in the tree view.
  6. In Transition Properties at the right side of the tree view, for Source and Destination:
    1. Set Source to End of Loop.
    2. Set Destiantion to Beginning.
  7. In Transition Properties at the right side of the tree view, for Transitions:
    1. Set Transition Type to Direct Concurrent Transition.
    2. Set Transitional Sound to the sound you wish to play after the looping sound has completed its loop.

Close the window and test it by playing the Cue. Also test to stop it As Authored to see if the behaviour fulfilles your expectations.


Implementation

In code, Stop the Cue As Authored to get this behaviour. Immediate stops the cue without playing the sound outro. I hope this helps other people who might run into this problem in the future. The question and answer wasn't that much code oriented as I thought initially. Also, this applies for XNA 2.0. I don't know if there will be other options for controlling this kind of behaviour in XNA 3.0+.

Statement