@thi.ng/dsp 4.6.20 → 4.7.1

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-19T11:01:47Z
3
+ - **Last updated**: 2023-12-31T09:44:23Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [4.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.7.0) (2023-12-28)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add squareSin() oscillator ([f7f1b1a](https://github.com/thi-ng/umbrella/commit/f7f1b1a))
17
+
12
18
  ## [4.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/dsp@4.6.0) (2023-09-28)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -7,8 +7,9 @@
7
7
  ![npm downloads](https://img.shields.io/npm/dm/@thi.ng/dsp.svg)
8
8
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
9
9
 
10
- This project is part of the
11
- [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
10
+ This is a standalone project, maintained as part of the
11
+ [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and
12
+ anti-framework.
12
13
 
13
14
  - [About](#about)
14
15
  - [Status](#status)
@@ -84,7 +85,7 @@ For Node.js REPL:
84
85
  const dsp = await import("@thi.ng/dsp");
85
86
  ```
86
87
 
87
- Package sizes (brotli'd, pre-treeshake): ESM: 7.52 KB
88
+ Package sizes (brotli'd, pre-treeshake): ESM: 7.57 KB
88
89
 
89
90
  ## Dependencies
90
91
 
@@ -253,6 +254,7 @@ Diagram of the FM/AM osc with some low pass filters applied:
253
254
  - [saw](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-saw.ts)
254
255
  - [sawAdditive](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-additive.ts)
255
256
  - [squareAdditive](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-additive.ts)
257
+ - [squareSin](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-square-sin.ts)
256
258
  - [sin](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-sin.ts)
257
259
  - [tri](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-tri.ts)
258
260
  - [wavetable](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-wavetable.ts)
package/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export * from "./osc-dsf.js";
39
39
  export * from "./osc-mix.js";
40
40
  export * from "./osc-parabolic.js";
41
41
  export * from "./osc-rect.js";
42
+ export * from "./osc-square-sin.js";
42
43
  export * from "./osc-saw.js";
43
44
  export * from "./osc-sin.js";
44
45
  export * from "./osc-tri.js";
package/index.js CHANGED
@@ -39,6 +39,7 @@ export * from "./osc-dsf.js";
39
39
  export * from "./osc-mix.js";
40
40
  export * from "./osc-parabolic.js";
41
41
  export * from "./osc-rect.js";
42
+ export * from "./osc-square-sin.js";
42
43
  export * from "./osc-saw.js";
43
44
  export * from "./osc-sin.js";
44
45
  export * from "./osc-tri.js";
@@ -0,0 +1,14 @@
1
+ import type { StatelessOscillator } from "./api.js";
2
+ /**
3
+ * Returns a {@link StatelessOscillator} function with adjustable waveform based
4
+ * on given `squareness` param (in [0..1) interval). If `squareness = 0` the
5
+ * waveform will be a perfect sine. Higher values morph the waveform
6
+ * increasingly into a square wave.
7
+ *
8
+ * @remarks
9
+ * Interactive graph: https://www.desmos.com/calculator/nbvd97m3kl
10
+ *
11
+ * @param squareness
12
+ */
13
+ export declare const squareSin: (squareness: number) => StatelessOscillator;
14
+ //# sourceMappingURL=osc-square-sin.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { TAU } from "@thi.ng/math/api";
2
+ const squareSin = (squareness) => {
3
+ squareness = 1 - squareness;
4
+ return (phase, freq, amp = 1, dc = 0) => {
5
+ const y = Math.sin(phase * freq * TAU);
6
+ return dc + amp * Math.sign(y) * Math.abs(y) ** squareness;
7
+ };
8
+ };
9
+ export {
10
+ squareSin
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/dsp",
3
- "version": "4.6.20",
3
+ "version": "4.7.1",
4
4
  "description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -32,22 +32,23 @@
32
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
34
34
  "pub": "yarn npm publish --access public",
35
- "test": "bun test"
35
+ "test": "bun test",
36
+ "tool:diagrams": "bun tools/generate-diagrams.ts"
36
37
  },
37
38
  "dependencies": {
38
- "@thi.ng/api": "^8.9.14",
39
- "@thi.ng/checks": "^3.4.14",
40
- "@thi.ng/errors": "^2.4.8",
41
- "@thi.ng/math": "^5.7.9",
42
- "@thi.ng/random": "^3.6.21",
43
- "@thi.ng/transducers": "^8.8.18"
39
+ "@thi.ng/api": "^8.9.16",
40
+ "@thi.ng/checks": "^3.4.16",
41
+ "@thi.ng/errors": "^2.4.10",
42
+ "@thi.ng/math": "^5.7.11",
43
+ "@thi.ng/random": "^3.6.23",
44
+ "@thi.ng/transducers": "^8.8.20"
44
45
  },
45
46
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.38.3",
47
- "esbuild": "^0.19.8",
47
+ "@microsoft/api-extractor": "^7.39.0",
48
+ "esbuild": "^0.19.10",
48
49
  "rimraf": "^5.0.5",
49
50
  "typedoc": "^0.25.4",
50
- "typescript": "^5.3.2"
51
+ "typescript": "^5.3.3"
51
52
  },
52
53
  "keywords": [
53
54
  "allpass",
@@ -223,6 +224,9 @@
223
224
  "./osc-sin": {
224
225
  "default": "./osc-sin.js"
225
226
  },
227
+ "./osc-square-sin": {
228
+ "default": "./osc-square-sin.js"
229
+ },
226
230
  "./osc-tri": {
227
231
  "default": "./osc-tri.js"
228
232
  },
@@ -284,5 +288,5 @@
284
288
  ],
285
289
  "year": 2015
286
290
  },
287
- "gitHead": "36d93175f8fbc0190c3c96a9ac0016a9663e9a80\n"
291
+ "gitHead": "b3db173682e1148cf08a6bd907b8d90b47b7c066\n"
288
292
  }