From 2e88f1ab1fa6aecaf8b34e693a8f977e139bb5b2 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 7 Feb 2017 16:21:14 -0800 Subject: [PATCH] conserving audio interval --- scripts/system/pal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 7e451a39fb..adbde0ef5c 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -502,6 +502,8 @@ if (Settings.getValue("HUDUIEnabled")) { } var isWired = false; var audioTimer; +var AUDIO_LEVEL_UPDATE_INTERVAL_MS = 100; // 10hz for now (change this and change the AVERAGING_RATIO too) +var AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS = 300; function off() { if (isWired) { // It is not ok to disconnect these twice, hence guard. Script.update.disconnect(updateOverlays); @@ -526,7 +528,7 @@ function onClicked() { Controller.mouseMoveEvent.connect(handleMouseMoveEvent); triggerMapping.enable(); triggerPressMapping.enable(); - audioTimer = createAudioInterval(AUDIO_LEVEL_UPDATE_INTERVAL_MS / (conserveResources ? 3 : 1)); + audioTimer = createAudioInterval(conserveResources ? AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS : AUDIO_LEVEL_UPDATE_INTERVAL_MS); } else { off(); } @@ -562,9 +564,7 @@ var AVERAGING_RATIO = 0.05; var LOUDNESS_FLOOR = 11.0; var LOUDNESS_SCALE = 2.8 / 5.0; var LOG2 = Math.log(2.0); -var AUDIO_LEVEL_UPDATE_INTERVAL_MS = 100; // 10hz for now (change this and change the AVERAGING_RATIO too) var myData = {}; // we're not includied in ExtendedOverlay.get. -var audioInterval; function getAudioLevel(id) { // the VU meter should work similarly to the one in AvatarInputs: log scale, exponentially averaged