@edkimmel/expo-audio-stream 0.3.1 → 0.3.2-beta.0
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.
|
@@ -7,12 +7,27 @@ import android.media.audiofx.NoiseSuppressor
|
|
|
7
7
|
import android.util.Log
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Manages audio effects for voice recording
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Manages hardware audio effects for voice recording.
|
|
11
|
+
*
|
|
12
|
+
* We use VOICE_RECOGNITION as our audio source. The Android CDD (Section 5.4)
|
|
13
|
+
* mandates that this source delivers unprocessed audio:
|
|
14
|
+
* [C-1-2] MUST disable noise reduction by default
|
|
15
|
+
* [C-1-3] MUST disable automatic gain control by default
|
|
16
|
+
*
|
|
17
|
+
* NS and AGC are therefore off by default to honor the spec. Enabling them
|
|
18
|
+
* re-introduces the processing the CDD explicitly prohibits for this source
|
|
19
|
+
* and can cause low-volume capture on many OEMs.
|
|
20
|
+
*
|
|
21
|
+
* AEC is the one effect the CDD permits for VOICE_RECOGNITION ("expects a
|
|
22
|
+
* stream that has an echo cancellation effect if available"), so it is
|
|
23
|
+
* enabled by default.
|
|
14
24
|
*/
|
|
15
|
-
class AudioEffectsManager
|
|
25
|
+
class AudioEffectsManager(
|
|
26
|
+
/** Enable hardware noise suppressor. Default false — CDD 5.4 [C-1-2] prohibits it for VOICE_RECOGNITION. */
|
|
27
|
+
private val enableNS: Boolean = false,
|
|
28
|
+
/** Enable hardware AGC. Default false — CDD 5.4 [C-1-3] prohibits it for VOICE_RECOGNITION. */
|
|
29
|
+
private val enableAGC: Boolean = false
|
|
30
|
+
) {
|
|
16
31
|
// Audio effects
|
|
17
32
|
private var acousticEchoCanceler: AcousticEchoCanceler? = null
|
|
18
33
|
private var noiseSuppressor: NoiseSuppressor? = null
|
|
@@ -41,11 +56,21 @@ class AudioEffectsManager {
|
|
|
41
56
|
Log.d(Constants.TAG, "Acoustic Echo Canceler enabled: ${acousticEchoCanceler?.enabled}")
|
|
42
57
|
}
|
|
43
58
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
// NS off by default — CDD 5.4 [C-1-2] prohibits it for VOICE_RECOGNITION.
|
|
60
|
+
// Enabling it can aggressively attenuate speech on many OEMs.
|
|
61
|
+
if (enableNS) {
|
|
62
|
+
enableNoiseSuppression(audioSessionId)
|
|
63
|
+
} else {
|
|
64
|
+
Log.d(Constants.TAG, "Noise Suppressor skipped (CDD 5.4 [C-1-2])")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// AGC off by default — CDD 5.4 [C-1-3] prohibits it for VOICE_RECOGNITION.
|
|
68
|
+
// Hardware AGC is also unreliable across devices.
|
|
69
|
+
if (enableAGC) {
|
|
70
|
+
enableAutomaticGainControl(audioSessionId)
|
|
71
|
+
} else {
|
|
72
|
+
Log.d(Constants.TAG, "Hardware AGC skipped (CDD 5.4 [C-1-3])")
|
|
73
|
+
}
|
|
49
74
|
|
|
50
75
|
} catch (e: Exception) {
|
|
51
76
|
Log.e(Constants.TAG, "Error setting up audio effects", e)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edkimmel/expo-audio-stream",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2-beta.0",
|
|
4
4
|
"description": "Expo Play Audio Stream module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|
|
47
47
|
"registry": "https://registry.npmjs.org/"
|
|
48
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"stableVersion": "0.3.1"
|
|
49
50
|
}
|