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

SoundEffect.Play() glitch?

Last post 10/18/2009 4:46 AM by Fat Kobra. 2 replies.
  • 10/18/2009 12:26 AM

    SoundEffect.Play() glitch?

    Hi,

    I'm trying to do some basic "raw audio generation" stuff... Basically what I do is that I create a byte array with 3 seconds of sound : the first and the third seconds are silence (zeros) and the second second(!!) is filled with a sinusoidal wave at 440Hz that I generated. I then use this byte array to create a SoundEffect object on wich I immediately call Play(). Doing this once every second I should have a fairly continuous sound (3 sound effects playing in the same time, 2 in silence and 1 with sound).

    My question is why is there a glitch in the sound every time I start to play a new SoundEffect? I didn't notice this glitch anywhere else (like in the platformer game that comes with XNA3.1)... Is it because the process of creating the byte array and then the SoundEffect object takes too long and that the CPU can't keep up with playing the other sound effects?

    Thanks!
  • 10/18/2009 2:07 AM In reply to

    Re: SoundEffect.Play() glitch?

    You must be using a hack similar to the one described in this article. Did you find out how to call SoundEffect's hidden constructor? Apparently you can do it on both Windows and Xbox 360. Here's what the author says about it:

    Skipping a D:
    Also, this is NOT suitable for "interactive" audio, which is to say you can't have a rolling buffer of continuously generated sound data. It almost works for that, but the gap between buffers is noticeable, and especially jarring on the 360. Here's to hoping they improve that in a future XNA release. Nevertheless, the ability to generate sound effects at runtime still provides interesting possibilities.


    Well, that sucks.

    Good luck, anyway!
  • 10/18/2009 4:46 AM In reply to

    Re: SoundEffect.Play() glitch?

    I did almost the exact same thing (although with a more complex wave generator). I wish I had found this article before... Anyways the author is correct, it almost work, but there is a little glith in between each SoundEffect play, even with my "technique" where I use 3 overlapping sound effects. I mean, if I was starting the sound effects sequentially I would have understood that there might be a little pause in between each play, but with a sound effect that has a full second of silence (44,100 samples) before the actual "sound" starts?? That's very strange...
Page 1 of 1 (3 items) Previous Next