Fix for Worklist Job #19503

Added random sound trigger to the examples
This commit is contained in:
gaitat 2014-02-16 14:50:50 -05:00
parent e30cf33a03
commit 03d3a535f8
2 changed files with 18 additions and 10 deletions

View file

@ -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);

View file

@ -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);