@audio/saturate-waveshaper 1.0.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.
Files changed (2) hide show
  1. package/package.json +32 -0
  2. package/waveshaper.js +8 -0
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@audio/saturate-waveshaper",
3
+ "version": "1.0.0",
4
+ "description": "Waveshaper — normalized tanh or custom curve, oversampled",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "waveshaper.js",
8
+ "exports": {
9
+ ".": "./waveshaper.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "waveshaper.js"
14
+ ],
15
+ "dependencies": {
16
+ "@audio/saturate-core": "^1.0.0"
17
+ },
18
+ "keywords": [
19
+ "audio",
20
+ "dsp",
21
+ "saturation",
22
+ "waveshaper"
23
+ ],
24
+ "license": "MIT",
25
+ "author": "Dmitry Iv. <dfcreative@gmail.com>",
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
package/waveshaper.js ADDED
@@ -0,0 +1,8 @@
1
+ // Waveshaper — normalized tanh (default) or custom transfer curve, oversampled.
2
+ import { shape } from '@audio/saturate-core'
3
+
4
+ export default function waveshaper (data, { drive = 2, curve, fs = 44100, oversample = 4, mix = 1 } = {}) {
5
+ let norm = Math.tanh(drive)
6
+ let fn = curve || (x => Math.tanh(drive * x) / norm)
7
+ return shape(data, fn, { fs, oversample, mix })
8
+ }