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

Setting loop points

Last post 09-11-2008 5:33 AM by Ashu Tatake. 12 replies.
  • 09-05-2008 7:15 AM

    Setting loop points

    A certain piece of music for my game consists of 4 bars intro followed by 32 bars which need to be looped.  Is it possible to set a loop point so I don't have to repeat the intro everytime?
  • 09-05-2008 8:43 AM In reply to

    Re: Setting loop points

    Why not just split the music into a non-loopable part, and a loop-able part ?
  • 09-05-2008 9:11 AM In reply to

    Re: Setting loop points

    That might be a good idea, but I'm not sure it's possible to make sure the looping part starts to play exactly when the intro stops?  It would have to be accurate to the sample, or else it would sound weird.  I'll give it a try tonight.
  • 09-08-2008 6:56 AM In reply to

    Re: Setting loop points

    Hmm, on the Xbox it works flawlessly, but on the PC sometimes the loopable part starts too early and sometimes too late.
  • 09-10-2008 12:39 AM In reply to

    Re: Setting loop points

    Hi Spin0r, can you share how you are playing this piece of music (XACT or the new Media/SounfEffect APIs)?
    - Ashu Tatake
    XNA Framework Developer
  • 09-10-2008 6:59 AM In reply to

    Re: Setting loop points

    I'm using XACT.  I wasn't aware of any new APIs.  Is this something new in XNA 3.0 CTP?  I'm still using 2.0.
  • 09-10-2008 11:05 AM In reply to

    Re: Setting loop points

    Yes, we've added a couple new audio APIs in 3.0 -
    • SoundEffect API which as the name implies is useful for playing back sound effects with some basic parametric control like looping, volume, pitch, panning (and 3D positioning on Windows and Xbox) etc.
    • Media API is useful for playing background music, either a soundtrack with the game content or from your media library.    
    Adding audio content to your game is easier in 3.0 as well. You can simply drag-drop wav, wma or mp3 files in your content project and use them in your game as any other content resource.

    As for your current issue though I have a couple more questions if you don't mind - how are you looping the content in XACT? Do you have the loop points defined within the wave file itself or is it something slightly more complicated (e.g.an InteractiveAudio cue with markers etc.)?  

     


    - Ashu Tatake
    XNA Framework Developer
  • 09-10-2008 12:05 PM In reply to

    Re: Setting loop points

    Well, I split the audio in an intro and a loopable part and try to start playing the loopable part after N elapsed milliseconds where N is the length of the intro in milliseconds. On the Xbox this seems to works fine, but on the PC the loopable part doesn't start exactly at the right time. I feel a bit silly now as I had no idea you could define loop points in the wave file.
  • 09-10-2008 3:25 PM In reply to

    Re: Setting loop points

    I have read that you can define loop points in a wave file, but I don't have any tool that actually can do it, it seems. My preferred tool is Audacity.

    Is there some tool that allows you to set and edit loop points in a wave file that you can recommend? Ideally not a tool that costs hundreds of dollars, as I'm low on that particular resource right now.

    Btw: if you try to play two cues with timing done in the application, it will never work quite right. A better way to do it would be to create a playlist in the Sound in XACT, where you have two Play Wave events on two tracks, the second offset by the length of the first. That ought to work fine on PC as well as Xbox.

     

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 09-10-2008 6:36 PM In reply to

    Re: Setting loop points

    Audacity's a great editor but I haven't used it since I got SoundForge 9 (which unfortunately costs a lot more). I did a quick search on creating loops in Audacity though and found some sites that explain how to do this.

    As for Spin0r's original question the easiest way to solve this is to -

    1. Define the loop in a wave editor.
    2. Add it to a wave bank.
    3. Drag-drop the wave into the sound bank editor to create a cue. This cue should have a sound corresponding to the wave with 1 play wave event on a looping track.
    4. Play the cue.

     This should give you accurate looping no matter what platform.

     

     

    - Ashu Tatake
    XNA Framework Developer
  • 09-10-2008 8:13 PM In reply to

    Re: Setting loop points

    Works like a charm. Thank you very much!
  • 09-11-2008 4:46 AM In reply to

    Re: Setting loop points

    Unfortunately, the markers in Audacity do not get exported to loop points that XACT understands when exporting to WAV. I had already tried that.

     

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 09-11-2008 5:33 AM In reply to

    Re: Setting loop points