Fix my audio level

This commit is contained in:
Zach Fox 2018-07-12 15:16:54 -07:00
parent 92756d81ad
commit fa518b995a

View file

@ -525,6 +525,7 @@ function updateAudioLevel(overlay, avatarData) {
var audioLevel = 0.0;
var avgAudioLevel = 0.0;
if (overlay) {
// we will do exponential moving average by taking some the last loudness and averaging
overlay.accumulatedLevel = AVERAGING_RATIO * (overlay.accumulatedLevel || 0) + (1 - AVERAGING_RATIO) * (avatarData.audioLoudness);
@ -541,11 +542,13 @@ function updateAudioLevel(overlay, avatarData) {
// now scale for the gain. Also, asked to boost the low end, so one simple way is
// to take sqrt of the value. Lets try that, see how it feels.
avgAudioLevel = Math.min(1.0, Math.sqrt(avgAudioLevel * (sessionGains[avatarData.sessionUUID] || 0.75)));
} else {
audioLevel = scaleAudio(Math.log(((1 - AVERAGING_RATIO) * (avatarData.audioLoudness)) + 1) / LOG2);
}
var param = {};
var level = [audioLevel, avgAudioLevel];
var userId = avatarData.sessionUUID || 0;
var userId = avatarData.sessionUUID === MyAvatar.sessionUUID ? 0 : avatarData.sessionUUID;
param[userId] = level;
sendToQml({ method: 'updateAudioLevel', params: param });
}
@ -557,6 +560,8 @@ function updateOverlays() {
var avatarData = JSON.parse(AvatarList.getPalData());
avatarData.forEach(function (currentAvatarData) {
updateAudioLevel(overlay, currentAvatarData);
if (currentAvatarData.sessionUUID === MyAvatar.sessionUUID || !avatarsOfInterest[currentAvatarData.sessionUUID]) {
return; // don't update ourself, or avatars we're not interested in
}
@ -566,8 +571,6 @@ function updateOverlays() {
overlay = addAvatarNode(currentAvatarData.sessionUUID);
}
updateAudioLevel(overlay, currentAvatarData);
var target = currentAvatarData.position;
var distance = Vec3.distance(target, eye);
var offset = currentAvatarData.palOrbOffset;