tags:

views:

48

answers:

2

So I'm making a game in XNA and I need to use XACT for my songs (rather than media player). I need to use XACT because each song will have multiple layers that combine when played at the same time (bass, lead, drums) etc. I cant use the media player because the media player can only play one song at a time.

Anyways, so lets say I have a song playing with XACT in my project with the following code

 public SongController()
    {
        audioEngine = new AudioEngine(@"Content\Song1\Song1.xgs");
        waveBank = new WaveBank(audioEngine, @"Content\Song1\Layers.xwb");
        soundBank = new SoundBank(audioEngine, @"Content\Song1\SongLayers.xsb");
        songTime = new PlayTime();

        Vox = soundBank.GetCue("Vox");
        BG = soundBank.GetCue("BG");
        Bass = soundBank.GetCue("Bass");
        Lead = soundBank.GetCue("Lead");
        Other = soundBank.GetCue("Other");

        Vox.SetVariable("CueVolume", 100.0f);
        BG.SetVariable("CueVolume", 100.0f);
        Bass.SetVariable("CueVolume", 100.0f);
        Lead.SetVariable("CueVolume", 100.0f);
        Other.SetVariable("CueVolume", 100.0f);

        _bassVol = 100.0f;
        _voxVol = 100.0f;
        _leadVol = 100.0f;
        _otherVol = 100.0f;

        Vox.Play();
        BG.Play();
        Bass.Play();
        Lead.Play();
        Other.Play();        }  

So when I look at the variables in Vox, or BG (they are Cue's btw) I cant seem to find any play position in them.

So I guess the question is: Is there a variable I can query to find that data, or do I need to make my own class that starts counting up from the time I start the song?

Thanks

+1  A: 

I do not believe this is possible. The API doesn't provide this information as far as I know.

Joel Martinez
A: 

Depending on your needs you might be able to author cues that mix the various layers instead of doing it in code (the possible latency in Cue.Play might not be helpful in this scenario anyway). If you need to do it in code (e.g. because you are creating some sort of tracker) then you need to do the timing yourself and store timing related metadata outside of XACT, too.

Using SoundEffect might be an option (that gives you at least the duration of the sound and its play latency might be a bit better) as you load all sounds into memory at once anyway.

Bjoern