AudioClip Question

Hey guys!

So I have an empty object which I have an Audio Source including an attached looped background track. I also have a script on the empty object which takes in two Audio Clips. When the user presses one button, one of the clips play, when they press the other the other clip plays. It works great but I am looking to have some more flexibility.

I would like to adjust volume and pitch of the individual Audio Clips without adjusting the background track. I am not sure how to do this though, since all of the sounds are sharing the same Audio Source. I would like to have them all sharing the Audio Source and be adjustable but have not found a clear solution to achieve this.

Any insight or assistance would be greatly appreciated!

Thanks guys!

Here is how I am playing each button sound, this is attached to my empty object that also has the Audio Source on it with the background track:

public var click : AudioClip;
public var click2 : AudioClip;

function OnClick(button : String)
{

if(button == "Button 1")
{
PlayClick(1);
}

if(button == "Button 2")
{
PlayClick(2);
}

}

function PlayClick(val : int)
{
if(val == 1)
{
GetComponent(AudioSource).PlayOneShot(click);
}

if(val == 2)
{
GetComponent(AudioSource).PlayOneShot(click2);
}
}

I did see this but was failing at making it work with my solution since those calls have all been deprecated. :frowning:

Since volume for audio is managed by the AudioSource, and not the AudioClip, I’m not sure you can do it with all clips playing from the same AudioSource.

I’m not super familiar with the new Audio Mixer, but I’m confident that could resolve all your issues. Otherwise, you probably want to separate your music and sound effects onto different objects, and then manage the volume/pitch of your effects separately from the music.

again, not done much with the new Audio, but I think tutorials 1 and 6 might be a good start: