diff --git a/examples/audioBall.js b/examples/audioBall.js index cfa08ef3a2..a0d9423526 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -10,31 +10,18 @@ // in response to the audio intensity. // -// add two vectors -function vPlus(a, b) { - var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; - return rval; -} - -// multiply scalar with vector -function vsMult(s, v) { - var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; - return rval; -} - var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); var FACTOR = 0.75; var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. var particleID; -function updateParticle() -{ +function updateParticle() { // the particle should be placed in front of the user's avatar - var avatarFront = Quat.getFront(MyAvatar.orientation); + var avatarFront = Quat.getFront(MyAvatar.orientation); // move particle three units in front of the avatar - var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(avatarFront, 3)); // play a sound at the location of the particle var options = new AudioInjectionOptions(); @@ -42,11 +29,10 @@ function updateParticle() options.volume = 0.75; Audio.playSound(sound, options); - var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; + var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); - if (countParticles < 1) - { + if (countParticles < 1) { var particleProperies = { position: particlePosition // the particle should stay in front of the user's avatar as he moves , color: { red: 0, green: 255, blue: 0 } @@ -59,8 +45,7 @@ function updateParticle() particleID = Particles.addParticle (particleProperies); countParticles++; } - else - { + else { // animates the particles radius and color in response to the changing audio intensity var newProperties = { position: particlePosition // the particle should stay in front of the user's avatar as he moves diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js index da15ec7421..a7b8a0a749 100644 --- a/examples/audioBallLifetime.js +++ b/examples/audioBallLifetime.js @@ -10,28 +10,15 @@ // in response to the audio intensity. // -// add two vectors -function vPlus(a, b) { - var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; - return rval; -} - -// multiply scalar with vector -function vsMult(s, v) { - var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; - return rval; -} - var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); var FACTOR = 0.75; -function addParticle() -{ +function addParticle() { // the particle should be placed in front of the user's avatar var avatarFront = Quat.getFront(MyAvatar.orientation); // move particle three units in front of the avatar - var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply (avatarFront, 3)); // play a sound at the location of the particle var options = new AudioInjectionOptions(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b38d970011..a16162112e 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -141,7 +141,7 @@ void MyAvatar::update(float deltaTime) { } // Get audio loudness data from audio input device - Audio *audio = Application::getInstance()->getAudio(); + Audio* audio = Application::getInstance()->getAudio(); _head.setAudioLoudness(audio->getLastInputLoudness()); _head.setAudioAverageLoudness(audio->getAudioAverageInputLoudness()); diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index 5b95d84d7b..04d5fe5b46 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -76,7 +76,7 @@ protected: float _rightEyeBlink; float _averageLoudness; float _browAudioLift; - float _audioAverageLoudness; + float _audioAverageLoudness; std::vector _blendshapeCoefficients; float _pupilDilation; AvatarData* _owningAvatar;