From eabeb9807671d3fd1cd3040adfdae3af0e8ddcc9 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 11:50:26 -0800 Subject: [PATCH 01/10] injector load --- examples/audioExamples/injectorLoadTest.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 examples/audioExamples/injectorLoadTest.js diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js new file mode 100644 index 0000000000..e25e964f3c --- /dev/null +++ b/examples/audioExamples/injectorLoadTest.js @@ -0,0 +1,55 @@ +// +// injectorLoadTest.js +// audio +// +// Created by Eric Levin 2/1/2016 +// Copyright 2016 High Fidelity, Inc. + +// This script tests what happens when many audio injectors are created and played +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + + +Script.include("../libraries/utils.js"); + +// A green box represents an injector that is playing + +var basePosition = { + x: 0, + y: 0, + z: 0 +}; + +var soundBoxes = []; + +var testSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav"); + +var numSounds = 45; +for (var i = 0; i < numSounds; i++) { + playSound(); +} + +function playSound() { + var position = Vec3.sum(basePosition, {x: randFloat(-.1, .1), y: randFloat(-1, 1), z: randFloat(-3, -.1)}); + var injector = Audio.playSound(testSound, { + position: position, + volume: 0.3 + }); + + var soundBox = Entities.addEntity({ + type: "Box", + color: {red: 200, green: 10, blue: 200}, + dimensions: {x: 0.1, y: 0.1, z: 0.1}, + position: position + }); + + soundBoxes.push(soundBox); +} + +function cleanup() { + soundBoxes.forEach( function(soundBox) { + Entities.deleteEntity(soundBox); + }); +} + +Script.scriptEnding.connect(cleanup); \ No newline at end of file From 1d9b3fadaf19e1213616c2c166e0865cf1a37f06 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 12:00:24 -0800 Subject: [PATCH 02/10] more logging --- examples/audioExamples/injectorLoadTest.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index e25e964f3c..d394e3a49b 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -24,11 +24,26 @@ var soundBoxes = []; var testSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav"); -var numSounds = 45; -for (var i = 0; i < numSounds; i++) { - playSound(); +if(!testSound.downloaded) { + + print("EBL SOUND IS NOT READY YET") + testSound.ready.connect(function() { + playSounds(); + }); +} else { + // otherwise play sounds right away + playSounds(); } +function playSounds() { + print("EBL PLAY SOUNDS!") + var numSounds = 45; + for (var i = 0; i < numSounds; i++) { + playSound(); + } +} + + function playSound() { var position = Vec3.sum(basePosition, {x: randFloat(-.1, .1), y: randFloat(-1, 1), z: randFloat(-3, -.1)}); var injector = Audio.playSound(testSound, { From ec1c7925c04c55c657e8f2ff603e871d0775172d Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 12:02:22 -0800 Subject: [PATCH 03/10] updated logging --- examples/audioExamples/injectorLoadTest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index d394e3a49b..35e3e07868 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -26,7 +26,7 @@ var testSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-con if(!testSound.downloaded) { - print("EBL SOUND IS NOT READY YET") + print("SOUND IS NOT READY YET") testSound.ready.connect(function() { playSounds(); }); @@ -36,7 +36,7 @@ if(!testSound.downloaded) { } function playSounds() { - print("EBL PLAY SOUNDS!") + print("PLAY SOUNDS!") var numSounds = 45; for (var i = 0; i < numSounds; i++) { playSound(); From efbb5ec9670a3955912c10de1d1abd4d6c0899f0 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 12:14:30 -0800 Subject: [PATCH 04/10] updated test --- examples/audioExamples/injectorLoadTest.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index 35e3e07868..3842678590 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -12,6 +12,9 @@ Script.include("../libraries/utils.js"); + +var numSoundsToPlayPerBatch = 1; +var timeBetweenBatch = 100; // A green box represents an injector that is playing var basePosition = { @@ -23,6 +26,7 @@ var basePosition = { var soundBoxes = []; var testSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav"); +var totalInjectors = 0; if(!testSound.downloaded) { @@ -37,10 +41,14 @@ if(!testSound.downloaded) { function playSounds() { print("PLAY SOUNDS!") - var numSounds = 45; - for (var i = 0; i < numSounds; i++) { + for (var i = 0; i < numSoundsToPlayPerBatch; i++) { playSound(); - } + } + print("EBL Total Number of Injectors: " + totalInjectors); + + Script.setTimeout(function() { + playSounds(); + }, timeBetweenBatch); } @@ -48,8 +56,9 @@ function playSound() { var position = Vec3.sum(basePosition, {x: randFloat(-.1, .1), y: randFloat(-1, 1), z: randFloat(-3, -.1)}); var injector = Audio.playSound(testSound, { position: position, - volume: 0.3 + volume: 0.1 }); + totalInjectors++; var soundBox = Entities.addEntity({ type: "Box", From b0664b587f52dbaa312dc8dc8ccf2429642361ed Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 15:39:38 -0800 Subject: [PATCH 05/10] bumped injector count --- examples/audioExamples/injectorLoadTest.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index 3842678590..3af54c4c48 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -13,8 +13,9 @@ Script.include("../libraries/utils.js"); -var numSoundsToPlayPerBatch = 1; -var timeBetweenBatch = 100; +var numSoundsToPlayPerBatch = 41 +var numSoundsPlaying = 0; +var timeBetweenBatch = 10000; // A green box represents an injector that is playing var basePosition = { @@ -58,6 +59,9 @@ function playSound() { position: position, volume: 0.1 }); + + print("INJECTOR VALUE: " + JSON.stringify(injector)); + totalInjectors++; var soundBox = Entities.addEntity({ From c3a687e294aa475dfbba0257d5e538186c7aeb0d Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 16:06:53 -0800 Subject: [PATCH 06/10] ac test --- examples/audioExamples/injectorLoadTest.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index 3af54c4c48..af4dcaecf7 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -15,7 +15,7 @@ Script.include("../libraries/utils.js"); var numSoundsToPlayPerBatch = 41 var numSoundsPlaying = 0; -var timeBetweenBatch = 10000; +var timeBetweenBatch = 100000; // A green box represents an injector that is playing var basePosition = { @@ -45,6 +45,10 @@ function playSounds() { for (var i = 0; i < numSoundsToPlayPerBatch; i++) { playSound(); } + + Script.setTimeout(function() { + numSoundsPlaying = 0; + }, 1500); print("EBL Total Number of Injectors: " + totalInjectors); Script.setTimeout(function() { @@ -57,11 +61,13 @@ function playSound() { var position = Vec3.sum(basePosition, {x: randFloat(-.1, .1), y: randFloat(-1, 1), z: randFloat(-3, -.1)}); var injector = Audio.playSound(testSound, { position: position, - volume: 0.1 + volume: 0.2 }); + numSoundsPlaying++; + print("NUM SOUNDS PLAYING: " + numSoundsPlaying); + print("*******************************************"); print("INJECTOR VALUE: " + JSON.stringify(injector)); - totalInjectors++; var soundBox = Entities.addEntity({ From bc0216633e45deab2e27246fca289a8c6ecc0db6 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 16:10:12 -0800 Subject: [PATCH 07/10] more logging --- examples/audioExamples/injectorLoadTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index af4dcaecf7..cc9d47e17e 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -13,7 +13,7 @@ Script.include("../libraries/utils.js"); -var numSoundsToPlayPerBatch = 41 +var numSoundsToPlayPerBatch = 60 var numSoundsPlaying = 0; var timeBetweenBatch = 100000; // A green box represents an injector that is playing From d0660fc90a01893a0ac7a116f258ed917db91cde Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 16:17:22 -0800 Subject: [PATCH 08/10] logging --- examples/audioExamples/injectorLoadTest.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index cc9d47e17e..d34117f56c 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -13,9 +13,9 @@ Script.include("../libraries/utils.js"); -var numSoundsToPlayPerBatch = 60 +var numSoundsToPlayPerBatch = 50 var numSoundsPlaying = 0; -var timeBetweenBatch = 100000; +var timeBetweenBatch = 30000; // A green box represents an injector that is playing var basePosition = { @@ -67,7 +67,8 @@ function playSound() { numSoundsPlaying++; print("NUM SOUNDS PLAYING: " + numSoundsPlaying); print("*******************************************"); - print("INJECTOR VALUE: " + JSON.stringify(injector)); + print("INJECTOR VALUE: ") + print(JSON.stringify(injector)); totalInjectors++; var soundBox = Entities.addEntity({ From 33a232edde27abbdf91483ecb6f03af8f965dcd8 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 18 Feb 2016 18:17:37 -0800 Subject: [PATCH 09/10] got rid of magic numbers --- examples/audioExamples/injectorLoadTest.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index d34117f56c..59ddea6a3c 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -13,7 +13,7 @@ Script.include("../libraries/utils.js"); -var numSoundsToPlayPerBatch = 50 +var numSoundsToPlayPerBatch = 35 var numSoundsPlaying = 0; var timeBetweenBatch = 30000; // A green box represents an injector that is playing @@ -28,16 +28,19 @@ var soundBoxes = []; var testSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/dove.wav"); var totalInjectors = 0; +var clipDuration; if(!testSound.downloaded) { print("SOUND IS NOT READY YET") testSound.ready.connect(function() { playSounds(); + clipDuration = testSound.duration; }); } else { // otherwise play sounds right away playSounds(); + clipDuration = testSound.duration; } function playSounds() { @@ -48,7 +51,7 @@ function playSounds() { Script.setTimeout(function() { numSoundsPlaying = 0; - }, 1500); + }, clipDuration); print("EBL Total Number of Injectors: " + totalInjectors); Script.setTimeout(function() { From e4508e1d3466e5ab1c430c17d6910d71cd720d52 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Fri, 19 Feb 2016 12:06:08 -0800 Subject: [PATCH 10/10] added comment and name --- examples/audioExamples/injectorLoadTest.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/audioExamples/injectorLoadTest.js b/examples/audioExamples/injectorLoadTest.js index 59ddea6a3c..3df2d873c7 100644 --- a/examples/audioExamples/injectorLoadTest.js +++ b/examples/audioExamples/injectorLoadTest.js @@ -13,7 +13,7 @@ Script.include("../libraries/utils.js"); -var numSoundsToPlayPerBatch = 35 +var numSoundsToPlayPerBatch = 35 // Number of simultaneously playing sounds var numSoundsPlaying = 0; var timeBetweenBatch = 30000; // A green box represents an injector that is playing @@ -76,6 +76,7 @@ function playSound() { var soundBox = Entities.addEntity({ type: "Box", + name: "Debug Sound Box", color: {red: 200, green: 10, blue: 200}, dimensions: {x: 0.1, y: 0.1, z: 0.1}, position: position