@newgameplusinc/odyssey-audio-video-sdk-dev 1.0.256 → 1.0.257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -61,7 +61,6 @@ export declare class SpatialAudioManager extends EventManager {
|
|
|
61
61
|
private positionSnapThreshold;
|
|
62
62
|
private cachedGainValues;
|
|
63
63
|
private gainChangeThreshold;
|
|
64
|
-
private minimumStableGain;
|
|
65
64
|
private _listenerDebugLogTime?;
|
|
66
65
|
private mlSuppressor;
|
|
67
66
|
private mlModelReady;
|
|
@@ -50,11 +50,8 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
50
50
|
// Caches last calculated gain value for each participant
|
|
51
51
|
this.cachedGainValues = new Map();
|
|
52
52
|
// Minimum gain change (0-1 scale) to trigger update
|
|
53
|
-
// 0.
|
|
54
|
-
this.gainChangeThreshold = 0.
|
|
55
|
-
// Minimum stable gain floor - never go below this when participant is audible
|
|
56
|
-
// This ensures audio is always clearly audible when within max distance
|
|
57
|
-
this.minimumStableGain = 0.15; // 15% minimum when within range
|
|
53
|
+
// 0.05 = 5% change required - filters out tiny distance jitter
|
|
54
|
+
this.gainChangeThreshold = 0.05;
|
|
58
55
|
// NOTE: Rate limiting variables removed - setTargetAtTime provides sufficient smoothing
|
|
59
56
|
// The smoothPanValue() and position snapping handle jitter reduction
|
|
60
57
|
// ML Noise Suppressor (TensorFlow.js-based)
|
|
@@ -441,35 +438,23 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
441
438
|
const panning = this.panningFromPanValue(smoothedPanValue, dxLocal);
|
|
442
439
|
// Calculate gain based on distance
|
|
443
440
|
const calculatedGain = this.calculateLogarithmicGain(distance);
|
|
444
|
-
|
|
445
|
-
//
|
|
446
|
-
// when within max distance (15m). This prevents "too quiet" audio.
|
|
447
|
-
newGainValue = Math.max(newGainValue, this.minimumStableGain);
|
|
448
|
-
// GAIN STABILIZATION: Only update gain if change exceeds threshold
|
|
449
|
-
// This prevents audio fluctuations when users are stationary
|
|
441
|
+
const newGainValue = calculatedGain / 100; // Convert to 0-1 range
|
|
442
|
+
// SIMPLE GAIN STABILIZATION: Only update if change exceeds threshold
|
|
450
443
|
const cachedGain = this.cachedGainValues.get(participantId);
|
|
451
444
|
let finalGainValue = newGainValue;
|
|
452
|
-
if (cachedGain !== undefined
|
|
445
|
+
if (cachedGain !== undefined) {
|
|
453
446
|
const gainChange = Math.abs(newGainValue - cachedGain);
|
|
454
|
-
|
|
455
|
-
// This prevents oscillation around threshold boundaries
|
|
456
|
-
const isIncreasing = newGainValue > cachedGain;
|
|
457
|
-
const effectiveThreshold = isIncreasing
|
|
458
|
-
? this.gainChangeThreshold * 0.8 // Easier to increase (respond to getting closer)
|
|
459
|
-
: this.gainChangeThreshold * 1.2; // Harder to decrease (resist getting quieter)
|
|
460
|
-
if (gainChange < effectiveThreshold) {
|
|
447
|
+
if (gainChange < this.gainChangeThreshold) {
|
|
461
448
|
// Change too small - keep cached value for stability
|
|
462
449
|
finalGainValue = cachedGain;
|
|
463
450
|
}
|
|
464
451
|
else {
|
|
465
|
-
// Significant change -
|
|
466
|
-
|
|
467
|
-
finalGainValue = newGainValue * 0.7 + cachedGain * 0.3;
|
|
468
|
-
this.cachedGainValues.set(participantId, finalGainValue);
|
|
452
|
+
// Significant change - update cache
|
|
453
|
+
this.cachedGainValues.set(participantId, newGainValue);
|
|
469
454
|
}
|
|
470
455
|
}
|
|
471
456
|
else {
|
|
472
|
-
// First time
|
|
457
|
+
// First time - cache the value
|
|
473
458
|
this.cachedGainValues.set(participantId, newGainValue);
|
|
474
459
|
}
|
|
475
460
|
// Apply panning
|
|
@@ -478,9 +463,8 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
478
463
|
const currentTime = this.audioContext.currentTime;
|
|
479
464
|
try {
|
|
480
465
|
// setTargetAtTime provides smooth exponential interpolation
|
|
481
|
-
// Time constant 0.
|
|
482
|
-
|
|
483
|
-
nodes.gain.gain.setTargetAtTime(finalGainValue, currentTime, 0.25);
|
|
466
|
+
// Time constant 0.1 = ~300ms to settle
|
|
467
|
+
nodes.gain.gain.setTargetAtTime(finalGainValue, currentTime, 0.1);
|
|
484
468
|
}
|
|
485
469
|
catch (err) {
|
|
486
470
|
// Fallback: If scheduling fails, set value directly (rare edge case)
|
|
@@ -1087,9 +1071,9 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
1087
1071
|
* - 10m+ → 5% (minimum, barely audible)
|
|
1088
1072
|
*/
|
|
1089
1073
|
calculateLogarithmicGain(distance) {
|
|
1090
|
-
const minDistance = 1.
|
|
1091
|
-
const minGain =
|
|
1092
|
-
const falloffRate = 0.12; // Controls how fast volume drops (
|
|
1074
|
+
const minDistance = 1.0; // Full volume at 1m or closer
|
|
1075
|
+
const minGain = 15; // Minimum 15% at far distances (still audible)
|
|
1076
|
+
const falloffRate = 0.12; // Controls how fast volume drops (gentler)
|
|
1093
1077
|
// Full volume within minimum distance
|
|
1094
1078
|
if (distance <= minDistance)
|
|
1095
1079
|
return 100;
|
package/package.json
CHANGED