-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamicsCompressor.tsx
80 lines (77 loc) · 2.38 KB
/
DynamicsCompressor.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from "react";
import { NodeProps } from "react-flow-renderer";
import Node from "components/Node";
import useDynamicsCompressorNode from "hooks/nodes/useDynamicsCompressorNode";
function DynamicsCompressor({ data, id, selected, type }: NodeProps) {
const { attack = 0.003, knee = 30, onChange, ratio = 12, release = 0.25, threshold = -24 } = data;
useDynamicsCompressorNode(id, { attack, knee, ratio, release, threshold });
return (
<Node
id={id}
inputs={["input", "threshold", "knee", "ratio", "attack", "release"]}
outputs={["output"]}
type={type}
>
{selected && (
<div className="customNode_editor nodrag">
<div className="customNode_item">
<input
min="-100"
max="0"
onChange={e => onChange({ threshold: +e.target.value })}
step="1"
title={`Threshold: ${threshold} dB`}
type="range"
value={threshold}
/>
</div>
<div className="customNode_item">
<input
min="0"
max="40"
onChange={e => onChange({ knee: +e.target.value })}
step="1"
title={`Knee: ${knee} dB`}
type="range"
value={knee}
/>
</div>
<div className="customNode_item">
<input
min="1"
max="20"
onChange={e => onChange({ ratio: +e.target.value })}
step="1"
title={`Ratio: ${ratio} dB`}
type="range"
value={ratio}
/>
</div>
<div className="customNode_item">
<input
min="0"
max="1"
onChange={e => onChange({ attack: +e.target.value })}
step="0.001"
title={`Attack: ${attack} s`}
type="range"
value={attack}
/>
</div>
<div className="customNode_item">
<input
min="0"
max="1"
onChange={e => onChange({ release: +e.target.value })}
step="0.001"
title={`Release: ${release} s`}
type="range"
value={release}
/>
</div>
</div>
)}
</Node>
);
}
export default React.memo(DynamicsCompressor);