-
Notifications
You must be signed in to change notification settings - Fork 0
/
Noise.tsx
28 lines (25 loc) · 1.08 KB
/
Noise.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
import React from "react";
import { NodeProps } from "react-flow-renderer";
import Node from "components/Node";
import useAudioWorkletNode from "hooks/nodes/useAudioWorkletNode";
import { NoiseType } from "worklets/noise-processor.types";
function Noise({ data, id, selected, type: nodeType }: NodeProps) {
const { onChange, type = NoiseType.White } = data;
useAudioWorkletNode(id, "noise-processor", { numberOfInputs: 0, processorOptions: { type } }, [type]);
return (
<Node id={id} outputs={["output"]} title={`Noise: ${type}`} type={nodeType}>
{selected && (
<div className="customNode_editor nodrag">
<div className="customNode_item">
<select onChange={e => onChange({ type: e.target.value })} title="Type" value={type}>
<option value={NoiseType.White}>{NoiseType.White}</option>
<option value={NoiseType.Pink}>{NoiseType.Pink}</option>
<option value={NoiseType.Brown}>{NoiseType.Brown}</option>
</select>
</div>
</div>
)}
</Node>
);
}
export default React.memo(Noise);