Merge branch 'main' into phasermodulation
This commit is contained in:
commit
026cbe050c
18 changed files with 382 additions and 7160 deletions
|
|
@ -7,9 +7,9 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||
import './feedbackdelay.mjs';
|
||||
import './reverb.mjs';
|
||||
import './vowel.mjs';
|
||||
import { clamp, nanFallback } from './util.mjs';
|
||||
import { clamp, nanFallback, _mod } 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;
|
||||
|
|
@ -185,10 +177,14 @@ function getPhaser(time, end, frequency = 1, depth = 0.5, centerFrequency = 1000
|
|||
return filterChain[filterChain.length - 1];
|
||||
}
|
||||
|
||||
function getFilterType(ftype) {
|
||||
ftype = ftype ?? 0;
|
||||
const filterTypes = ['12db', 'ladder', '24db'];
|
||||
return typeof ftype === 'number' ? filterTypes[Math.floor(_mod(ftype, filterTypes.length))] : ftype;
|
||||
}
|
||||
|
||||
let reverbs = {};
|
||||
|
||||
let hasChanged = (now, before) => now !== undefined && now !== before;
|
||||
|
||||
function getReverb(orbit, duration, fade, lp, dim, ir) {
|
||||
// If no reverb has been created for a given orbit, create one
|
||||
if (!reverbs[orbit]) {
|
||||
|
|
@ -287,8 +283,9 @@ export const superdough = async (value, t, hapDuration) => {
|
|||
postgain = 1,
|
||||
density = 0.03,
|
||||
// filters
|
||||
ftype = '12db',
|
||||
|
||||
fanchor = 0.5,
|
||||
drive = 0.69,
|
||||
// low pass
|
||||
cutoff,
|
||||
lpenv,
|
||||
|
|
@ -393,6 +390,8 @@ export const superdough = async (value, t, hapDuration) => {
|
|||
// gain stage
|
||||
chain.push(gainNode(gain));
|
||||
|
||||
//filter
|
||||
const ftype = getFilterType(value.ftype);
|
||||
if (cutoff !== undefined) {
|
||||
let lp = () =>
|
||||
createFilter(
|
||||
|
|
@ -408,6 +407,8 @@ export const superdough = async (value, t, hapDuration) => {
|
|||
t,
|
||||
t + hapDuration,
|
||||
fanchor,
|
||||
ftype,
|
||||
drive,
|
||||
);
|
||||
chain.push(lp());
|
||||
if (ftype === '24db') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue