Skip to content

Instantly share code, notes, and snippets.

@szastupov
Created November 11, 2017 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szastupov/4e80e3ef66b2d2d1a3dfbc00249b65a7 to your computer and use it in GitHub Desktop.
Save szastupov/4e80e3ef66b2d2d1a3dfbc00249b65a7 to your computer and use it in GitHub Desktop.
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