@logue/reverb 1.2.7 → 1.2.10

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/dist/Reverb.es.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2023 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.2.7
8
+ * @version 1.2.10
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
@@ -30,25 +30,25 @@ const defaults = {
30
30
  };
31
31
 
32
32
  const meta = {
33
- version: "1.2.7",
34
- date: "2023-03-10T12:40:23.409Z"
33
+ version: "1.2.10",
34
+ date: "2023-04-03T23:44:29.225Z"
35
35
  };
36
36
 
37
37
  const Noise = {
38
38
  /** Blue noise */
39
- BLUE: "blue",
39
+ blue: "blue",
40
40
  /** Green noise */
41
- GREEN: "green",
41
+ green: "green",
42
42
  /** Pink noise */
43
- PINK: "pink",
43
+ pink: "pink",
44
44
  /** Red noise */
45
- RED: "red",
45
+ brown: "red",
46
46
  /** Violet noise */
47
- VIOLET: "violet",
47
+ violet: "violet",
48
48
  /** White noise */
49
- WHITE: "white",
49
+ white: "white",
50
50
  /** Brown noise (same as red noise) */
51
- BROWN: "red"
51
+ red: "red"
52
52
  };
53
53
 
54
54
  class Reverb {
@@ -80,9 +80,9 @@ class Reverb {
80
80
  * @param ctx - Root AudioContext
81
81
  * @param options - Configure
82
82
  */
83
- constructor(ctx, options) {
83
+ constructor(ctx, options = {}) {
84
84
  this.ctx = ctx;
85
- this.options = { ...defaults, ...options };
85
+ this.options = Object.assign(defaults, options);
86
86
  this.wetGainNode = this.ctx.createGain();
87
87
  this.dryGainNode = this.ctx.createGain();
88
88
  this.filterNode = this.ctx.createBiquadFilter();
@@ -260,20 +260,20 @@ class Reverb {
260
260
  setNoise(type) {
261
261
  this.options.noise = type;
262
262
  switch (type) {
263
- case Noise["BLUE"]:
263
+ case Noise.blue:
264
264
  this.noise = blue;
265
265
  break;
266
- case Noise["GREEN"]:
266
+ case Noise.green:
267
267
  this.noise = green;
268
268
  break;
269
- case Noise["PINK"]:
269
+ case Noise.pink:
270
270
  this.noise = pink;
271
271
  break;
272
- case Noise["RED"]:
273
- case Noise["BROWN"]:
272
+ case Noise.red:
273
+ case Noise.brown:
274
274
  this.noise = red;
275
275
  break;
276
- case Noise["VIOLET"]:
276
+ case Noise.violet:
277
277
  this.noise = violet;
278
278
  break;
279
279
  default:
@@ -319,8 +319,8 @@ class Reverb {
319
319
  } else {
320
320
  n = this.options.reverse ? duration - i : i;
321
321
  }
322
- impulseL[i] = noiseL[i] * (1 - n / duration) ** this.options.decay;
323
- impulseR[i] = noiseR[i] * (1 - n / duration) ** this.options.decay;
322
+ impulseL[i] = (noiseL[i] ?? 0) * (1 - n / duration) ** this.options.decay;
323
+ impulseR[i] = (noiseR[i] ?? 0) * (1 - n / duration) ** this.options.decay;
324
324
  }
325
325
  impulse.getChannelData(0).set(impulseL);
326
326
  impulse.getChannelData(1).set(impulseR);
@@ -335,11 +335,11 @@ class Reverb {
335
335
  return [
336
336
  ...take(
337
337
  duration,
338
- this.noise(
339
- this.options.peaks,
340
- this.options.scale,
341
- this.options.randomAlgorithm
342
- )
338
+ this.noise({
339
+ bins: this.options.peaks,
340
+ scale: this.options.scale,
341
+ rnd: this.options.randomAlgorithm
342
+ })
343
343
  )
344
344
  ];
345
345
  }
@@ -5,7 +5,7 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2023 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.2.7
8
+ * @version 1.2.10
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
@@ -29,25 +29,25 @@ var Reverb = (function (random, coloredNoise, transducers) {
29
29
  };
30
30
 
31
31
  const meta = {
32
- version: "1.2.7",
33
- date: "2023-03-10T12:40:23.409Z"
32
+ version: "1.2.10",
33
+ date: "2023-04-03T23:44:29.225Z"
34
34
  };
35
35
 
36
36
  const Noise = {
37
37
  /** Blue noise */
38
- BLUE: "blue",
38
+ blue: "blue",
39
39
  /** Green noise */
40
- GREEN: "green",
40
+ green: "green",
41
41
  /** Pink noise */
42
- PINK: "pink",
42
+ pink: "pink",
43
43
  /** Red noise */
44
- RED: "red",
44
+ brown: "red",
45
45
  /** Violet noise */
46
- VIOLET: "violet",
46
+ violet: "violet",
47
47
  /** White noise */
48
- WHITE: "white",
48
+ white: "white",
49
49
  /** Brown noise (same as red noise) */
50
- BROWN: "red"
50
+ red: "red"
51
51
  };
52
52
 
53
53
  class Reverb {
@@ -79,9 +79,9 @@ var Reverb = (function (random, coloredNoise, transducers) {
79
79
  * @param ctx - Root AudioContext
80
80
  * @param options - Configure
81
81
  */
82
- constructor(ctx, options) {
82
+ constructor(ctx, options = {}) {
83
83
  this.ctx = ctx;
84
- this.options = { ...defaults, ...options };
84
+ this.options = Object.assign(defaults, options);
85
85
  this.wetGainNode = this.ctx.createGain();
86
86
  this.dryGainNode = this.ctx.createGain();
87
87
  this.filterNode = this.ctx.createBiquadFilter();
@@ -259,20 +259,20 @@ var Reverb = (function (random, coloredNoise, transducers) {
259
259
  setNoise(type) {
260
260
  this.options.noise = type;
261
261
  switch (type) {
262
- case Noise["BLUE"]:
262
+ case Noise.blue:
263
263
  this.noise = coloredNoise.blue;
264
264
  break;
265
- case Noise["GREEN"]:
265
+ case Noise.green:
266
266
  this.noise = coloredNoise.green;
267
267
  break;
268
- case Noise["PINK"]:
268
+ case Noise.pink:
269
269
  this.noise = coloredNoise.pink;
270
270
  break;
271
- case Noise["RED"]:
272
- case Noise["BROWN"]:
271
+ case Noise.red:
272
+ case Noise.brown:
273
273
  this.noise = coloredNoise.red;
274
274
  break;
275
- case Noise["VIOLET"]:
275
+ case Noise.violet:
276
276
  this.noise = coloredNoise.violet;
277
277
  break;
278
278
  default:
@@ -318,8 +318,8 @@ var Reverb = (function (random, coloredNoise, transducers) {
318
318
  } else {
319
319
  n = this.options.reverse ? duration - i : i;
320
320
  }
321
- impulseL[i] = noiseL[i] * (1 - n / duration) ** this.options.decay;
322
- impulseR[i] = noiseR[i] * (1 - n / duration) ** this.options.decay;
321
+ impulseL[i] = (noiseL[i] ?? 0) * (1 - n / duration) ** this.options.decay;
322
+ impulseR[i] = (noiseR[i] ?? 0) * (1 - n / duration) ** this.options.decay;
323
323
  }
324
324
  impulse.getChannelData(0).set(impulseL);
325
325
  impulse.getChannelData(1).set(impulseR);
@@ -334,11 +334,11 @@ var Reverb = (function (random, coloredNoise, transducers) {
334
334
  return [
335
335
  ...transducers.take(
336
336
  duration,
337
- this.noise(
338
- this.options.peaks,
339
- this.options.scale,
340
- this.options.randomAlgorithm
341
- )
337
+ this.noise({
338
+ bins: this.options.peaks,
339
+ scale: this.options.scale,
340
+ rnd: this.options.randomAlgorithm
341
+ })
342
342
  )
343
343
  ];
344
344
  }
@@ -5,7 +5,7 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2019-2023 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.2.7
8
+ * @version 1.2.10
9
9
  * @see {@link https://github.com/logue/Reverb.js}
10
10
  */
11
11
 
@@ -32,25 +32,25 @@
32
32
  };
33
33
 
34
34
  const meta = {
35
- version: "1.2.7",
36
- date: "2023-03-10T12:40:23.409Z"
35
+ version: "1.2.10",
36
+ date: "2023-04-03T23:44:29.225Z"
37
37
  };
38
38
 
39
39
  const Noise = {
40
40
  /** Blue noise */
41
- BLUE: "blue",
41
+ blue: "blue",
42
42
  /** Green noise */
43
- GREEN: "green",
43
+ green: "green",
44
44
  /** Pink noise */
45
- PINK: "pink",
45
+ pink: "pink",
46
46
  /** Red noise */
47
- RED: "red",
47
+ brown: "red",
48
48
  /** Violet noise */
49
- VIOLET: "violet",
49
+ violet: "violet",
50
50
  /** White noise */
51
- WHITE: "white",
51
+ white: "white",
52
52
  /** Brown noise (same as red noise) */
53
- BROWN: "red"
53
+ red: "red"
54
54
  };
55
55
 
56
56
  class Reverb {
@@ -82,9 +82,9 @@
82
82
  * @param ctx - Root AudioContext
83
83
  * @param options - Configure
84
84
  */
85
- constructor(ctx, options) {
85
+ constructor(ctx, options = {}) {
86
86
  this.ctx = ctx;
87
- this.options = { ...defaults, ...options };
87
+ this.options = Object.assign(defaults, options);
88
88
  this.wetGainNode = this.ctx.createGain();
89
89
  this.dryGainNode = this.ctx.createGain();
90
90
  this.filterNode = this.ctx.createBiquadFilter();
@@ -262,20 +262,20 @@
262
262
  setNoise(type) {
263
263
  this.options.noise = type;
264
264
  switch (type) {
265
- case Noise["BLUE"]:
265
+ case Noise.blue:
266
266
  this.noise = coloredNoise.blue;
267
267
  break;
268
- case Noise["GREEN"]:
268
+ case Noise.green:
269
269
  this.noise = coloredNoise.green;
270
270
  break;
271
- case Noise["PINK"]:
271
+ case Noise.pink:
272
272
  this.noise = coloredNoise.pink;
273
273
  break;
274
- case Noise["RED"]:
275
- case Noise["BROWN"]:
274
+ case Noise.red:
275
+ case Noise.brown:
276
276
  this.noise = coloredNoise.red;
277
277
  break;
278
- case Noise["VIOLET"]:
278
+ case Noise.violet:
279
279
  this.noise = coloredNoise.violet;
280
280
  break;
281
281
  default:
@@ -321,8 +321,8 @@
321
321
  } else {
322
322
  n = this.options.reverse ? duration - i : i;
323
323
  }
324
- impulseL[i] = noiseL[i] * (1 - n / duration) ** this.options.decay;
325
- impulseR[i] = noiseR[i] * (1 - n / duration) ** this.options.decay;
324
+ impulseL[i] = (noiseL[i] ?? 0) * (1 - n / duration) ** this.options.decay;
325
+ impulseR[i] = (noiseR[i] ?? 0) * (1 - n / duration) ** this.options.decay;
326
326
  }
327
327
  impulse.getChannelData(0).set(impulseL);
328
328
  impulse.getChannelData(1).set(impulseR);
@@ -337,11 +337,11 @@
337
337
  return [
338
338
  ...transducers.take(
339
339
  duration,
340
- this.noise(
341
- this.options.peaks,
342
- this.options.scale,
343
- this.options.randomAlgorithm
344
- )
340
+ this.noise({
341
+ bins: this.options.peaks,
342
+ scale: this.options.scale,
343
+ rnd: this.options.randomAlgorithm
344
+ })
345
345
  )
346
346
  ];
347
347
  }
@@ -1,6 +1,6 @@
1
1
  /** Impulse response noise generation algorithm */
2
- declare const Noise: Record<string, string>;
2
+ declare const Noise: Record<NoiseType, string>;
3
3
  /** Noise Type */
4
- export type NoiseType = (typeof Noise)[keyof typeof Noise];
4
+ export type NoiseType = 'blue' | 'green' | 'pink' | 'red' | 'violet' | 'white' | 'brown';
5
5
  /** Noise */
6
6
  export default Noise;
@@ -1,39 +1,53 @@
1
- import type { NoiseType } from '../NoiseType';
2
1
  import type { INorm } from '@thi.ng/random';
2
+ import type { NoiseType } from '../NoiseType';
3
3
  /** Reverb Option */
4
4
  export default interface OptionInterface {
5
5
  /**
6
6
  * IR (Inpulse Response) colord noise algorithm (BLUE, GREEN, PINK, RED, VIOLET, WHITE)
7
7
  * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/colored-noise}
8
8
  */
9
- noise: NoiseType;
9
+ noise?: NoiseType;
10
10
  /** IR source noise scale */
11
- scale: number;
11
+ scale?: number;
12
12
  /** Number of IR source noise peaks */
13
- peaks: number;
13
+ peaks?: number;
14
14
  /**
15
15
  * Randam noise algorythm
16
16
  * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/random}
17
17
  */
18
- randomAlgorithm: INorm;
18
+ randomAlgorithm?: INorm;
19
19
  /** Decay */
20
- decay: number;
20
+ decay?: number;
21
21
  /** Delay until impulse response is generated */
22
- delay: number;
22
+ delay?: number;
23
23
  /** Filter frequency applied to impulse response[Hz] */
24
- filterFreq: number;
24
+ filterFreq?: number;
25
25
  /** Filter quality for impulse response */
26
- filterQ: number;
26
+ filterQ?: number;
27
27
  /** Filter type for impulse response */
28
- filterType: BiquadFilterType;
28
+ filterType?: BiquadFilterType;
29
29
  /** Dry/Wet ratio */
30
- mix: number;
30
+ mix?: number;
31
31
  /** Invert the impulse response */
32
- reverse: boolean;
32
+ reverse?: boolean;
33
33
  /** Impulse response length */
34
- time: number;
34
+ time?: number;
35
35
  /** Prevents multiple effectors from being connected. */
36
- once: boolean;
36
+ once?: boolean;
37
37
  }
38
38
  /** デフォルト値 */
39
- export declare const defaults: OptionInterface;
39
+ export declare const defaults: {
40
+ noise: NoiseType;
41
+ scale: number;
42
+ peaks: number;
43
+ randomAlgorithm: INorm;
44
+ decay: number;
45
+ delay: number;
46
+ filterFreq: number;
47
+ filterQ: number;
48
+ filterType: BiquadFilterType;
49
+ mix: number;
50
+ reverse: boolean;
51
+ time: number;
52
+ once: boolean;
53
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@logue/reverb",
4
- "version": "1.2.7",
4
+ "version": "1.2.10",
5
5
  "description": "JavaScript Reverb effect class",
6
6
  "keywords": [
7
7
  "webaudio",
@@ -41,48 +41,51 @@
41
41
  "node": ">=18.15.0",
42
42
  "yarn": ">=1.22.19"
43
43
  },
44
- "packageManager": "yarn@3.4.1",
44
+ "packageManager": "yarn@3.5.0",
45
45
  "sideEffects": false,
46
46
  "scripts": {
47
47
  "dev": "vite",
48
48
  "clean": "rimraf node_modules/.vite",
49
49
  "type-check": "tsc --noEmit --composite false",
50
50
  "build": "run-p type-check build-only",
51
+ "build:docs": "vite build --mode=docs",
51
52
  "build:analyze": "vite build --mode=analyze",
52
53
  "build:clean": "rimraf dist",
53
54
  "build-only": "vite build",
54
55
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
56
+ "preview": "vite preview --mode=docs",
55
57
  "prepare": "husky install"
56
58
  },
57
59
  "dependencies": {
58
- "@thi.ng/colored-noise": "^1.0.11",
59
- "@thi.ng/transducers": "^8.3.37"
60
+ "@thi.ng/colored-noise": "^1.0.13",
61
+ "@thi.ng/transducers": "^8.4.1"
60
62
  },
61
63
  "devDependencies": {
62
64
  "@tsconfig/node18-strictest-esm": "^1.0.1",
63
- "@types/node": "^18.15.0",
64
- "@typescript-eslint/eslint-plugin": "^5.54.1",
65
- "@typescript-eslint/parser": "^5.54.1",
66
- "eslint": "^8.35.0",
67
- "eslint-config-google": "^0.14.0",
68
- "eslint-config-prettier": "^8.7.0",
65
+ "@types/node": "^18.15.11",
66
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
67
+ "eslint": "^8.37.0",
68
+ "eslint-config-prettier": "^8.8.0",
69
+ "eslint-config-standard-with-typescript": "^34.0.1",
69
70
  "eslint-import-resolver-alias": "^1.1.2",
70
- "eslint-import-resolver-typescript": "^3.5.3",
71
+ "eslint-import-resolver-typescript": "^3.5.4",
72
+ "eslint-plugin-html": "^7.1.0",
71
73
  "eslint-plugin-import": "^2.27.5",
72
- "eslint-plugin-jsdoc": "^40.0.1",
73
- "eslint-plugin-prettier": "^4.2.1",
74
+ "eslint-plugin-n": "^15.7.0",
75
+ "eslint-plugin-promise": "^6.1.1",
74
76
  "eslint-plugin-tsdoc": "^0.2.17",
77
+ "eslint-plugin-yaml": "^0.5.0",
75
78
  "husky": "^8.0.3",
76
79
  "lint-staged": "^13.2.0",
77
80
  "npm-run-all": "^4.1.5",
78
- "prettier": "^2.8.4",
79
- "rimraf": "^4.4.0",
81
+ "prettier": "^2.8.7",
82
+ "rimraf": "^4.4.1",
80
83
  "rollup-plugin-visualizer": "^5.9.0",
81
- "typescript": "^4.9.5",
82
- "vite": "^4.1.4",
84
+ "typescript": "*",
85
+ "vite": "^4.2.1",
83
86
  "vite-plugin-banner": "^0.7.0",
84
87
  "vite-plugin-checker": "^0.5.6",
85
- "vite-plugin-dts": "^2.1.0"
88
+ "vite-plugin-dts": "^2.2.0"
86
89
  },
87
90
  "husky": {
88
91
  "hooks": {