mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 19:43:12 +00:00
aaf880c925
* 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
27 lines
672 B
TypeScript
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);
|