1 | import "../core/worklet/SingleIOProcessor.worklet.js";
|
2 | import { registerProcessor } from "../core/worklet/WorkletGlobalScope.js";
|
3 | export const workletName = "bit-crusher";
|
4 | export const bitCrusherWorklet = `
|
5 | class BitCrusherWorklet extends SingleIOProcessor {
|
6 |
|
7 | static get parameterDescriptors() {
|
8 | return [{
|
9 | name: "bits",
|
10 | defaultValue: 12,
|
11 | minValue: 1,
|
12 | maxValue: 16,
|
13 | automationRate: 'k-rate'
|
14 | }];
|
15 | }
|
16 |
|
17 | generate(input, _channel, parameters) {
|
18 | const step = Math.pow(0.5, parameters.bits - 1);
|
19 | const val = step * Math.floor(input / step + 0.5);
|
20 | return val;
|
21 | }
|
22 | }
|
23 | `;
|
24 | registerProcessor(workletName, bitCrusherWorklet);
|
25 |
|
\ | No newline at end of file |