@logue/reverb 0.5.3 → 0.5.4
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.d.ts +0 -5
- package/dist/Reverb.d.ts.map +1 -1
- package/dist/reverb.es.js +13 -18
- package/dist/reverb.umd.js +11 -9
- package/package.json +35 -34
package/dist/Reverb.d.ts
CHANGED
|
@@ -2,11 +2,6 @@ import type OptionInterface from './interfaces/OptionInterface';
|
|
|
2
2
|
import { type NoiseType } from './NoiseType';
|
|
3
3
|
/**
|
|
4
4
|
* JS reverb effect class
|
|
5
|
-
*
|
|
6
|
-
* @license MIT
|
|
7
|
-
* @author Logue {@link logue@hotmail.co.jp}
|
|
8
|
-
* @copyright 2019-2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
9
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
5
|
*/
|
|
11
6
|
export default class Reverb {
|
|
12
7
|
/** Version strings */
|
package/dist/Reverb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"Reverb.d.ts","sourceRoot":"","sources":["../src/Reverb.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAC;AAChE,OAAc,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC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OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;IAoGpB,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAC,UAAU;CAI1B"}
|
package/dist/reverb.es.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @logue/reverb
|
|
3
|
+
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 0.5.4
|
|
9
|
+
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
+
*/
|
|
11
|
+
|
|
1
12
|
const meta = {
|
|
2
|
-
version: "0.5.
|
|
3
|
-
date: "2022-
|
|
13
|
+
version: "0.5.4",
|
|
14
|
+
date: "2022-07-08T12:56:05.192Z"
|
|
4
15
|
};
|
|
5
16
|
const Noise = {
|
|
6
17
|
WHITE: "white",
|
|
7
18
|
PINK: "pink",
|
|
8
19
|
BROWN: "brown"
|
|
9
20
|
};
|
|
10
|
-
/**
|
|
11
|
-
* JS reverb effect class
|
|
12
|
-
*
|
|
13
|
-
* @license MIT
|
|
14
|
-
* @author Logue {@link logue@hotmail.co.jp}
|
|
15
|
-
* @copyright 2019-2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
16
|
-
* @see {@link https://github.com/logue/Reverb.js}
|
|
17
|
-
*/
|
|
18
21
|
class Reverb {
|
|
19
22
|
constructor(ctx, options) {
|
|
20
23
|
this.version = meta.version;
|
|
@@ -58,7 +61,6 @@ class Reverb {
|
|
|
58
61
|
this._options.mix = mix;
|
|
59
62
|
this.dryGainNode.gain.value = 1 - this._options.mix;
|
|
60
63
|
this.wetGainNode.gain.value = this._options.mix;
|
|
61
|
-
console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);
|
|
62
64
|
}
|
|
63
65
|
time(value) {
|
|
64
66
|
if (!this.inRange(value, 1, 50)) {
|
|
@@ -66,7 +68,6 @@ class Reverb {
|
|
|
66
68
|
}
|
|
67
69
|
this._options.time = value;
|
|
68
70
|
this.buildImpulse();
|
|
69
|
-
console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);
|
|
70
71
|
}
|
|
71
72
|
decay(value) {
|
|
72
73
|
if (!this.inRange(value, 0, 100)) {
|
|
@@ -74,7 +75,6 @@ class Reverb {
|
|
|
74
75
|
}
|
|
75
76
|
this._options.decay = value;
|
|
76
77
|
this.buildImpulse();
|
|
77
|
-
console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);
|
|
78
78
|
}
|
|
79
79
|
delay(value) {
|
|
80
80
|
if (!this.inRange(value, 0, 100)) {
|
|
@@ -82,16 +82,13 @@ class Reverb {
|
|
|
82
82
|
}
|
|
83
83
|
this._options.delay = value;
|
|
84
84
|
this.buildImpulse();
|
|
85
|
-
console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);
|
|
86
85
|
}
|
|
87
86
|
reverse(reverse) {
|
|
88
87
|
this._options.reverse = reverse;
|
|
89
88
|
this.buildImpulse();
|
|
90
|
-
console.debug(`Reverb.js: Inpulse response is ${reverse ? "" : "not "}reversed.`);
|
|
91
89
|
}
|
|
92
90
|
filterType(type) {
|
|
93
91
|
this.filterNode.type = this._options.filterType = type;
|
|
94
|
-
console.debug(`Set filter type to ${type}`);
|
|
95
92
|
}
|
|
96
93
|
filterFreq(freq) {
|
|
97
94
|
if (!this.inRange(freq, 20, 5e3)) {
|
|
@@ -99,7 +96,6 @@ class Reverb {
|
|
|
99
96
|
}
|
|
100
97
|
this._options.filterFreq = freq;
|
|
101
98
|
this.filterNode.frequency.value = this._options.filterFreq;
|
|
102
|
-
console.debug(`Set filter frequency to ${freq}Hz.`);
|
|
103
99
|
}
|
|
104
100
|
filterQ(q) {
|
|
105
101
|
if (!this.inRange(q, 0, 10)) {
|
|
@@ -112,7 +108,6 @@ class Reverb {
|
|
|
112
108
|
setNoise(type) {
|
|
113
109
|
this._options.noise = type;
|
|
114
110
|
this.buildImpulse();
|
|
115
|
-
console.debug(`Set Noise type to ${type}.`);
|
|
116
111
|
}
|
|
117
112
|
inRange(x, min, max) {
|
|
118
113
|
return (x - min) * (x - max) <= 0;
|
package/dist/reverb.umd.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Reverb=t()}(this,(function(){"use strict";const e="0.5.3",t="2022-06-05T00:53:37.175Z",i="white",s="pink",o="brown";
|
|
2
1
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
* @logue/reverb
|
|
3
|
+
*
|
|
4
|
+
* @description JavaScript Reverb effect class
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2019-2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 0.5.4
|
|
9
|
+
* @see {@link https://github.com/logue/Reverb.js}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Reverb=t()}(this,(function(){"use strict";const e="0.5.4",t="2022-07-08T12:56:05.192Z",i="white",s="pink",o="brown";class n{constructor(i,s){this.version=e,this.build=t,this.ctx=i,this._options={...r,...s},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.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(!this.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(!this.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(!this.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(!this.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){this.filterNode.type=this._options.filterType=e}filterFreq(e){if(!this.inRange(e,20,5e3))throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");this._options.filterFreq=e,this.filterNode.frequency.value=this._options.filterFreq}filterQ(e){if(!this.inRange(e,0,10))throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");this._options.filterQ=e,this.filterNode.Q.value=this._options.filterQ}setNoise(e){this._options.noise=e,this.buildImpulse()}inRange(e,t,i){return(e-t)*(e-i)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this._options.time,1),i=e*this._options.delay,r=this.ctx.createBuffer(2,t,e),h=new Float32Array(t),a=new Float32Array(t),l=[0,0,0,0,0,0,0];for(let c=0;c<t;c++){let e=0;switch(c<i?(h[c]=0,a[c]=0,e=this._options.reverse?t-(c-i):c-i):e=this._options.reverse?t-c:c,this._options.noise){case s:l[0]=.99886*l[0]+.0555179*n.whiteNoise(),l[1]=.99332*l[1]+.0750759*n.whiteNoise(),l[2]=.969*l[2]+.153852*n.whiteNoise(),l[3]=.8665*l[3]+.3104856*n.whiteNoise(),l[4]=.55*l[4]+.5329522*n.whiteNoise(),l[5]=-.7616*l[5]-.016898*n.whiteNoise(),h[c]=l[0]+l[1]+l[2]+l[3]+l[4]+l[5]+l[6]+.5362*n.whiteNoise(),a[c]=l[0]+l[1]+l[2]+l[3]+l[4]+l[5]+l[6]+.5362*n.whiteNoise(),h[c]*=.11,a[c]*=.11,l[6]=.115926*n.whiteNoise();break;case o:h[c]=(l[0]+.02*n.whiteNoise())/1.02,l[0]=h[c],a[c]=(l[1]+.02*n.whiteNoise())/1.02,l[1]=a[c],h[c]*=3.5,a[c]*=3.5;break;default:h[c]=n.whiteNoise(),a[c]=n.whiteNoise()}h[c]*=(1-e/t)**this._options.decay,a[c]*=(1-e/t)**this._options.decay}r.getChannelData(0).set(h),r.getChannelData(1).set(a),this.convolverNode.buffer=r}static whiteNoise(){return 2*Math.random()-1}}const r={noise:i,decay:2,delay:0,reverse:!1,time:2,filterType:"lowpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};return n}));
|
package/package.json
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@logue/reverb",
|
|
4
|
-
"version": "0.5.
|
|
5
|
-
"description": "Reverb effect
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"main": "./dist/reverb.umd.js",
|
|
10
|
-
"module": "./dist/reverb.es.js",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/reverb.es.js",
|
|
14
|
-
"require": "./dist/reverb.umd.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"types": "./dist/Reverb.d.ts",
|
|
18
|
-
"directories": {
|
|
19
|
-
"doc": "docs"
|
|
20
|
-
},
|
|
4
|
+
"version": "0.5.4",
|
|
5
|
+
"description": "JavaScript Reverb effect class",
|
|
21
6
|
"keywords": [
|
|
22
7
|
"webaudio",
|
|
23
8
|
"convolver",
|
|
24
9
|
"effect",
|
|
25
10
|
"reverb"
|
|
26
11
|
],
|
|
12
|
+
"license": "MIT",
|
|
27
13
|
"author": {
|
|
28
14
|
"name": "Logue",
|
|
29
15
|
"email": "logue@hotmail.co.jp",
|
|
@@ -37,12 +23,26 @@
|
|
|
37
23
|
"bugs": {
|
|
38
24
|
"url": "https://github.com/logue/Reverb.js/issues"
|
|
39
25
|
},
|
|
26
|
+
"directories": {
|
|
27
|
+
"doc": "docs"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"main": "./dist/reverb.umd.js",
|
|
33
|
+
"module": "./dist/reverb.es.js",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": "./dist/reverb.es.js",
|
|
37
|
+
"require": "./dist/reverb.umd.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"types": "./dist/Reverb.d.ts",
|
|
40
41
|
"engines": {
|
|
41
|
-
"node": ">=16.
|
|
42
|
+
"node": ">=16.16.0",
|
|
42
43
|
"yarn": ">=1.22.4"
|
|
43
44
|
},
|
|
44
45
|
"packageManager": "yarn@3.2.1",
|
|
45
|
-
"license": "MIT",
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"scripts": {
|
|
48
48
|
"dev": "vite",
|
|
@@ -52,28 +52,26 @@
|
|
|
52
52
|
"prepare": "husky install"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"@typescript-eslint/parser": "^5.27.0",
|
|
60
|
-
"eslint": "^8.17.0",
|
|
55
|
+
"@types/node": "^18.0.3",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
57
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
58
|
+
"eslint": "^8.19.0",
|
|
61
59
|
"eslint-config-google": "^0.14.0",
|
|
62
60
|
"eslint-config-prettier": "^8.5.0",
|
|
63
61
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
64
|
-
"eslint-import-resolver-typescript": "^2.
|
|
62
|
+
"eslint-import-resolver-typescript": "^3.2.4",
|
|
65
63
|
"eslint-plugin-import": "^2.26.0",
|
|
66
|
-
"eslint-plugin-jsdoc": "^39.3.
|
|
67
|
-
"eslint-plugin-prettier": "^4.
|
|
64
|
+
"eslint-plugin-jsdoc": "^39.3.3",
|
|
65
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
68
66
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
69
67
|
"husky": "^8.0.1",
|
|
70
|
-
"lint-staged": "^13.0.
|
|
71
|
-
"
|
|
72
|
-
"prettier": "^2.6.2",
|
|
68
|
+
"lint-staged": "^13.0.3",
|
|
69
|
+
"prettier": "^2.7.1",
|
|
73
70
|
"rimraf": "^3.0.2",
|
|
74
|
-
"typescript": "^4.7.
|
|
75
|
-
"vite": "^2.9.
|
|
76
|
-
"vite-plugin-
|
|
71
|
+
"typescript": "^4.7.4",
|
|
72
|
+
"vite": "^2.9.14",
|
|
73
|
+
"vite-plugin-banner": "^0.3.0",
|
|
74
|
+
"vite-plugin-checker": "^0.4.8"
|
|
77
75
|
},
|
|
78
76
|
"husky": {
|
|
79
77
|
"hooks": {
|
|
@@ -83,5 +81,8 @@
|
|
|
83
81
|
"lint-staged": {
|
|
84
82
|
"*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
85
83
|
"*": "prettier -w -u"
|
|
84
|
+
},
|
|
85
|
+
"resolutions": {
|
|
86
|
+
"prettier": "^2.7.1"
|
|
86
87
|
}
|
|
87
88
|
}
|