@logue/reverb 0.5.0 → 0.5.1
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 +61 -84
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,93 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reverb.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/%40logue%2Freverb)
|
|
4
|
+
|
|
5
|
+
Append reverb effect to audio source.
|
|
6
|
+
|
|
7
|
+
This script is originally a spin out of [sf2synth.js](https://github.com/logue/smfplayer.js)'s reverb effect.
|
|
8
|
+
|
|
9
|
+
## Sample
|
|
10
|
+
|
|
11
|
+
* <https://logue.dev/Reverb.js/>
|
|
12
|
+
* <https://logue.dev/Reverb.js/localaudio.html>
|
|
13
|
+
|
|
14
|
+
## Syntax
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const reverb = new Reverb(ctx, {
|
|
18
|
+
noise: 0, // Inpulse Response Noise algorithm (0: White noise, 1: Pink noise, 2: Brown noise)
|
|
19
|
+
decay: 5, // Amount of IR (Inpulse Response) decay. 0~100
|
|
20
|
+
delay: 0, // Delay time o IR. (NOT delay effect) 0~100 [sec]
|
|
21
|
+
filterFreq: 2200, // Filter frequency. 20~5000 [Hz]
|
|
22
|
+
filterQ: 1, // Filter quality. 0~10
|
|
23
|
+
filterType: 'lowpass', // Filter type. 'bandpass' etc. See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type .
|
|
24
|
+
mix: 0.5, // Dry (Original Sound) and Wet (Effected sound) raito. 0~1
|
|
25
|
+
reverse: false, // Reverse IR.
|
|
26
|
+
time: 3 // Time length of IR. 0~50 [sec]
|
|
27
|
+
});
|
|
28
|
+
```
|
|
4
29
|
|
|
5
30
|
## Usage
|
|
6
31
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
]
|
|
32
|
+
```js
|
|
33
|
+
// Setup Audio Context
|
|
34
|
+
const ctx = new (window.AudioContext || window.webkitAudioContext)();
|
|
35
|
+
|
|
36
|
+
// iOS fix.
|
|
37
|
+
document.addEventListener('touchstart', initAudioContext);
|
|
38
|
+
function initAudioContext() {
|
|
39
|
+
document.removeEventListener('touchstart', initAudioContext);
|
|
40
|
+
// wake up AudioContext
|
|
41
|
+
const emptySource = ctx.createBufferSource();
|
|
42
|
+
emptySource.start();
|
|
43
|
+
emptySource.stop();
|
|
88
44
|
}
|
|
45
|
+
|
|
46
|
+
// Setup Reverb Class
|
|
47
|
+
const reverb = new Reverb(ctx, {});
|
|
48
|
+
|
|
49
|
+
// put Audio data to audio buffer source
|
|
50
|
+
const sourceNode = ctx.createBufferSource();
|
|
51
|
+
sourceNode.buffer = [AudioBuffer];
|
|
52
|
+
|
|
53
|
+
// Connect Reverb
|
|
54
|
+
reverb.connect(sourceNode);
|
|
55
|
+
sourceNode.connect(ctx.destination);
|
|
56
|
+
|
|
57
|
+
// fire
|
|
58
|
+
sourceNode.play();
|
|
89
59
|
```
|
|
90
60
|
|
|
91
|
-
##
|
|
61
|
+
## Reference
|
|
62
|
+
|
|
63
|
+
* [Web Audio API](https://www.w3.org/TR/webaudio/)
|
|
64
|
+
* [Web Audio API日本語訳](https://g200kg.github.io/web-audio-api-ja/)
|
|
65
|
+
* [コンボルバーの使い方](https://www.g200kg.com/jp/docs/webaudio/convolver.html)
|
|
66
|
+
* [WebAudioの闇](https://qiita.com/zprodev/items/7fcd8335d7e8e613a01f)
|
|
67
|
+
|
|
68
|
+
## License
|
|
92
69
|
|
|
93
70
|
[MIT](LICENSE)
|