Tone.js/Tone/effect/BitCrusher.worklet.ts
Yotam Mann aaf880c925
Using web-test-runner for tests, updating import paths (#1242)
* WIP moving tests to web-test-runner

* updating thresholds

* Adding file extensions

* Testing integrations

* linting

* fixing dep

* moving back to root dir

* prettier all of the files

* updating eslint rules to use with prettier

* remove import package

* moving tsignore around

* removing unneeded ignores

* all tests run on puppeteer, no need for testing guards

* linting

* import type syntax

* cleaning up

* Update package.json
2024-05-03 14:31:14 -04:00

27 lines
672 B
TypeScript

import "../core/worklet/SingleIOProcessor.worklet.js";
import { registerProcessor } from "../core/worklet/WorkletGlobalScope.js";
export const workletName = "bit-crusher";
export const bitCrusherWorklet = /* javascript */ `
class BitCrusherWorklet extends SingleIOProcessor {
static get parameterDescriptors() {
return [{
name: "bits",
defaultValue: 12,
minValue: 1,
maxValue: 16,
automationRate: 'k-rate'
}];
}
generate(input, _channel, parameters) {
const step = Math.pow(0.5, parameters.bits - 1);
const val = step * Math.floor(input / step + 0.5);
return val;
}
}
`;
registerProcessor(workletName, bitCrusherWorklet);