documentation
This commit is contained in:
parent
e6f272dd0c
commit
a8eafbc309
4 changed files with 24 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// coarse, crush, and shape processors adapted from dktr0's webdirt: https://github.com/dktr0/WebDirt/blob/5ce3d698362c54d6e1b68acc47eb2955ac62c793/dist/AudioWorklets.js
|
||||
// LICENSE GNU General Public License v3.0 see https://github.com/dktr0/WebDirt/blob/main/LICENSE
|
||||
|
||||
import { clamp } from './util.mjs';
|
||||
const blockSize = 128;
|
||||
class CoarseProcessor extends AudioWorkletProcessor {
|
||||
static get parameterDescriptors() {
|
||||
|
|
@ -111,13 +111,13 @@ function fast_tanh(x) {
|
|||
return (x * (27.0 + x2)) / (27.0 + 9.0 * x2);
|
||||
}
|
||||
const _PI = 3.14159265359;
|
||||
|
||||
//adapted from https://github.com/TheBouteillacBear/webaudioworklet-wasm?tab=MIT-1-ov-file
|
||||
class LadderProcessor extends AudioWorkletProcessor {
|
||||
static get parameterDescriptors() {
|
||||
return [
|
||||
{ name: 'frequency', defaultValue: 500 },
|
||||
{ name: 'q', defaultValue: 1 },
|
||||
{ name: 'drive', defaultValue: 1 },
|
||||
{ name: 'drive', defaultValue: 0.69 },
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -145,13 +145,14 @@ class LadderProcessor extends AudioWorkletProcessor {
|
|||
this.started = hasInput;
|
||||
|
||||
const resonance = parameters.q[0];
|
||||
const drive = parameters.drive[0] * 2;
|
||||
const drive = clamp(Math.exp(parameters.drive[0]), 0.1, 2000);
|
||||
let cutoff = parameters.frequency[0];
|
||||
cutoff = (cutoff * 2 * _PI) / sampleRate;
|
||||
cutoff = cutoff > 1 ? 1 : cutoff;
|
||||
|
||||
const k = resonance * 4;
|
||||
const makeupgain = 1 / drive;
|
||||
const k = Math.min(8, resonance * 2);
|
||||
// drive makeup * resonance volume loss makeup
|
||||
const makeupgain = (1 / drive) * Math.min(1.75, 1 + k);
|
||||
|
||||
for (let n = 0; n < blockSize; n++) {
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue