1
0
Эх сурвалжийг харах

fix: change default limiter settings

Sven 1 жил өмнө
parent
commit
63af1a7

+ 5 - 0
.changeset/tidy-years-kneel.md

@@ -0,0 +1,5 @@
+---
+"@sv443-network/userutils": patch
+---
+
+Change default limiter options to be more balanced

+ 2 - 2
README.md

@@ -490,7 +490,7 @@ This is the processing workflow applied to the media element:
   
 A limiter (compression) is applied to the audio to prevent clipping.  
 Its properties can be changed by calling the returned function `setLimiterOptions()`  
-The default props are `{ threshold: -2, knee: 40, ratio: 12, attack: 0.003, release: 0.25 }`  
+The limiter options set by default are `{ threshold: -12, knee: 30, ratio: 12, attack: 0.003, release: 0.25 }`  
   
 ⚠️ This function has to be run in response to a user interaction event, else the browser will reject it because of the strict autoplay policy.  
 ⚠️ Make sure to call the returned function `enable()` after calling this function to actually enable the amplification.  
@@ -502,7 +502,7 @@ The returned object of the type `AmplifyMediaResult` has the following propertie
 | `getGain()` | Returns the current gain multiplier |
 | `enable()` | Call to enable the amplification for the first time or if it was disabled before |
 | `disable()` | Call to disable amplification |
-| `setLimiterOptions()` | Used for changing the [options of the DynamicsCompressorNode](https://developer.mozilla.org/en-US/docs/Web/API/DynamicsCompressorNode/DynamicsCompressorNode#options) - the default is `{ threshold: -2, knee: 40, ratio: 12, attack: 0.003, release: 0.25 }` |
+| `setLimiterOptions()` | Used for changing the [options of the DynamicsCompressorNode](https://developer.mozilla.org/en-US/docs/Web/API/DynamicsCompressorNode/DynamicsCompressorNode#options) - the default is `{ threshold: -12, knee: 30, ratio: 12, attack: 0.003, release: 0.25 }` |
 | `context` | The AudioContext instance |
 | `source` | The MediaElementSourceNode instance |
 | `gainNode` | The GainNode instance used for actually boosting the gain |

+ 3 - 3
lib/dom.ts

@@ -184,7 +184,7 @@ export function amplifyMedia<TElem extends HTMLMediaElement>(mediaElement: TElem
     },
     /**
      * Set the options of the [limiter / DynamicsCompressorNode](https://developer.mozilla.org/en-US/docs/Web/API/DynamicsCompressorNode/DynamicsCompressorNode#options)  
-     * The default is `{ threshold: -2, knee: 40, ratio: 12, attack: 0.003, release: 0.25 }`
+     * The default is `{ threshold: -12, knee: 30, ratio: 12, attack: 0.003, release: 0.25 }`
      */
     setLimiterOptions(options: Partial<Record<"threshold" | "knee" | "ratio" | "attack" | "release", number>>) {
       for(const [key, val] of Object.entries(options))
@@ -198,8 +198,8 @@ export function amplifyMedia<TElem extends HTMLMediaElement>(mediaElement: TElem
   };
 
   props.setLimiterOptions({
-    threshold: -2,
-    knee: 40,
+    threshold: -12,
+    knee: 30,
     ratio: 12,
     attack: 0.003,
     release: 0.25,