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
WWise Ver: 2019.2.5

Unity Ver: 2019.4.8f1

Hello,

I have a Unity scene which plays some background music, and has an object in it which plays some spatial music via the AkAmbient component.

I want to fade the background music out as the player gets close to the object, and then fade the background music back in when they move away from it. My goal therefore is to have it so both pieces of music can be heard without them clashing together.

I've tried auto-ducking by using buses. This doesnt work because the spatial audio is set to 'Trigger On: Start' so as soon as the scene starts the background music ducks out before the player is close to the object. I've also tried changing to 'Trigger On: AkTriggerEnter' which works better - but then the background music never resumes because I assume once triggered the AkAmbient bus just stays active.

What can I do to get the behaviour I want?
in General Discussion by Pete B. (290 points)

1 Answer

+1 vote
 
Best answer

Hey Pete, 

There's quite a few ways to do this, but I would probably use busses with some adjustments. 

I noticed you write... 
"as soon as the scene starts the background music ducks out before the player is close to the object."
- Do you have attenuation on the non-background music? Ducking should definitely not duck, unless something is actually playing through it. Alternatively, you could try attaching a Wwise Meter to the non-background music bus, and then connect the RTPC from it, to the volume of the background music. 

Another less "volume-based" solution could also be to set an RTPC based on how close you are to the non-background music and map it to the volume of the background music bus. This should work quite well, as the RTPC influence will only subtract volume from the background music's audio bus, and so you can still have like a volume control RTPC on it as well. 
- You can do that by creating a new script, and in your Update() function, set the RTPC to the Vector3.Distance(transform.position, playertransform.position). 

If you want to see how this could be implemented, then for the Audio Bus ducking solution you can check out the arcade machine in WAG, that does exactly the same for the main music when it plays. For the method of setting an RTPC in Update, there's a section in Wwise 301 that describes more about that. 

Let me know if this helps!

by Mads Maretty S. (Audiokinetic) (39.8k points)
selected by Pete B.
Hey there. Thanks, I'll give those ideas a bit of research.

Quick note though - in WAG the arcade machine doesn't do anything for me. I get an interact prompt, which does nothing, and certainly no sound is heard.
"then for the Audio Bus ducking solution you can check out the arcade machine in WAG, that does exactly the same for the main music when it play"

Can you screen shot where in WWise the ducking is setup? I'm having a look at the project in WWise but I'm feeling quite lost.
In the end I went for the script option and setting the RTPC that way. I would love to know the other ways of doing this by using audio buses, but I was unable to figure it out.

In this case, the WAM wasn't helpful. The example of the arcade machine simply doesn't work for me (it never makes any sound when playing the game)and also I noticed the setup of the arcade machine is on interact which involves start and stop events. This is different to my scenario; I have an AKAmbient component which simply has a 'Trigger On: Start' setting. There is no notion of stopping it.
...