@newgameplusinc/odyssey-audio-video-sdk-dev 1.0.23 → 1.0.25
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.
- package/README.md +7 -7
- package/dist/SpatialAudioManager.js +56 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,16 +91,16 @@ These layers run entirely in Web Audio, so you can ship “AirPods-style” back
|
|
|
91
91
|
```ts
|
|
92
92
|
const sdk = new OdysseySpatialComms(serverUrl, {
|
|
93
93
|
denoiser: {
|
|
94
|
-
threshold: 0.
|
|
95
|
-
maxReduction: 0.
|
|
96
|
-
hissCut: 0.
|
|
97
|
-
holdMs:
|
|
94
|
+
threshold: 0.008,
|
|
95
|
+
maxReduction: 0.88,
|
|
96
|
+
hissCut: 0.52,
|
|
97
|
+
holdMs: 260,
|
|
98
98
|
voiceBoost: 0.65,
|
|
99
99
|
voiceSensitivity: 0.33,
|
|
100
100
|
voiceEnhancement: true,
|
|
101
|
-
silenceFloor: 0.
|
|
102
|
-
silenceHoldMs:
|
|
103
|
-
silenceReleaseMs:
|
|
101
|
+
silenceFloor: 0.00075,
|
|
102
|
+
silenceHoldMs: 520,
|
|
103
|
+
silenceReleaseMs: 160,
|
|
104
104
|
},
|
|
105
105
|
});
|
|
106
106
|
```
|
|
@@ -604,6 +604,8 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
604
604
|
this.voiceSensitivity = this._sanitize(cfg.voiceSensitivity, 0.05, 0.9, 0.35);
|
|
605
605
|
this.voiceEnhancement = cfg.voiceEnhancement === true;
|
|
606
606
|
this.silenceFloor = this._sanitize(cfg.silenceFloor, 0.0002, 0.02, 0.00085);
|
|
607
|
+
this.gateGraceSamples = Math.round(sampleRate * 0.45);
|
|
608
|
+
this.postSpeechHoldSamples = Math.round(sampleRate * 0.35);
|
|
607
609
|
this.silenceHoldSamples = Math.max(
|
|
608
610
|
8,
|
|
609
611
|
Math.round(
|
|
@@ -645,6 +647,8 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
645
647
|
silenceReleaseCounter: 0,
|
|
646
648
|
isSilenced: false,
|
|
647
649
|
muteGain: 1,
|
|
650
|
+
graceSamplesRemaining: this.gateGraceSamples,
|
|
651
|
+
postSpeechHold: 0,
|
|
648
652
|
};
|
|
649
653
|
}
|
|
650
654
|
return this.channelState[index];
|
|
@@ -741,6 +745,13 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
741
745
|
|
|
742
746
|
state.envelope += (magnitude - state.envelope) * this.attack;
|
|
743
747
|
|
|
748
|
+
if (speechPresence > 0.12 || state.envelope > this.threshold * 1.1) {
|
|
749
|
+
state.graceSamplesRemaining = this.gateGraceSamples;
|
|
750
|
+
state.postSpeechHold = this.postSpeechHoldSamples;
|
|
751
|
+
} else if (state.postSpeechHold > 0) {
|
|
752
|
+
state.postSpeechHold--;
|
|
753
|
+
}
|
|
754
|
+
|
|
744
755
|
if (state.envelope < this.threshold) {
|
|
745
756
|
state.noise += (state.envelope - state.noise) * this.learnRate;
|
|
746
757
|
state.quietSamples++;
|
|
@@ -748,35 +759,44 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
748
759
|
state.quietSamples = 0;
|
|
749
760
|
}
|
|
750
761
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
state.
|
|
754
|
-
|
|
755
|
-
state.silenceSamples = Math.max(0, state.silenceSamples - 3);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
if (!state.isSilenced && state.silenceSamples > this.silenceHoldSamples) {
|
|
759
|
-
state.isSilenced = true;
|
|
762
|
+
if (state.graceSamplesRemaining > 0 || state.postSpeechHold > 0) {
|
|
763
|
+
state.graceSamplesRemaining--;
|
|
764
|
+
state.isSilenced = false;
|
|
765
|
+
state.silenceSamples = 0;
|
|
760
766
|
state.silenceReleaseCounter = 0;
|
|
761
|
-
}
|
|
767
|
+
} else {
|
|
768
|
+
const belowFloor = state.envelope < this.silenceFloor;
|
|
769
|
+
if (belowFloor && speechPresence < 0.15) {
|
|
770
|
+
state.silenceSamples++;
|
|
771
|
+
} else {
|
|
772
|
+
state.silenceSamples = Math.max(0, state.silenceSamples - 3);
|
|
773
|
+
}
|
|
762
774
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
const wakeFromVoice = speechPresence > 0.25;
|
|
766
|
-
if (wakeFromEnergy || wakeFromVoice) {
|
|
767
|
-
state.isSilenced = false;
|
|
768
|
-
state.silenceSamples = 0;
|
|
775
|
+
if (!state.isSilenced && state.silenceSamples > this.silenceHoldSamples) {
|
|
776
|
+
state.isSilenced = true;
|
|
769
777
|
state.silenceReleaseCounter = 0;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (state.isSilenced) {
|
|
781
|
+
const wakeFromEnergy = state.envelope > this.silenceFloor * 1.2;
|
|
782
|
+
const wakeFromVoice = speechPresence > 0.15;
|
|
783
|
+
if (wakeFromEnergy || wakeFromVoice) {
|
|
773
784
|
state.isSilenced = false;
|
|
774
785
|
state.silenceSamples = 0;
|
|
775
786
|
state.silenceReleaseCounter = 0;
|
|
787
|
+
state.postSpeechHold = this.postSpeechHoldSamples;
|
|
788
|
+
state.graceSamplesRemaining = this.gateGraceSamples;
|
|
789
|
+
} else {
|
|
790
|
+
state.silenceReleaseCounter++;
|
|
791
|
+
if (state.silenceReleaseCounter > this.silenceReleaseSamples) {
|
|
792
|
+
state.isSilenced = false;
|
|
793
|
+
state.silenceSamples = 0;
|
|
794
|
+
state.silenceReleaseCounter = 0;
|
|
795
|
+
}
|
|
776
796
|
}
|
|
797
|
+
} else {
|
|
798
|
+
state.silenceReleaseCounter = 0;
|
|
777
799
|
}
|
|
778
|
-
} else {
|
|
779
|
-
state.silenceReleaseCounter = 0;
|
|
780
800
|
}
|
|
781
801
|
|
|
782
802
|
const ratio = state.noise / Math.max(state.envelope, 1e-6);
|
|
@@ -808,8 +828,9 @@ class SpatialAudioManager extends EventManager_1.EventManager {
|
|
|
808
828
|
const hissGain = 1 - hissRatio * (this.hissCut * (1 - 0.4 * speechPresence));
|
|
809
829
|
processed = state.lpState + highComponent * hissGain;
|
|
810
830
|
|
|
811
|
-
const muteTarget = state.isSilenced ? 0 : 1;
|
|
812
|
-
|
|
831
|
+
const muteTarget = state.isSilenced ? 0.05 : 1;
|
|
832
|
+
const smoothing = state.isSilenced ? 0.12 : 0.42;
|
|
833
|
+
state.muteGain += (muteTarget - state.muteGain) * smoothing;
|
|
813
834
|
processed *= state.muteGain;
|
|
814
835
|
|
|
815
836
|
outChannel[i] = processed;
|
|
@@ -849,21 +870,21 @@ registerProcessor('odyssey-denoise', OdysseyDenoiseProcessor);
|
|
|
849
870
|
};
|
|
850
871
|
const denoiserDefaults = {
|
|
851
872
|
enabled: true,
|
|
852
|
-
threshold: 0.
|
|
853
|
-
noiseFloor: 0.
|
|
854
|
-
release: 0.
|
|
855
|
-
attack: 0.
|
|
856
|
-
holdMs:
|
|
857
|
-
maxReduction: 0.
|
|
858
|
-
hissCut: 0.
|
|
859
|
-
expansionRatio: 2.
|
|
860
|
-
learnRate: 0.
|
|
873
|
+
threshold: 0.008,
|
|
874
|
+
noiseFloor: 0.002,
|
|
875
|
+
release: 0.22,
|
|
876
|
+
attack: 0.36,
|
|
877
|
+
holdMs: 260,
|
|
878
|
+
maxReduction: 0.88,
|
|
879
|
+
hissCut: 0.52,
|
|
880
|
+
expansionRatio: 2.15,
|
|
881
|
+
learnRate: 0.045,
|
|
861
882
|
voiceBoost: 0.65,
|
|
862
883
|
voiceSensitivity: 0.33,
|
|
863
884
|
voiceEnhancement: false,
|
|
864
|
-
silenceFloor: 0.
|
|
865
|
-
silenceHoldMs:
|
|
866
|
-
silenceReleaseMs:
|
|
885
|
+
silenceFloor: 0.00075,
|
|
886
|
+
silenceHoldMs: 520,
|
|
887
|
+
silenceReleaseMs: 160,
|
|
867
888
|
};
|
|
868
889
|
return {
|
|
869
890
|
distance: {
|
package/package.json
CHANGED