Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes

Let's say we have to play many short 3D events in random locations.

To do that, we:

1) create temporary SoundObj

2) set position to it

3) PostEvent to it

... renderAudio()...

4) handle AK_EndOfEvent  callback to delete temp SoundObj

Is it the best way?

Basically, I need something like PostEvent( eventId, AkSoundPos, ... ) without SoundObj

Thank you

in General Discussion by ILYA L. (190 points)

1 Answer

+1 vote
 
Best answer

The best way is slightly simpler, you don't have to wait for the Ak_EndOfEvent.

  1. temp = RegisterGameObj();
  2. SetPosition(temp, x,y,z)
  3. PostEvent
  4. UnregisterGameObj(temp);

RenderAudio could be called before or after the UnregisterGameObj, it doesn't matter.  UnregisterGameObj only marks the game object for destruction.  Wwise will keep it alive until all the sounds playing on it are finished.

by Mathieu J. (Audiokinetic) (7.1k points)
selected by ILYA L.
Thank you, Mathieu. it's good to know.
What about reusing temp object inplace?
i.e.
temp = RegisterGameObj();
SetPosition(temp, pos1)
PostEvent(event1, temp)
SetPosition(temp, pos2)
PostEvent(event2, temp)
UnregisterGameObj(temp);
...
renderAudio()
...

will event1 have pos1 and will event2 have pos2 in this case?
A game object can have only one position, both sounds will be posted at the same location (pos2).  Don't worry, a game object consumes very little resources.  As long as you don't spawn thousand of them concurrently, you won't hit any performance problem.
Thank you, Mathieu
You, AK guys, are the best when it comes to customer support.
Regards,
Ilya
...