@logue/reverb 1.3.9 → 1.3.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 +3 -3
- package/dist/Reverb.iife.js +2 -2
- package/dist/Reverb.umd.js +2 -2
- package/package.json +22 -22
- package/dist/Reverb.d.ts +0 -144
package/dist/Reverb.es.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.10
|
|
9
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -13,8 +13,8 @@ import { white as c, violet as m, red as f, pink as b, green as N, blue as g } f
|
|
|
13
13
|
import { take as v } from "@thi.ng/transducers";
|
|
14
14
|
import { SYSTEM as w } from "@thi.ng/random";
|
|
15
15
|
const d = {
|
|
16
|
-
version: "1.3.
|
|
17
|
-
date: "2024-
|
|
16
|
+
version: "1.3.10",
|
|
17
|
+
date: "2024-08-10T17:32:59.823Z"
|
|
18
18
|
}, o = {
|
|
19
19
|
/** Blue noise */
|
|
20
20
|
blue: "blue",
|
package/dist/Reverb.iife.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.10
|
|
9
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
var Reverb=function(n,p,u){"use strict";const d={version:"1.3.
|
|
12
|
+
var Reverb=function(n,p,u){"use strict";const d={version:"1.3.10",date:"2024-08-10T17:32:59.823Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},f={noise:"white",scale:1,peaks:2,randomAlgorithm:u.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class s{static version=d.version;static build=d.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=n.white;constructor(e,t){this.ctx=e,this.options=Object.assign(f,t),this.wetGainNode=this.ctx.createGain(),this.dryGainNode=this.ctx.createGain(),this.filterNode=this.ctx.createBiquadFilter(),this.convolverNode=this.ctx.createConvolver(),this.outputNode=this.ctx.createGain(),this.isConnected=!1,this.filterType(this.options.filterType),this.setNoise(this.options.noise),this.buildImpulse(),this.mix(this.options.mix)}connect(e){return this.isConnected&&this.options.once?(this.isConnected=!1,this.outputNode):(this.convolverNode.connect(this.filterNode),this.filterNode.connect(this.wetGainNode),e.connect(this.convolverNode),e.connect(this.dryGainNode).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!s.inRange(e,0,1))throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");this.options.mix=e,this.dryGainNode.gain.value=1-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!s.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of inpulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!s.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!s.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!s.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!s.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case o.blue:this.noise=n.blue;break;case o.green:this.noise=n.green;break;case o.pink:this.noise=n.pink;break;case o.red:case o.brown:this.noise=n.red;break;case o.violet:this.noise=n.violet;break;default:this.noise=n.white}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,r){return(e-t)*(e-r)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),r=e*this.options.delay,h=this.ctx.createBuffer(2,t,e),l=new Float32Array(t),c=new Float32Array(t),m=this.getNoise(t),b=this.getNoise(t);for(let i=0;i<t;i++){let a=0;i<r?(l[i]=0,c[i]=0,a=this.options.reverse??!1?t-(i-r):i-r):a=this.options.reverse??!1?t-i:i,l[i]=(m[i]??0)*(1-a/t)**this.options.decay,c[i]=(b[i]??0)*(1-a/t)**this.options.decay}h.getChannelData(0).set(l),h.getChannelData(1).set(c),this.convolverNode.buffer=h}getNoise(e){return[...p.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}return s}(coloredNoise,transducers,random);
|
package/dist/Reverb.umd.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.3.
|
|
8
|
+
* @version 1.3.10
|
|
9
9
|
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
(function(t,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@thi.ng/colored-noise"),require("@thi.ng/transducers"),require("@thi.ng/random")):typeof define=="function"&&define.amd?define(["@thi.ng/colored-noise","@thi.ng/transducers","@thi.ng/random"],r):(t=typeof globalThis<"u"?globalThis:t||self,t.Reverb=r(t.coloredNoise,t.transducers,t.random))})(this,function(t,r,p){"use strict";const u={version:"1.3.
|
|
12
|
+
(function(t,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@thi.ng/colored-noise"),require("@thi.ng/transducers"),require("@thi.ng/random")):typeof define=="function"&&define.amd?define(["@thi.ng/colored-noise","@thi.ng/transducers","@thi.ng/random"],r):(t=typeof globalThis<"u"?globalThis:t||self,t.Reverb=r(t.coloredNoise,t.transducers,t.random))})(this,function(t,r,p){"use strict";const u={version:"1.3.10",date:"2024-08-10T17:32:59.823Z"},o={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},f={noise:"white",scale:1,peaks:2,randomAlgorithm:p.SYSTEM,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class n{static version=u.version;static build=u.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=t.white;constructor(e,i){this.ctx=e,this.options=Object.assign(f,i),this.wetGainNode=this.ctx.createGain(),this.dryGainNode=this.ctx.createGain(),this.filterNode=this.ctx.createBiquadFilter(),this.convolverNode=this.ctx.createConvolver(),this.outputNode=this.ctx.createGain(),this.isConnected=!1,this.filterType(this.options.filterType),this.setNoise(this.options.noise),this.buildImpulse(),this.mix(this.options.mix)}connect(e){return this.isConnected&&this.options.once?(this.isConnected=!1,this.outputNode):(this.convolverNode.connect(this.filterNode),this.filterNode.connect(this.wetGainNode),e.connect(this.convolverNode),e.connect(this.dryGainNode).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!n.inRange(e,0,1))throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");this.options.mix=e,this.dryGainNode.gain.value=1-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!n.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of inpulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!n.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!n.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!n.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!n.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case o.blue:this.noise=t.blue;break;case o.green:this.noise=t.green;break;case o.pink:this.noise=t.pink;break;case o.red:case o.brown:this.noise=t.red;break;case o.violet:this.noise=t.violet;break;default:this.noise=t.white}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,i,h){return(e-i)*(e-h)<=0}buildImpulse(){const e=this.ctx.sampleRate,i=Math.max(e*this.options.time,1),h=e*this.options.delay,l=this.ctx.createBuffer(2,i,e),d=new Float32Array(i),c=new Float32Array(i),m=this.getNoise(i),b=this.getNoise(i);for(let s=0;s<i;s++){let a=0;s<h?(d[s]=0,c[s]=0,a=this.options.reverse??!1?i-(s-h):s-h):a=this.options.reverse??!1?i-s:s,d[s]=(m[s]??0)*(1-a/i)**this.options.decay,c[s]=(b[s]??0)*(1-a/i)**this.options.decay}l.getChannelData(0).set(d),l.getChannelData(1).set(c),this.convolverNode.buffer=l}getNoise(e){return[...r.take(e,this.noise({bins:this.options.peaks,scale:this.options.scale,rnd:this.options.randomAlgorithm}))]}}return n});
|
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.3.
|
|
4
|
+
"version": "1.3.10",
|
|
5
5
|
"description": "JavaScript Reverb effect class",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webaudio",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=20.1.3",
|
|
44
|
-
"
|
|
44
|
+
"pnpm": ">=9.7.0"
|
|
45
45
|
},
|
|
46
|
-
"packageManager": "
|
|
46
|
+
"packageManager": "pnpm@9.7.0",
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"scripts": {
|
|
49
49
|
"dev": "vite",
|
|
@@ -59,38 +59,38 @@
|
|
|
59
59
|
"prepare": "husky install"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@thi.ng/colored-noise": "^1.0.
|
|
63
|
-
"@thi.ng/transducers": "^9.0.
|
|
62
|
+
"@thi.ng/colored-noise": "^1.0.78",
|
|
63
|
+
"@thi.ng/transducers": "^9.0.13"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@eslint/js": "^9.
|
|
66
|
+
"@eslint/js": "^9.9.0",
|
|
67
67
|
"@tsconfig/node-lts": "^20.1.3",
|
|
68
|
-
"@types/node": "^
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
68
|
+
"@types/node": "^22.2.0",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.0.1",
|
|
70
70
|
"bootstrap": "^5.3.3",
|
|
71
|
-
"eslint": "^9.
|
|
71
|
+
"eslint": "^9.9.0",
|
|
72
72
|
"eslint-config-prettier": "^9.1.0",
|
|
73
73
|
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
74
74
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
75
75
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
76
76
|
"eslint-plugin-html": "^8.1.1",
|
|
77
77
|
"eslint-plugin-import": "^2.29.1",
|
|
78
|
-
"eslint-plugin-n": "^17.2
|
|
79
|
-
"eslint-plugin-promise": "^
|
|
80
|
-
"eslint-plugin-tsdoc": "^0.
|
|
81
|
-
"eslint-plugin-yaml": "^0.
|
|
82
|
-
"husky": "^9.
|
|
83
|
-
"lint-staged": "^15.2.
|
|
78
|
+
"eslint-plugin-n": "^17.10.2",
|
|
79
|
+
"eslint-plugin-promise": "^7.1.0",
|
|
80
|
+
"eslint-plugin-tsdoc": "^0.3.0",
|
|
81
|
+
"eslint-plugin-yaml": "^1.0.3",
|
|
82
|
+
"husky": "^9.1.4",
|
|
83
|
+
"lint-staged": "^15.2.8",
|
|
84
84
|
"npm-run-all": "^4.1.5",
|
|
85
|
-
"prettier": "^3.
|
|
86
|
-
"rimraf": "^
|
|
85
|
+
"prettier": "^3.3.3",
|
|
86
|
+
"rimraf": "^6.0.1",
|
|
87
87
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
88
|
-
"typescript": "^5.4
|
|
89
|
-
"typescript-eslint": "^
|
|
90
|
-
"vite": "^5.
|
|
88
|
+
"typescript": "^5.5.4",
|
|
89
|
+
"typescript-eslint": "^8.0.1",
|
|
90
|
+
"vite": "^5.4.0",
|
|
91
91
|
"vite-plugin-banner": "^0.7.1",
|
|
92
|
-
"vite-plugin-checker": "^0.
|
|
93
|
-
"vite-plugin-dts": "^
|
|
92
|
+
"vite-plugin-checker": "^0.7.2",
|
|
93
|
+
"vite-plugin-dts": "^4.0.2"
|
|
94
94
|
},
|
|
95
95
|
"husky": {
|
|
96
96
|
"hooks": {
|
package/dist/Reverb.d.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { NoiseType } from './NoiseType';
|
|
2
|
-
import { INorm } from '@thi.ng/random';
|
|
3
|
-
import { default as OptionInterface } from './interfaces/OptionInterface';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reverb effect class
|
|
7
|
-
*/
|
|
8
|
-
export default class Reverb {
|
|
9
|
-
/** Version strings */
|
|
10
|
-
static version: string;
|
|
11
|
-
/** Build date */
|
|
12
|
-
static build: string;
|
|
13
|
-
/** AudioContext */
|
|
14
|
-
private readonly ctx;
|
|
15
|
-
/** Wet Level (Reverberated node) */
|
|
16
|
-
private readonly wetGainNode;
|
|
17
|
-
/** Dry Level (Original sound node) */
|
|
18
|
-
private readonly dryGainNode;
|
|
19
|
-
/** Impulse response filter */
|
|
20
|
-
private readonly filterNode;
|
|
21
|
-
/** Convolution node for applying impulse response */
|
|
22
|
-
private readonly convolverNode;
|
|
23
|
-
/** Output gain node */
|
|
24
|
-
private readonly outputNode;
|
|
25
|
-
/** Option */
|
|
26
|
-
private readonly options;
|
|
27
|
-
/** Connected flag */
|
|
28
|
-
private isConnected;
|
|
29
|
-
/** Noise Generator */
|
|
30
|
-
private noise;
|
|
31
|
-
/**
|
|
32
|
-
* Constructor
|
|
33
|
-
*
|
|
34
|
-
* @param ctx - Root AudioContext
|
|
35
|
-
* @param options - Configure
|
|
36
|
-
*/
|
|
37
|
-
constructor(ctx: AudioContext, options: Partial<OptionInterface>);
|
|
38
|
-
/**
|
|
39
|
-
* Connect the node for the reverb effect to the original sound node.
|
|
40
|
-
*
|
|
41
|
-
* @param sourceNode - Input source node
|
|
42
|
-
*/
|
|
43
|
-
connect(sourceNode: AudioNode): AudioNode;
|
|
44
|
-
/**
|
|
45
|
-
* Disconnect the reverb node
|
|
46
|
-
*
|
|
47
|
-
* @param sourceNode - Input source node
|
|
48
|
-
*/
|
|
49
|
-
disconnect(sourceNode?: AudioNode): AudioNode | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Dry/Wet ratio
|
|
52
|
-
*
|
|
53
|
-
* @param mix - Ratio (0~1)
|
|
54
|
-
*/
|
|
55
|
-
mix(mix: number): void;
|
|
56
|
-
/**
|
|
57
|
-
* Set Impulse Response time length (second)
|
|
58
|
-
*
|
|
59
|
-
* @param value - IR length
|
|
60
|
-
*/
|
|
61
|
-
time(value: number): void;
|
|
62
|
-
/**
|
|
63
|
-
* Impulse response decay rate.
|
|
64
|
-
*
|
|
65
|
-
* @param value - Decay value
|
|
66
|
-
*/
|
|
67
|
-
decay(value: number): void;
|
|
68
|
-
/**
|
|
69
|
-
* Delay before reverberation starts
|
|
70
|
-
*
|
|
71
|
-
* @param value - Time[ms]
|
|
72
|
-
*/
|
|
73
|
-
delay(value: number): void;
|
|
74
|
-
/**
|
|
75
|
-
* Reverse the impulse response.
|
|
76
|
-
*
|
|
77
|
-
* @param reverse - Reverse IR
|
|
78
|
-
*/
|
|
79
|
-
reverse(reverse: boolean): void;
|
|
80
|
-
/**
|
|
81
|
-
* Filter for impulse response
|
|
82
|
-
*
|
|
83
|
-
* @param type - Filiter Type
|
|
84
|
-
*/
|
|
85
|
-
filterType(type?: BiquadFilterType): void;
|
|
86
|
-
/**
|
|
87
|
-
* Filter frequency applied to impulse response
|
|
88
|
-
*
|
|
89
|
-
* @param freq - Frequency
|
|
90
|
-
*/
|
|
91
|
-
filterFreq(freq: number): void;
|
|
92
|
-
/**
|
|
93
|
-
* Filter quality.
|
|
94
|
-
*
|
|
95
|
-
* @param q - Quality
|
|
96
|
-
*/
|
|
97
|
-
filterQ(q: number): void;
|
|
98
|
-
/**
|
|
99
|
-
* set IR source noise peaks
|
|
100
|
-
*
|
|
101
|
-
* @param p - Peaks
|
|
102
|
-
*/
|
|
103
|
-
peaks(p: number): void;
|
|
104
|
-
/**
|
|
105
|
-
* set IR source noise scale.
|
|
106
|
-
*
|
|
107
|
-
* @param s - Scale
|
|
108
|
-
*/
|
|
109
|
-
scale(s: number): void;
|
|
110
|
-
/**
|
|
111
|
-
* set IR source noise generator.
|
|
112
|
-
*
|
|
113
|
-
* @param a - Algorithm
|
|
114
|
-
*/
|
|
115
|
-
randomAlgorithm(a: INorm): void;
|
|
116
|
-
/**
|
|
117
|
-
* Inpulse Response Noise algorithm.
|
|
118
|
-
*
|
|
119
|
-
* @param type - IR noise algorithm type.
|
|
120
|
-
*/
|
|
121
|
-
setNoise(type: NoiseType): void;
|
|
122
|
-
/**
|
|
123
|
-
* Set Random Algorythm
|
|
124
|
-
*
|
|
125
|
-
* @param algorithm - Algorythm
|
|
126
|
-
*/
|
|
127
|
-
setRandomAlgorythm(algorithm: INorm): void;
|
|
128
|
-
/**
|
|
129
|
-
* Return true if in range, otherwise false
|
|
130
|
-
*
|
|
131
|
-
* @param x - Target value
|
|
132
|
-
* @param min - Minimum value
|
|
133
|
-
* @param max - Maximum value
|
|
134
|
-
*/
|
|
135
|
-
private static inRange;
|
|
136
|
-
/** Utility function for building an impulse response from the module parameters. */
|
|
137
|
-
private buildImpulse;
|
|
138
|
-
/**
|
|
139
|
-
* Noise source
|
|
140
|
-
*
|
|
141
|
-
* @param duration - length of IR.
|
|
142
|
-
*/
|
|
143
|
-
private getNoise;
|
|
144
|
-
}
|