Code review / lint

This commit is contained in:
Philip Rosedale 2017-04-25 15:37:39 -07:00
parent eaa2102d3f
commit 16dd6a2ce1

View file

@ -30,7 +30,6 @@ Script.update.connect(function () {
// //
// Check for other people's audio levels, mute if anyone is talking. // Check for other people's audio levels, mute if anyone is talking.
// //
var othersLoudness = 0; var othersLoudness = 0;
var avatars = AvatarList.getAvatarIdentifiers(); var avatars = AvatarList.getAvatarIdentifiers();
avatars.forEach(function (id) { avatars.forEach(function (id) {
@ -39,7 +38,7 @@ Script.update.connect(function () {
othersLoudness += Math.round(avatar.audioLoudness); othersLoudness += Math.round(avatar.audioLoudness);
} }
// Mute other microphone avatars to not feedback with muti-source environment // Mute other microphone avatars to not feedback with muti-source environment
if (avatar.displayName.indexOf(MICROPHONE_DISPLAY_NAME) == 0) { if (avatar.displayName.indexOf(MICROPHONE_DISPLAY_NAME) === 0) {
if (!Users.getPersonalMuteStatus(avatar.sessionUUID)) { if (!Users.getPersonalMuteStatus(avatar.sessionUUID)) {
Users.personalMute(avatar.sessionUUID, true); Users.personalMute(avatar.sessionUUID, true);
} }
@ -49,13 +48,17 @@ Script.update.connect(function () {
averageLoudness = AVERAGING_TIME * averageLoudness + (1.0 - AVERAGING_TIME) * othersLoudness; averageLoudness = AVERAGING_TIME * averageLoudness + (1.0 - AVERAGING_TIME) * othersLoudness;
if (!isMuted && (averageLoudness > LOUDNESS_THRESHOLD * HYSTERESIS_GAP)) { if (!isMuted && (averageLoudness > LOUDNESS_THRESHOLD * HYSTERESIS_GAP)) {
if (debug) { print("Muted!"); } if (debug) {
print("Muted!");
}
isMuted = true; isMuted = true;
if (!AudioDevice.getMuted()) { if (!AudioDevice.getMuted()) {
AudioDevice.toggleMute(); AudioDevice.toggleMute();
} }
} else if (isMuted && (averageLoudness < LOUDNESS_THRESHOLD)) { } else if (isMuted && (averageLoudness < LOUDNESS_THRESHOLD)) {
if (debug) { print("UnMuted!"); } if (debug) {
print("UnMuted!");
}
isMuted = false; isMuted = false;
if (AudioDevice.getMuted()) { if (AudioDevice.getMuted()) {
AudioDevice.toggleMute(); AudioDevice.toggleMute();