@logue/reverb 0.4.2 → 0.5.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/README.md CHANGED
@@ -1,72 +1,93 @@
1
- # Reverb.js
1
+ # vue-codemirror6
2
2
 
3
- [![npm version](https://badge.fury.io/js/%40logue%2Freverb.svg)](https://badge.fury.io/js/%40logue%2Freverb)
4
- [![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)
5
-
6
- Append reverb effect to audio source.
7
-
8
- This script is originally a spin out of [sf2synth.js](https://github.com/logue/smfplayer.js)'s reverb effect.
9
-
10
-
11
- ## Sample
12
-
13
- * <https://logue.github.io/Reverb.js/>
14
- * <https://logue.github.io/Reverb.js/localaudio.html>
15
-
16
- ## Syntax
17
-
18
- ```js
19
- const reverb = new Reverb.default(ctx, {
20
- noise: 0, // Inpulse Response Noise algorithm (0: White noise, 1: Pink noise, 2: Brown noise)
21
- decay: 5, // Amount of IR (Inpulse Response) decay. 0~100
22
- delay: 0, // Delay time o IR. (NOT delay effect) 0~100 [sec]
23
- filterFreq: 2200, // Filter frequency. 20~5000 [Hz]
24
- filterQ: 1, // Filter quality. 0~10
25
- filterType: 'lowpass', // Filter type. 'bandpass' etc. See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type .
26
- mix: 0.5, // Dry (Original Sound) and Wet (Effected sound) raito. 0~1
27
- reverse: false, // Reverse IR.
28
- time: 3 // Time length of IR. 0~50 [sec]
29
- });
30
- ```
3
+ A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unlike [surmon-china's vue-codemirror](https://github.com/surmon-china/vue-codemirror), it is for CodeMirror6.
31
4
 
32
5
  ## Usage
33
6
 
34
- ```js
35
- // Setup Audio Context
36
- const ctx = new (window.AudioContext || window.webkitAudioContext)();
37
-
38
- // iOS fix.
39
- document.addEventListener('touchstart', initAudioContext);
40
- function initAudioContext() {
41
- document.removeEventListener('touchstart', initAudioContext);
42
- // wake up AudioContext
43
- const emptySource = ctx.createBufferSource();
44
- emptySource.start();
45
- emptySource.stop();
7
+ When using as a Markdown editor on Vuetify.
8
+
9
+ ```vue
10
+ <template>
11
+ <codemirror
12
+ v-model="value"
13
+ :lang="lang"
14
+ :phrases="phreses"
15
+ :extensions="extensions"
16
+ :dark="$vuetify.theme.dark"
17
+ />
18
+ </template>
19
+
20
+ <script lang="ts">
21
+ import { Component, Vue } from 'vue-property-decorator';
22
+
23
+ // Load component
24
+ import CodeMirror from 'vue-codemirror6';
25
+
26
+ // CodeMirror extensions
27
+ import { basicSetup } from '@codemirror/basic-setup';
28
+ import { LanguageSupport } from '@codemirror/language';
29
+ import { markdown } from '@codemirror/lang-markdown';
30
+
31
+ @Component({ components: { CodeMirror } })
32
+ export default class Home extends Vue {
33
+ /** text */
34
+ value: string;
35
+
36
+ /**
37
+ * CodeMirror Language
38
+ *
39
+ * @see {@link https://codemirror.net/6/docs/ref/#language|@codemirror/language}
40
+ */
41
+ lang: LanguageSupport = markdown();
42
+
43
+ /**
44
+ * Internationalization Config
45
+ *
46
+ * @see {@link https://codemirror.net/6/examples/translate/|Example: Internationalization}
47
+ */
48
+ phrases: Record<string, string> = {
49
+ // @codemirror/view
50
+ 'Control character': '制御文字',
51
+ // @codemirror/fold
52
+ 'Folded lines': '折り畳まれた行',
53
+ 'Unfolded lines': '折り畳める行',
54
+ to: '行き先',
55
+ 'folded code': '折り畳まれたコード',
56
+ unfold: '折り畳む解除',
57
+ 'Fold line': '行を折り畳む',
58
+ 'Unfold line': '行の折り畳む解除',
59
+ // @codemirror/search
60
+ 'Go to line': '行き先の行',
61
+ go: 'OK',
62
+ Find: '検索',
63
+ Replace: '置き換え',
64
+ next: '▼',
65
+ previous: '▲',
66
+ all: 'すべて',
67
+ 'match case': '一致条件',
68
+ regexp: '正規表現',
69
+ replace: '置き換え',
70
+ 'replace all': 'すべてを置き換え',
71
+ close: '閉じる',
72
+ 'current match': '現在の一致',
73
+ 'on line': 'した行',
74
+ // @codemirror/lint
75
+ Diagnostics: 'エラー',
76
+ 'No diagnostics': 'エラーなし',
77
+ }
78
+
79
+ /**
80
+ * CodeMirror Extensions
81
+ *
82
+ * @see {@link:https://codemirror.net/6/docs/ref/#state.Extension|Extending Editor State}
83
+ */
84
+ extensions: [
85
+ /** @see {@link:https://codemirror.net/6/docs/ref/#basic-setup|basic-setup} */
86
+ basicSetup
87
+ ]
46
88
  }
47
-
48
- // Setup Reverb Class
49
- const reverb = new Reverb.default(ctx, {});
50
-
51
- // put Audio data to audio buffer source
52
- const sourceNode = ctx.createBufferSource();
53
- sourceNode.buffer = [AudioBuffer];
54
-
55
- // Connect Reverb
56
- reverb.connect(sourceNode);
57
- sourceNode.connect(ctx.destination);
58
-
59
- // fire
60
- sourceNode.play();
61
89
  ```
62
90
 
63
- ## Reference
64
-
65
- * [Web Audio API](https://www.w3.org/TR/webaudio/)
66
- * [Web Audio API日本語訳](https://g200kg.github.io/web-audio-api-ja/)
67
- * [コンボルバーの使い方](https://www.g200kg.com/jp/docs/webaudio/convolver.html)
68
- * [WebAudioの闇](https://qiita.com/zprodev/items/7fcd8335d7e8e613a01f)
69
-
70
- ## License
91
+ ## LICENSE
71
92
 
72
- [MIT](LICENSE)
93
+ [MIT](LICENSE)
@@ -0,0 +1,188 @@
1
+ const meta = {
2
+ version: "0.5.0",
3
+ date: "2022-02-21T09:25:39.234Z"
4
+ };
5
+ const Noise = {
6
+ WHITE: "white",
7
+ PINK: "pink",
8
+ BROWN: "brown"
9
+ };
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
+ class Reverb {
19
+ constructor(ctx, options) {
20
+ this.version = meta.version;
21
+ this.build = meta.date;
22
+ this.ctx = ctx;
23
+ this._options = { ...optionDefaults, ...options };
24
+ this.wetGainNode = this.ctx.createGain();
25
+ this.dryGainNode = this.ctx.createGain();
26
+ this.filterNode = this.ctx.createBiquadFilter();
27
+ this.convolverNode = this.ctx.createConvolver();
28
+ this.outputNode = this.ctx.createGain();
29
+ this.isConnected = false;
30
+ this.buildImpulse();
31
+ this.mix(this._options.mix);
32
+ }
33
+ connect(sourceNode) {
34
+ if (this.isConnected && this._options.once) {
35
+ this.isConnected = false;
36
+ return this.outputNode;
37
+ }
38
+ this.convolverNode.connect(this.filterNode);
39
+ this.filterNode.connect(this.wetGainNode);
40
+ sourceNode.connect(this.convolverNode);
41
+ sourceNode.connect(this.dryGainNode).connect(this.outputNode);
42
+ sourceNode.connect(this.wetGainNode).connect(this.outputNode);
43
+ this.isConnected = true;
44
+ return this.outputNode;
45
+ }
46
+ disconnect(sourceNode) {
47
+ if (this.isConnected) {
48
+ this.convolverNode.disconnect(this.filterNode);
49
+ this.filterNode.disconnect(this.wetGainNode);
50
+ }
51
+ this.isConnected = false;
52
+ return sourceNode;
53
+ }
54
+ mix(mix) {
55
+ if (!this.inRange(mix, 0, 1)) {
56
+ throw new RangeError("Reverb.js: Dry/Wet ratio must be between 0 to 1.");
57
+ }
58
+ this._options.mix = mix;
59
+ this.dryGainNode.gain.value = 1 - this._options.mix;
60
+ this.wetGainNode.gain.value = this._options.mix;
61
+ console.debug(`Reverb.js: Set dry/wet ratio to ${mix * 100}%`);
62
+ }
63
+ time(value) {
64
+ if (!this.inRange(value, 1, 50)) {
65
+ throw new RangeError("Reverb.js: Time length of inpulse response must be less than 50sec.");
66
+ }
67
+ this._options.time = value;
68
+ this.buildImpulse();
69
+ console.info(`Reverb.js: Set inpulse response time length to ${value}sec.`);
70
+ }
71
+ decay(value) {
72
+ if (!this.inRange(value, 0, 100)) {
73
+ throw new RangeError("Reverb.js: Inpulse Response decay level must be less than 100.");
74
+ }
75
+ this._options.decay = value;
76
+ this.buildImpulse();
77
+ console.debug(`Reverb.js: Set inpulse response decay level to ${value}.`);
78
+ }
79
+ delay(value) {
80
+ if (!this.inRange(value, 0, 100)) {
81
+ throw new RangeError("Reverb.js: Inpulse Response delay time must be less than 100.");
82
+ }
83
+ this._options.delay = value;
84
+ this.buildImpulse();
85
+ console.debug(`Reverb.js: Set inpulse response delay time to ${value}sec.`);
86
+ }
87
+ reverse(reverse) {
88
+ this._options.reverse = reverse;
89
+ this.buildImpulse();
90
+ console.debug(`Reverb.js: Inpulse response is ${reverse ? "" : "not "}reversed.`);
91
+ }
92
+ filterType(type) {
93
+ this.filterNode.type = this._options.filterType = type;
94
+ console.debug(`Set filter type to ${type}`);
95
+ }
96
+ filterFreq(freq) {
97
+ if (!this.inRange(freq, 20, 5e3)) {
98
+ throw new RangeError("Reverb.js: Filter frequrncy must be between 20 and 5000.");
99
+ }
100
+ this._options.filterFreq = freq;
101
+ this.filterNode.frequency.value = this._options.filterFreq;
102
+ console.debug(`Set filter frequency to ${freq}Hz.`);
103
+ }
104
+ filterQ(q) {
105
+ if (!this.inRange(q, 0, 10)) {
106
+ throw new RangeError("Reverb.js: Filter quality value must be between 0 and 10.");
107
+ }
108
+ this._options.filterQ = q;
109
+ this.filterNode.Q.value = this._options.filterQ;
110
+ console.debug(`Set filter quality to ${q}.`);
111
+ }
112
+ setNoise(type) {
113
+ this._options.noise = type;
114
+ this.buildImpulse();
115
+ console.debug(`Set Noise type to ${type}.`);
116
+ }
117
+ inRange(x, min, max) {
118
+ return (x - min) * (x - max) <= 0;
119
+ }
120
+ buildImpulse() {
121
+ const rate = this.ctx.sampleRate;
122
+ const duration = Math.max(rate * this._options.time, 1);
123
+ const delayDuration = rate * this._options.delay;
124
+ const impulse = this.ctx.createBuffer(2, duration, rate);
125
+ const impulseL = new Float32Array(duration);
126
+ const impulseR = new Float32Array(duration);
127
+ const b = [0, 0, 0, 0, 0, 0, 0];
128
+ for (let i = 0; i < duration; i++) {
129
+ let n = 0;
130
+ if (i < delayDuration) {
131
+ impulseL[i] = 0;
132
+ impulseR[i] = 0;
133
+ n = this._options.reverse ? duration - (i - delayDuration) : i - delayDuration;
134
+ } else {
135
+ n = this._options.reverse ? duration - i : i;
136
+ }
137
+ switch (this._options.noise) {
138
+ case Noise.PINK:
139
+ b[0] = 0.99886 * b[0] + Reverb.whiteNoise() * 0.0555179;
140
+ b[1] = 0.99332 * b[1] + Reverb.whiteNoise() * 0.0750759;
141
+ b[2] = 0.969 * b[2] + Reverb.whiteNoise() * 0.153852;
142
+ b[3] = 0.8665 * b[3] + Reverb.whiteNoise() * 0.3104856;
143
+ b[4] = 0.55 * b[4] + Reverb.whiteNoise() * 0.5329522;
144
+ b[5] = -0.7616 * b[5] - Reverb.whiteNoise() * 0.016898;
145
+ impulseL[i] = b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + Reverb.whiteNoise() * 0.5362;
146
+ impulseR[i] = b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + Reverb.whiteNoise() * 0.5362;
147
+ impulseL[i] *= 0.11;
148
+ impulseR[i] *= 0.11;
149
+ b[6] = Reverb.whiteNoise() * 0.115926;
150
+ break;
151
+ case Noise.BROWN:
152
+ impulseL[i] = (b[0] + 0.02 * Reverb.whiteNoise()) / 1.02;
153
+ b[0] = impulseL[i];
154
+ impulseR[i] = (b[1] + 0.02 * Reverb.whiteNoise()) / 1.02;
155
+ b[1] = impulseR[i];
156
+ impulseL[i] *= 3.5;
157
+ impulseR[i] *= 3.5;
158
+ break;
159
+ case Noise.WHITE:
160
+ default:
161
+ impulseL[i] = Reverb.whiteNoise();
162
+ impulseR[i] = Reverb.whiteNoise();
163
+ break;
164
+ }
165
+ impulseL[i] *= (1 - n / duration) ** this._options.decay;
166
+ impulseR[i] *= (1 - n / duration) ** this._options.decay;
167
+ }
168
+ impulse.getChannelData(0).set(impulseL);
169
+ impulse.getChannelData(1).set(impulseR);
170
+ this.convolverNode.buffer = impulse;
171
+ }
172
+ static whiteNoise() {
173
+ return Math.random() * 2 - 1;
174
+ }
175
+ }
176
+ const optionDefaults = {
177
+ noise: Noise.WHITE,
178
+ decay: 2,
179
+ delay: 0,
180
+ reverse: false,
181
+ time: 2,
182
+ filterType: "lowpass",
183
+ filterFreq: 2200,
184
+ filterQ: 1,
185
+ mix: 0.5,
186
+ once: false
187
+ };
188
+ export { Reverb as default };
@@ -0,0 +1,10 @@
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.0",t="2022-02-21T09:25:39.234Z",i="white",s="pink",o="brown";
2
+ /**
3
+ * JS reverb effect class
4
+ *
5
+ * @license MIT
6
+ * @author Logue {@link logue@hotmail.co.jp}
7
+ * @copyright 2019-2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
8
+ * @see {@link https://github.com/logue/Reverb.js}
9
+ */
10
+ 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,24 +1,24 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "@logue/reverb",
3
- "version": "0.4.2",
4
+ "version": "0.5.0",
4
5
  "description": "Reverb effect.",
5
- "main": "./bin/reverb.min.js",
6
+ "files": [
7
+ "dist",
8
+ "types"
9
+ ],
10
+ "main": "./dist/reverb.umd.js",
11
+ "module": "./dist/reverb.es.js",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/reverb.es.js",
15
+ "require": "./dist/reverb.umd.js"
16
+ }
17
+ },
18
+ "types": "./types/Reverb.d.ts",
6
19
  "directories": {
7
20
  "doc": "docs"
8
21
  },
9
- "scripts": {
10
- "build": "webpack --mode production",
11
- "dev": "webpack --mode development",
12
- "serve": "webpack serve --mode development --color --progress -w",
13
- "lint": "gts lint ./src/**/*.{js,ts}",
14
- "clean": "gts clean",
15
- "compile": "tsc",
16
- "fix": "gts fix ./src/**/*.{js,ts}"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/logue/reverb.js.git"
21
- },
22
22
  "keywords": [
23
23
  "webaudio",
24
24
  "convolver",
@@ -30,35 +30,55 @@
30
30
  "email": "logue@hotmail.co.jp",
31
31
  "url": "https://logue.dev/"
32
32
  },
33
- "license": "MIT",
33
+ "homepage": "https://github.com/logue/Reverb.js",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git@github.com:logue/Reverb.js.git"
37
+ },
34
38
  "bugs": {
35
- "url": "https://github.com/logue/reverb.js/issues"
39
+ "url": "https://github.com/logue/Reverb.js/issues"
40
+ },
41
+ "engines": {
42
+ "node": ">=16"
43
+ },
44
+ "license": "MIT",
45
+ "sideEffects": false,
46
+ "scripts": {
47
+ "dev": "vite",
48
+ "build": "tsc && vite build",
49
+ "build:clean": "rimraf dist",
50
+ "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
51
+ "prepare": "husky install"
36
52
  },
37
- "homepage": "https://github.com/logue/reverb.js#readme",
38
53
  "devDependencies": {
39
- "@types/terser-webpack-plugin": "^5.0.4",
40
- "@types/webpack": "^5.28.0",
41
- "@types/webpack-dev-server": "^3.11.5",
42
- "fs": "0.0.1-security",
43
- "gts": "^3.1.0",
44
- "hosted-git-info": "^4.0.2",
45
- "lint-staged": "^11.0.0",
46
- "terser-webpack-plugin": "^5.1.4",
47
- "ts-loader": "^9.2.3",
48
- "ts-node": "^10.0.0",
49
- "tsconfig-paths": "^3.9.0",
50
- "typescript": "^4.3.5",
51
- "webpack": "^5.42.0",
52
- "webpack-cli": "^4.7.2",
53
- "webpack-dev-server": "^3.11.2"
54
+ "@types/node": "^17.0.18",
55
+ "@typescript-eslint/eslint-plugin": "^5.12.0",
56
+ "@typescript-eslint/parser": "^5.12.0",
57
+ "eslint": "^8.9.0",
58
+ "eslint-config-google": "^0.14.0",
59
+ "eslint-config-prettier": "^8.4.0",
60
+ "eslint-import-resolver-alias": "^1.1.2",
61
+ "eslint-import-resolver-typescript": "^2.5.0",
62
+ "eslint-plugin-import": "^2.25.4",
63
+ "eslint-plugin-prettier": "^4.0.0",
64
+ "eslint-plugin-tsdoc": "^0.2.14",
65
+ "husky": "^7.0.4",
66
+ "lint-staged": "^12.3.4",
67
+ "prettier": "^2.5.1",
68
+ "prettier-plugin-jsdoc": "^0.3.30",
69
+ "prettier-plugin-md-nocjsp": "^1.2.0",
70
+ "rimraf": "^3.0.2",
71
+ "typescript": "^4.5.5",
72
+ "vite": "^2.8.4",
73
+ "vite-plugin-eslint": "^1.3.0"
54
74
  },
55
- "gitHooks": {
56
- "pre-commit": "lint-staged"
75
+ "husky": {
76
+ "hooks": {
77
+ "pre-commit": "lint-staged"
78
+ }
57
79
  },
58
80
  "lint-staged": {
59
- "*.{js,jsx,ts,tsx}": [
60
- "npm lint",
61
- "git add"
62
- ]
81
+ "*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
82
+ "*": "prettier -w -u"
63
83
  }
64
- }
84
+ }
@@ -0,0 +1,4 @@
1
+ import type MetaInterface from '@/interfaces/MetaInterface';
2
+ declare const meta: MetaInterface;
3
+ export default meta;
4
+ // # sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAC;AAG5D,QAAA,MAAM,IAAI,EAAE,aAGX,CAAC;AACF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** Impulse response noise generation algorithm */
2
+ declare const Noise: {
3
+ /** White noise */
4
+ readonly WHITE: 'white';
5
+ /** Pink noise */
6
+ readonly PINK: 'pink';
7
+ /** Brown Noise */
8
+ readonly BROWN: 'brown';
9
+ };
10
+ /** Noise Type */
11
+ export declare type NoiseType = typeof Noise[keyof typeof Noise];
12
+ /** Noise */
13
+ export default Noise;
14
+ // # sourceMappingURL=NoiseType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NoiseType.d.ts","sourceRoot":"","sources":["../src/NoiseType.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,QAAA,MAAM,KAAK;IACT,kBAAkB;;IAElB,iBAAiB;;IAEjB,kBAAkB;;CAGV,CAAC;AAEX,iBAAiB;AACjB,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEzD,YAAY;AACZ,eAAe,KAAK,CAAC"}
@@ -0,0 +1,118 @@
1
+ import type OptionInterface from './interfaces/OptionInterface';
2
+ import { type NoiseType } from './NoiseType';
3
+ /**
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
+ */
11
+ export default class Reverb {
12
+ /** Version strings */
13
+ readonly version: string;
14
+ /** Build date */
15
+ readonly build: string;
16
+ /** AudioContext */
17
+ private readonly ctx;
18
+ /** Wet Level (Reverberated node) */
19
+ private readonly wetGainNode;
20
+ /** Dry Level (Original sound node) */
21
+ private readonly dryGainNode;
22
+ /** Impulse response filter */
23
+ private readonly filterNode;
24
+ /** Convolution node for applying impulse response */
25
+ private readonly convolverNode;
26
+ /** Output nodse */
27
+ private readonly outputNode;
28
+ /** Option */
29
+ private readonly _options;
30
+ /** Connected flag */
31
+ private isConnected;
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @param ctx - Root AudioContext
36
+ * @param options - Configure
37
+ */
38
+ constructor(ctx: AudioContext, options: OptionInterface | undefined);
39
+ /**
40
+ * Connect the node for the reverb effect to the original sound node.
41
+ *
42
+ * @param sourceNode - Input source node
43
+ */
44
+ connect(sourceNode: AudioNode): AudioNode;
45
+ /**
46
+ * Disconnect the reverb node
47
+ *
48
+ * @param sourceNode - Input source node
49
+ */
50
+ disconnect(sourceNode: AudioNode | undefined): AudioNode | undefined;
51
+ /**
52
+ * Dry/Wet ratio
53
+ *
54
+ * @param mix - Ratio (0~1)
55
+ */
56
+ mix(mix: number): void;
57
+ /**
58
+ * Set Impulse Response time length (second)
59
+ *
60
+ * @param value - IR length
61
+ */
62
+ time(value: number): void;
63
+ /**
64
+ * Impulse response decay rate.
65
+ *
66
+ * @param value - Decay value
67
+ */
68
+ decay(value: number): void;
69
+ /**
70
+ * Delay before reverberation starts
71
+ *
72
+ * @param value - Time[ms]
73
+ */
74
+ delay(value: number): void;
75
+ /**
76
+ * Reverse the impulse response.
77
+ *
78
+ * @param reverse - Reverse IR
79
+ */
80
+ reverse(reverse: boolean): void;
81
+ /**
82
+ * Filter for impulse response
83
+ *
84
+ * @param type - Filiter Type
85
+ */
86
+ filterType(type: BiquadFilterType): void;
87
+ /**
88
+ * Filter frequency applied to impulse response
89
+ *
90
+ * @param freq - Frequency
91
+ */
92
+ filterFreq(freq: number): void;
93
+ /**
94
+ * Filter quality.
95
+ *
96
+ * @param q - Quality
97
+ */
98
+ filterQ(q: number): void;
99
+ /**
100
+ * Inpulse Response Noise algorithm.
101
+ *
102
+ * @param type - IR noise algorithm type.
103
+ */
104
+ setNoise(type: NoiseType): void;
105
+ /**
106
+ * Return true if in range, otherwise false
107
+ *
108
+ * @param x - Target value
109
+ * @param min - Minimum value
110
+ * @param max - Maximum value
111
+ */
112
+ private inRange;
113
+ /** Utility function for building an impulse response from the module parameters. */
114
+ private buildImpulse;
115
+ /** Generate white noise */
116
+ private static whiteNoise;
117
+ }
118
+ // # sourceMappingURL=Reverb.d.ts.map
@@ -0,0 +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;;;;;;;GAOG;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,GAAG,CAAe;IACnC,oCAAoC;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAW;IACvC,8BAA8B;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,mBAAmB;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IACtC,aAAa;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,qBAAqB;IACrB,OAAO,CAAC,WAAW,CAAU;IAE7B;;;;;OAKG;gBACS,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,SAAS;IAsBnE;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS;IAsBhD;;;;OAIG;IACI,UAAU,CAAC,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;IAe3E;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAU7B;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWhC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWjC;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAK/C;;;;OAIG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWrC;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAW/B;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,SAAS;IAM/B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAIf,oFAAoF;IACpF,OAAO,CAAC,YAAY;IAoGpB,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAC,UAAU;CAI1B"}
@@ -0,0 +1,8 @@
1
+ /** Meta Information Interface */
2
+ export default interface MetaInterface {
3
+ /** Version */
4
+ version: string;
5
+ /** Build Date */
6
+ date: string;
7
+ }
8
+ // # sourceMappingURL=MetaInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetaInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/MetaInterface.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,25 @@
1
+ import { NoiseType } from '../NoiseType';
2
+ /** Reverb Option */
3
+ export default interface OptionInterface {
4
+ /** Types of impulse response noise generation algorithms */
5
+ noise: NoiseType;
6
+ /** Decay */
7
+ decay: number;
8
+ /** Delay until impulse response is generated */
9
+ delay: number;
10
+ /** Filter frequency applied to impulse response[Hz] */
11
+ filterFreq: number;
12
+ /** Filter quality for impulse response */
13
+ filterQ: number;
14
+ /** Filter type for impulse response */
15
+ filterType: BiquadFilterType;
16
+ /** Dry/Wet ratio */
17
+ mix: number;
18
+ /** Invert the impulse response */
19
+ reverse: boolean;
20
+ /** Impulse response length */
21
+ time: number;
22
+ /** Prevents multiple effectors from being connected. */
23
+ once: boolean;
24
+ }
25
+ // # sourceMappingURL=OptionInterface.d.ts.map