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

Xact Custom Streaming?

Last post 6/6/2008 10:58 PM by Duncan. 5 replies.
  • 8/7/2007 12:09 PM

    Xact Custom Streaming?

    Sorry if this has already been explained, but I've done my share of searching already...

    So I'm trying to get streaming to work with my audio engine, and the way mine works is I have another layer that takes care of the streaming (double buffered). It seems like there is no way to do custom streaming, like without a file handle passed to XACT_STREAMING_PARAMETERS (as the data is already loaded from the file on my engine...).

    So I also tried using PrepareInMemoryWave for my custom streaming, and specifying it to loop forever and handle streaming myself. Because I have a double buffer system, I can use XACTNOTIFICATIONTYPE_WAVELOOPED to get a message back when I need to send it data for the second frame (soon as the first frame should start playing). But I don't see any way for it to receive a message exactly half way through the sample so I can load the first frame soon as the second frame starts playing. I see a XACTNOTIFICATIONTYPE_MARKER, but it looks like that doesn't actually work yet... So I could just calculate how many milliseconds it would take to play from the beginning of my wave to the center, and then just start a timer callback to trigger on the middle on the playback through my buffer... Hacky but doable...

    But that leaves me with my final problem... if I start changing the data in BYTE* pbWaveData I passed to PrepareInMemoryWave, will it know to copy this buffer down to wherever it needs to for actual playback? I doubt it...

    So is custom streaming actual possible on Xact, or should I just go back to using the old Xaudio for 360, and DirectSound for W32? I was looking very forward to having cross platform support without having to have duplicated code...

    :-(
  • 8/8/2007 11:54 AM In reply to

    Re: Xact Custom Streaming?

    Well after reading the beta notes for XAudio 2, it looks like thats the way I'd like to go instead of XAct... Too bad XAudio 2 doesn't support reverb yet... Looks like this is a wasted effort and perhaps I should just stick with using DirectSound for the PC...

    No one happens to know when reverb is planning on getting added to XAudio 2 do they?
  • 9/18/2007 6:39 PM In reply to

    Re: Xact Custom Streaming?

    Hi John,

    I may be misreading the question, but you can actually hook all of the file I/O callbacks in XACT; then it's up to you to deliver the content to XACT when it requests it for playback, and you can store/stream it however is most appropriate for your game. For more info, check out the documentation pages for XACT_FILEIO_CALLBACKS, which you can fill in during initialization of your game's engine (IXACTEngine::Initialize). Hope this helps!

    -Scott

  • 6/6/2008 6:20 PM In reply to

    Re: Xact Custom Streaming?

    This is interesting.  I'm basically in the same boat as John: I open my (non-PCM) audio file within my own code, pass part of it through a decoder to get raw WAV data, and buffer some number of bytes.  But these File IO callbacks seem to assume that XACT loads the file itself and then calls the callback with the handle it opened.  Does anyone know if this is actually the case?  The documentation pages for these callbacks are pretty sparse and I haven't found any sample code for this feature, so I'm not sure exactly how it's supposed to work.

    If that is what it does, it doesn't work too well for me since I'd like to load and close files myself.  More importantly, since I'm trying to stream audio that isn't in WAV format, there's no way XACT could get format and size information from the handle it opens.  Anyone know if there's another way around this?

  • 6/6/2008 8:26 PM In reply to

    Re: Xact Custom Streaming?

    BMKane:
    This is interesting.  I'm basically in the same boat as John: I open my (non-PCM) audio file within my own code, pass part of it through a decoder to get raw WAV data, and buffer some number of bytes.  But these File IO callbacks seem to assume that XACT loads the file itself and then calls the callback with the handle it opened.  Does anyone know if this is actually the case?  The documentation pages for these callbacks are pretty sparse and I haven't found any sample code for this feature, so I'm not sure exactly how it's supposed to work.

    If that is what it does, it doesn't work too well for me since I'd like to load and close files myself.  More importantly, since I'm trying to stream audio that isn't in WAV format, there's no way XACT could get format and size information from the handle it opens.  Anyone know if there's another way around this?

    XACT expects that WaveBanks are in xwb format and nothing else. The custom file IO support exists mainly (as far as I can tell) to support something like having all your assets in an archive instead of individual files. If you can figure out the binary format of the xwb you could create your own dummy for your audio files, implement the relevant XACT_FILEIO_CALLBACKS and feed the decoded data into the XACT engine. However, if that is worth the hassle is another question and it might either be better to switch to use XAudio2 for these audio files or, if this is about compression only, create the WaveBank with xWMA compression - assuming this is all about XACT3. After all, XACT is not a generic audio API, that's what XAudio2 :]

    We are boki. The rest is known.

    The not so known part of the rest: It is Björn or Bjoern, but never Bjorn.

    Twitter ~ Bnoerj ~ SharpSteer ~ SgtConker.com
  • 6/6/2008 10:58 PM In reply to

    Re: Xact Custom Streaming?

    johnsm:
    Well after reading the beta notes for XAudio 2, it looks like thats the way I'd like to go instead of XAct... Too bad XAudio 2 doesn't support reverb yet... Looks like this is a wasted effort and perhaps I should just stick with using DirectSound for the PC...

    No one happens to know when reverb is planning on getting added to XAudio 2 do they?

    XAudio2 ships with a reverb effect: http://msdn.microsoft.com/en-us/library/bb924655(VS.85).aspx

    You may also add your own DSP effects via xAPOs: http://msdn.microsoft.com/en-us/library/bb669165(VS.85).aspx

    Duncan McKay [MS]
    The Game Audio Team needs you (Software development engineer position open): http://forums.xna.com/forums/t/14399.aspx
Page 1 of 1 (6 items) Previous Next