Game Development Community

When to call AudioEngine.Update()

by Raymond Ku · in Torque X 2D · 07/06/2010 (10:57 am) · 2 replies

hey everyone, I've been having some sound distortion problems that happen randomly as I play through my level. I've fixed this by calling the update() method for the audio engines every tick in my player component.

However as to why this fixed this I have no idea. And I'm not sure when I should be updating my audio engine. Should I update when I play a new sound? or should I make a component to just update my engines every tick( As sound still plays when the player is paused, I don't want the random distortions to come back if the updates are tied to my player component).

Does anyone else have experience with this?
Thanks
Ray

#1
07/06/2010 (3:01 pm)
if your using torque X to do the sounds you shouldn't have to call AudioEngine.update at all (I don't think none of the code I have calls it at all in the PSK or demos)

if your using regular XNA to do your sounds then yes you should be calling AudioEngine.Update() whenever Update gets called.

if you add the following to your game.cs file
protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            AudioEngine.Update();
        }

that will call it every time Update gets called.. which is called by the XNA framework upto 60 times a second maybe more maybe less. but thats where you would put it.
#2
07/06/2010 (4:12 pm)
gotcha! Thanks!