Volume of background sounds


#1

Hi!

Is it possible to adjust the volume of the sounds incorporated into the code? For example: I am working on a virtual city tour and would like to have organ music playing while the user is in a cathedral. But I also would like the user to be able to understand what is being read after clicking on an info panel. Is this generally possible?


#2

Hi Fabian,

right now you can only change the volume of a sound by script. Here’s how you do it in your scene.

  1. Upload the sound in your “upload” tab

  2. Open up your code editor and write the following in JavaScript

let backgroundSound = Scene.loadSound("") as Sound;
backgroundSound.play(true);
  1. Copy the sound id of your uploaded sound by pressing “copy ID” in your upload panel. Then paste the id via CTRL+V (Mac: CMD+V) in-between the quotation marks. It should look similar to this code now (your sound has a different ID than the one used in this example).
let backgroundSound = Scene.loadSound("A3kkkUh2T1WWhxCyXEVEbs8erMtljnDBuwOqvCtojM6") as Sound;
backgroundSound.play(true);
  1. Finally, to change the volume we add the method backgroundSound.setVolume(0.5);. You can adjust the parameter to a number between 0 and 1, depending on how loud you want the background sound to be.

I hope this helps you adjusting the background sound to a suitable volume. Please note that any uploaded stage sound (in the environment tab) will still play. You want to remove stage sounds to prevent the background sound from playing twice.


#3

Thanks! That helps a lot!