@thi.ng/dsp 4.3.17 → 4.3.20

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 (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +53 -43
  3. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-04T10:58:19Z
3
+ - **Last updated**: 2023-08-12T13:14:08Z
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.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  <!-- This file is generated - DO NOT EDIT! -->
2
+ <!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
2
3
 
3
- # ![@thi.ng/dsp](https://media.thi.ng/umbrella/banners-20220914/thing-dsp.svg?5dc8dc3b)
4
+ # ![@thi.ng/dsp](https://media.thi.ng/umbrella/banners-20230807/thing-dsp.svg?5dc8dc3b)
4
5
 
5
6
  [![npm version](https://img.shields.io/npm/v/@thi.ng/dsp.svg)](https://www.npmjs.com/package/@thi.ng/dsp)
6
7
  ![npm downloads](https://img.shields.io/npm/dm/@thi.ng/dsp.svg)
@@ -49,12 +50,11 @@ Partially ported from other thi.ng projects (e.g.
49
50
 
50
51
  [Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bdsp%5D+in%3Atitle)
51
52
 
52
- Even though this library is now at v2.0.0 and still retains most of the
53
- features from earlier versions, all recently added features (IGen's,
54
- IProc's, composition ops etc.) should be considered "beta" and are
55
- likely to undergo further (hopefully not too drastic) changes in the
56
- near future. Also, pending outcomes of ongoing experiments, some aspects
57
- might be ported to WASM.
53
+ Even though this library is now at v2.0.0 and still retains most of the features
54
+ from earlier versions, all recently added features (IGen's, IProc's, composition
55
+ ops etc.) should be considered "beta" and are likely to undergo further
56
+ (hopefully not too drastic) changes in the near future. Also, pending outcomes
57
+ of ongoing experiments, some aspects might be ported to WASM.
58
58
 
59
59
  ## Support packages
60
60
 
@@ -107,6 +107,7 @@ A selection:
107
107
  |:-----------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
108
108
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fft-synth.png" width="240"/> | Interactive inverse FFT toy synth | [Demo](https://demo.thi.ng/umbrella/fft-synth/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fft-synth) |
109
109
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-basics.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-basics) |
110
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-zoom.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-zoom/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-zoom) |
110
111
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/poly-spline.png" width="240"/> | Polygon to cubic curve conversion & visualization | [Demo](https://demo.thi.ng/umbrella/poly-spline/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/poly-spline) |
111
112
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rasterize-blend.jpg" width="240"/> | Steering behavior drawing with alpha-blended shapes | [Demo](https://demo.thi.ng/umbrella/rasterize-blend/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rasterize-blend) |
112
113
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cubemap.jpg" width="240"/> | WebGL cube maps with async texture loading | [Demo](https://demo.thi.ng/umbrella/webgl-cubemap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cubemap) |
@@ -118,17 +119,15 @@ A selection:
118
119
 
119
120
  ### IGen
120
121
 
121
- The following unit generators are infinite data sources based on the
122
- [`IGen`
122
+ The following unit generators are infinite data sources based on the [`IGen`
123
123
  interface](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/api.ts)
124
- with most being resettable too. The interface is similar to ES6
125
- iterators in that the next value can be obtained by calling `.next()`,
126
- however since `IGen`s are always infinite, there's no need to [wrap the
127
- result
124
+ with most being resettable too. The interface is similar to ES6 iterators in
125
+ that the next value can be obtained by calling `.next()`, however since `IGen`s
126
+ are always infinite, there's no need to [wrap the result
128
127
  value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol)
129
- as is done with ES6 iterables. Furthermore, all gens defined in this
130
- package do implement `Symbol.iterator` and so can actually be used as
131
- standard iterables as well.
128
+ as is done with ES6 iterables. Furthermore, all gens defined in this package do
129
+ implement `Symbol.iterator` and so can actually be used as standard iterables as
130
+ well.
132
131
 
133
132
  `IGen` also implements the
134
133
  [`IDeref`](https://github.com/thi-ng/umbrella/blob/develop/packages/api/src/api/deref.ts)
@@ -185,10 +184,10 @@ import { take } from "@thi.ng/transducers";
185
184
  ```
186
185
 
187
186
  - [add](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/add.ts) - adder
188
- - [adsr](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/add.ts) - timebased ADSR / AD envelope generator
187
+ - [adsr](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/adsr.ts) - timebased ADSR / AD envelope generator
189
188
  - [alt](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/alt.ts) - alternating values
190
189
  - [constant](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/const.ts) - constant value
191
- - [cosine](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/cosp.ts) - trig-free cosine osc
190
+ - [cosine](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/cosine.ts) - trig-free cosine osc
192
191
  - [curve](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/curve.ts) - timebased exponential gain/decay (factory for `madd`)
193
192
  - [impulse](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/impulse.ts) - impulse gen
194
193
  - [impulseTrain](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/impulse-train.ts) - timebased cyclic impulse
@@ -199,7 +198,7 @@ import { take } from "@thi.ng/transducers";
199
198
  - [reciprocal](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/reciprocal.ts) - fractional sequence (1, 1/2, 1/3, 1/4 etc.)
200
199
  - [sincos](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/sincos.ts) - trig-free sin/cos LFO
201
200
  - [sweep](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/sweep.ts) - freq sweep gen w/ phase accumulation for oscillators
202
- - [whiteNoise](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/pink-noise.ts) - white noise
201
+ - [whiteNoise](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/white-noise.ts) - white noise
203
202
 
204
203
  #### Higher order generators
205
204
 
@@ -261,18 +260,25 @@ Diagram of the FM/AM osc with some low pass filters applied:
261
260
 
262
261
  ### IProc
263
262
 
264
- The second fundamental interface in this package, similar to `IGen` and
265
- used to implement processors & transformers of input values (e.g those
266
- generated by the various `IGen`s available). `IProc` implementations have a
267
- `.next(x)` method, where `x` is the next input to be processed.
263
+ The second fundamental interface in this package, similar to `IGen` and used to
264
+ implement processors & transformers of input values (e.g those generated by the
265
+ various `IGen`s available). `IProc` implementations have a `.next(x)` method,
266
+ where `x` is the next input to be processed.
268
267
 
269
- The package also provides several approaches to compose multi-step
270
- processing pipelines (see section further below). Furthermore, all
271
- implementations in this package implement the [@thi.ng/transducers
272
- `IXform`
268
+ The package also provides several approaches to compose multi-step processing
269
+ pipelines (see section further below). Furthermore, all implementations in this
270
+ package implement the [@thi.ng/transducers `IXform`
273
271
  interface](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers/README.md#IXform-interface)
274
272
  and so can be directly used in transducer pipelines too.
275
273
 
274
+ Additional higher order `IProc` implementations:
275
+
276
+ - [bounce](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/bounce.ts) - sum multiple inputs
277
+ - [mix](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/mix.ts) - linear interpolation of 2 inputs
278
+ - [multiplex](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/multiplex.ts) - process 1 input into multiple outs
279
+ - [pipe](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/pipe.ts) - `IGen` & multiple `IProc` pipeline setup
280
+ - [serial](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/serial.ts) - serial processing of multiple `IProc`
281
+
276
282
  ```ts
277
283
  import { comp, push, take, transduce } from "@thi.ng/transducers";
278
284
 
@@ -310,7 +316,9 @@ const sig = new Float32Array(
310
316
  fs.writeFileSync("sig.raw", Buffer.from(sig.buffer));
311
317
  ```
312
318
 
313
- The raw audio file can then be converted to WAV via `ffmpeg`:
319
+ Use the [@thi.ng/dsp-io-wav
320
+ package](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp-io-wav/)
321
+ to export as WAV, or alternatively use `ffmpeg` for conversion:
314
322
 
315
323
  ```bash
316
324
  ffmpeg -f f32le -ar 48k -ac 1 -i sig.raw sig.wav -y
@@ -318,8 +326,8 @@ ffmpeg -f f32le -ar 48k -ac 1 -i sig.raw sig.wav -y
318
326
 
319
327
  #### Filters
320
328
 
321
- The following diagrams show various combinations of oscillator signals
322
- and their filtered responses (with different cutoff/center frequencies).
329
+ The following diagrams show various combinations of oscillator signals and their
330
+ filtered responses (with different cutoff/center frequencies).
323
331
 
324
332
  All diagrams were generated with [this
325
333
  script](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/tools/generate-diagrams.ts).
@@ -388,7 +396,7 @@ High shelf (gain = -6dB):
388
396
 
389
397
  ##### State variable filter
390
398
 
391
- [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/biquad.ts)
399
+ [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/svf.ts)
392
400
 
393
401
  - `svfLP` - low pass, resonance
394
402
  - `svfHP` - high pass, resonance
@@ -427,10 +435,10 @@ Allpass:
427
435
 
428
436
  Using the [Filter response
429
437
  utils](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/filter-response.ts),
430
- the following filter types can be evaluated for analyzing their impact
431
- on specific frequencies (or frequency bands). Any type implementing
432
- [`IFilter`](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/api.ts#L50)
433
- can be used, currently:
438
+ the following filter types can be evaluated for analyzing their impact on
439
+ specific frequencies (or frequency bands). Any type implementing
440
+ [`IFilter`](https://docs.thi.ng/umbrella/dsp/interfaces/FilterConfig.html) can
441
+ be used, currently:
434
442
 
435
443
  - 1-pole
436
444
  - DC-block
@@ -471,16 +479,16 @@ Basic filter response plot:
471
479
 
472
480
  [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/delay.ts)
473
481
 
474
- Ringbuffer / delay line for arbitrary values and support for single &
475
- multi-taps at any relative positions. Useful fundamental building block
476
- for various other effects, filters etc.
482
+ Ringbuffer / delay line for arbitrary values and support for single & multi-taps
483
+ at any relative positions. Useful fundamental building block for various other
484
+ effects, filters etc.
477
485
 
478
486
  #### Feedback delay
479
487
 
480
488
  [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/feedback-delay.ts)
481
489
 
482
- Variation of `delay()` which adds a portion of the delayed value to each
483
- new input and stores result in delay line.
490
+ Variation of `delay()` which adds a portion of the delayed value to each new
491
+ input and stores result in delay line.
484
492
 
485
493
  #### Filtered feedback delay
486
494
 
@@ -493,7 +501,8 @@ Variation of `feedbackDelay()` which processes feedback via given filter /
493
501
 
494
502
  [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/waveshaper.ts)
495
503
 
496
- This operator remaps inputs via a user provided function. The following shaping functions are provided:
504
+ This operator remaps inputs via a user provided function. The following shaping
505
+ functions are provided:
497
506
 
498
507
  - `waveshapeTan` - arctan based (soft-clip/distortion)
499
508
  - `waveshapeSigmoid` - sigmoid based, similar to above
@@ -516,9 +525,10 @@ Sine:
516
525
 
517
526
  #### Foldback distortion
518
527
 
519
- [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/waveshaper.ts)
528
+ [Source](https://github.com/thi-ng/umbrella/blob/develop/packages/dsp/src/foldback.ts)
520
529
 
521
- Recursively folds input into `[-thresh .. +thresh]` interval and amplifies it with `amp` (default: 1/thresh).
530
+ Recursively folds input into `[-thresh .. +thresh]` interval and amplifies it
531
+ with `amp` (default: 1/thresh).
522
532
 
523
533
  Use the [interactive calculator @
524
534
  Desmos](https://www.desmos.com/calculator/lkyf2ag3ta) to experiment.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/dsp",
3
- "version": "4.3.17",
3
+ "version": "4.3.20",
4
4
  "description": "Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,16 +34,16 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.9.0",
38
- "@thi.ng/checks": "^3.4.0",
39
- "@thi.ng/errors": "^2.3.0",
40
- "@thi.ng/math": "^5.5.1",
41
- "@thi.ng/random": "^3.5.1",
42
- "@thi.ng/transducers": "^8.5.0"
37
+ "@thi.ng/api": "^8.9.3",
38
+ "@thi.ng/checks": "^3.4.3",
39
+ "@thi.ng/errors": "^2.3.3",
40
+ "@thi.ng/math": "^5.5.4",
41
+ "@thi.ng/random": "^3.6.0",
42
+ "@thi.ng/transducers": "^8.5.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@microsoft/api-extractor": "^7.36.3",
46
- "@thi.ng/testament": "^0.3.18",
45
+ "@microsoft/api-extractor": "^7.36.4",
46
+ "@thi.ng/testament": "^0.3.21",
47
47
  "rimraf": "^5.0.1",
48
48
  "tools": "^0.0.1",
49
49
  "typedoc": "^0.24.8",
@@ -275,5 +275,5 @@
275
275
  ],
276
276
  "year": 2015
277
277
  },
278
- "gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
278
+ "gitHead": "399f8c53d66b9b763d16c21bb59f145df5f59514\n"
279
279
  }