Created
November 11, 2017 00:47
-
-
Save szastupov/4e80e3ef66b2d2d1a3dfbc00249b65a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compress(signal, threshold, ratio, makeup) { | |
return signal.map(x => { | |
let amp = Math.abs(x) | |
let sign = Math.sign(x) | |
if (amp > threshold) { | |
amp = (amp - threshold) * ratio + threshold | |
} | |
return sign * (amp * makeup) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment