-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformer.tsx
70 lines (66 loc) · 1.93 KB
/
Transformer.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
import React from "react";
import { NodeProps } from "react-flow-renderer";
import Node from "components/Node";
import useAudioWorkletNode from "hooks/nodes/useAudioWorkletNode";
const inputStyle = {
width: 50,
};
function Transformer({ data, id, selected, type }: NodeProps) {
const { inputMax = 1, inputMin = -1, onChange, outputMax = 1, outputMin = 0 } = data;
useAudioWorkletNode(
id,
"transformer-processor",
{
processorOptions: {
inputMin,
inputMax,
outputMin,
outputMax,
},
},
[inputMin, inputMax, outputMin, outputMax]
);
return (
<Node id={id} inputs={["input"]} outputs={["output"]} title="Transformer" type={type}>
{selected && (
<div className="customNode_editor nodrag">
<div className="customNode_item">
<input
onChange={e => onChange({ inputMin: +e.target.value })}
style={inputStyle}
title={`Input min`}
type="number"
value={inputMin}
/>
<span>→</span>
<input
onChange={e => onChange({ outputMin: +e.target.value })}
style={inputStyle}
title={`Output min`}
type="number"
value={outputMin}
/>
</div>
<div className="customNode_item">
<input
onChange={e => onChange({ inputMax: +e.target.value })}
style={inputStyle}
title={`Input max`}
type="number"
value={inputMax}
/>
<span>→</span>
<input
onChange={e => onChange({ outputMax: +e.target.value })}
style={inputStyle}
title={`Output max`}
type="number"
value={outputMax}
/>
</div>
</div>
)}
</Node>
);
}
export default React.memo(Transformer);