From 03d3a535f827a31e4080a8b4fe85ffefe902401b Mon Sep 17 00:00:00 2001 From: gaitat Date: Sun, 16 Feb 2014 14:50:50 -0500 Subject: [PATCH] Fix for Worklist Job #19503 Added random sound trigger to the examples --- examples/audioBall.js | 14 +++++++++----- examples/audioBallLifetime.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/audioBall.js b/examples/audioBall.js index a0d9423526..676b9118b3 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -11,6 +11,8 @@ // var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var CHANCE_OF_PLAYING_SOUND = 0.01; + var FACTOR = 0.75; var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. @@ -23,11 +25,13 @@ function updateParticle() { // move particle three units in front of the avatar var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(avatarFront, 3)); - // play a sound at the location of the particle - var options = new AudioInjectionOptions(); - options.position = particlePosition; - options.volume = 0.75; - Audio.playSound(sound, options); + if (Math.random() < CHANCE_OF_PLAYING_SOUND) { + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.75; + Audio.playSound(sound, options); + } var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js index a7b8a0a749..affb75f04d 100644 --- a/examples/audioBallLifetime.js +++ b/examples/audioBallLifetime.js @@ -11,6 +11,8 @@ // var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var CHANCE_OF_PLAYING_SOUND = 0.01; + var FACTOR = 0.75; function addParticle() { @@ -20,11 +22,13 @@ function addParticle() { // move particle three units in front of the avatar var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply (avatarFront, 3)); - // play a sound at the location of the particle - var options = new AudioInjectionOptions(); - options.position = particlePosition; - options.volume = 0.25; - Audio.playSound(sound, options); + if (Math.random() < CHANCE_OF_PLAYING_SOUND) { + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.25; + Audio.playSound(sound, options); + } var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness);