@thi.ng/dsp 4.6.19 → 4.7.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.
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-28T23:24:38Z
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
@@ -84,7 +84,7 @@ For Node.js REPL:
84
84
  const dsp = await import("@thi.ng/dsp");
85
85
  ```
86
86
 
87
- Package sizes (brotli'd, pre-treeshake): ESM: 7.52 KB
87
+ Package sizes (brotli'd, pre-treeshake): ESM: 7.57 KB
88
88
 
89
89
  ## Dependencies
90
90
 
@@ -253,6 +253,7 @@ Diagram of the FM/AM osc with some low pass filters applied:
253
253
  - [saw](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-saw.ts)
254
254
  - [sawAdditive](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-additive.ts)
255
255
  - [squareAdditive](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-additive.ts)
256
+ - [squareSin](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-square-sin.ts)
256
257
  - [sin](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-sin.ts)
257
258
  - [tri](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/osc-tri.ts)
258
259
  - [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.19",
3
+ "version": "4.7.0",
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.20",
43
- "@thi.ng/transducers": "^8.8.17"
39
+ "@thi.ng/api": "^8.9.15",
40
+ "@thi.ng/checks": "^3.4.15",
41
+ "@thi.ng/errors": "^2.4.9",
42
+ "@thi.ng/math": "^5.7.10",
43
+ "@thi.ng/random": "^3.6.22",
44
+ "@thi.ng/transducers": "^8.8.19"
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": "0d9265be7be13eccf0ef75eaedbfd42626339279\n"
291
+ "gitHead": "775c664723cd87d6ac5909cedf91195317add287\n"
288
292
  }