Forum Discussion

JimOwen-f418d1f's avatar
JimOwen-f418d1f
Community Member
10 months ago

Volume slider thing

I'm wondering if this is possible.

I want to play two pieces of audio simultaneously. I want the user to be able to drag a slider back and forth to change the volumes of the audio clips. If they are slid all the way left, audio 1 plays full volume and audio 2 is silent. As they slide right, audio 2 increases in volume and audio 1 decreases, until they are all the way to the right and audio 2 is full volume and audio 1 silent. How might I accomplish this?

One idea I have is instead of allowing an opportunity for infinite variability in relative volumes, to have perhaps 5 separate audio files:

1. All audio 1

2. Mostly audio 1 but a little audio 2

3. Both equal volume

4. Mostly audio 2 but a little audio 1

5. All audio 2

And then use buttons to swap between them rather than manipulate volume in SL at runtime. Would that perhaps be doable?

  • I have found from a previous thread this Javascript:

    var $volume = (GetPlayer().GetVar('volume') / 10);
    DS.appState.currentVolume($volume);

    But that is setting the volume for the entire project, not individual audio objects. Is there any way to control the volume of objects independently?

    If I insert the 5 audio files as described above, with different relative volume levels, would it perhaap be possible to mute all but one of them but keep them running so that when I switch they are still synced up?