fix import

This commit is contained in:
Jade (Rose) Rowland 2024-05-18 01:33:40 -04:00
parent 9b52807c7e
commit e87055d583
4 changed files with 14 additions and 10 deletions

View File

@ -14,6 +14,15 @@ const getSlope = (y1, y2, x1, x2) => {
}
return (y2 - y1) / (x2 - x1);
};
export function getWorklet(ac, processor, params, config) {
const node = new AudioWorkletNode(ac, processor, config);
Object.entries(params).forEach(([key, value]) => {
node.parameters.get(key).value = value;
});
return node;
}
export const getParamADSR = (
param,
attack,

View File

@ -9,7 +9,7 @@ import './reverb.mjs';
import './vowel.mjs';
import { clamp, nanFallback } from './util.mjs';
import workletsUrl from './worklets.mjs?url';
import { createFilter, gainNode, getCompressor } from './helpers.mjs';
import { createFilter, gainNode, getCompressor, getWorklet } from './helpers.mjs';
import { map } from 'nanostores';
import { logger } from './logger.mjs';
import { loadBuffer } from './sampler.mjs';
@ -50,14 +50,6 @@ function loadWorklets() {
return workletsLoading;
}
export function getWorklet(ac, processor, params, config) {
const node = new AudioWorkletNode(ac, processor, config);
Object.entries(params).forEach(([key, value]) => {
node.parameters.get(key).value = value;
});
return node;
}
// this function should be called on first user interaction (to avoid console warning)
export async function initAudio(options = {}) {
const { disableWorklets = false } = options;

View File

@ -1,5 +1,5 @@
import { clamp, midiToFreq, noteToMidi } from './util.mjs';
import { registerSound, getAudioContext, getWorklet } from './superdough.mjs';
import { registerSound, getAudioContext } from './superdough.mjs';
import {
applyFM,
gainNode,
@ -8,6 +8,7 @@ import {
getPitchEnvelope,
getVibratoOscillator,
webAudioTimeout,
getWorklet,
} from './helpers.mjs';
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';

View File

@ -146,7 +146,9 @@ class LadderProcessor extends AudioWorkletProcessor {
const resonance = parameters.q[0];
const drive = clamp(Math.exp(parameters.drive[0]), 0.1, 2000);
let cutoff = parameters.frequency[0];
// eslint-disable-next-line no-undef
cutoff = (cutoff * 2 * _PI) / sampleRate;
cutoff = cutoff > 1 ? 1 : cutoff;