mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 20:18:34 +00:00
add fanchor
This commit is contained in:
parent
7dbcc90450
commit
e959c275fd
@ -586,6 +586,7 @@ const generic_params = [
|
|||||||
*/
|
*/
|
||||||
['bprelease', 'bpr'],
|
['bprelease', 'bpr'],
|
||||||
['ftype'],
|
['ftype'],
|
||||||
|
['fanchor'],
|
||||||
/**
|
/**
|
||||||
* Applies the cutoff frequency of the **h**igh-**p**ass **f**ilter.
|
* Applies the cutoff frequency of the **h**igh-**p**ass **f**ilter.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -78,7 +78,20 @@ export const getParamADSR = (param, attack, decay, sustain, release, min, max, b
|
|||||||
param.linearRampToValueAtTime(min, end + Math.max(release, 0.1));
|
param.linearRampToValueAtTime(min, end + Math.max(release, 0.1));
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createFilter(context, type, frequency, Q, attack, decay, sustain, release, fenv, start, end) {
|
export function createFilter(
|
||||||
|
context,
|
||||||
|
type,
|
||||||
|
frequency,
|
||||||
|
Q,
|
||||||
|
attack,
|
||||||
|
decay,
|
||||||
|
sustain,
|
||||||
|
release,
|
||||||
|
fenv,
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
fanchor = 0.5,
|
||||||
|
) {
|
||||||
const filter = context.createBiquadFilter();
|
const filter = context.createBiquadFilter();
|
||||||
filter.type = type;
|
filter.type = type;
|
||||||
filter.Q.value = Q;
|
filter.Q.value = Q;
|
||||||
@ -86,8 +99,7 @@ export function createFilter(context, type, frequency, Q, attack, decay, sustain
|
|||||||
|
|
||||||
// Apply ADSR to filter frequency
|
// Apply ADSR to filter frequency
|
||||||
if (fenv !== 0) {
|
if (fenv !== 0) {
|
||||||
const anchor = 0.5;
|
const offset = fenv * fanchor;
|
||||||
const offset = fenv * anchor;
|
|
||||||
|
|
||||||
const min = clamp(2 ** -offset * frequency, 0, 20000);
|
const min = clamp(2 ** -offset * frequency, 0, 20000);
|
||||||
const max = clamp(2 ** (fenv - offset) * frequency, 0, 20000);
|
const max = clamp(2 ** (fenv - offset) * frequency, 0, 20000);
|
||||||
|
|||||||
@ -179,6 +179,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
|||||||
gain = 0.8,
|
gain = 0.8,
|
||||||
// filters
|
// filters
|
||||||
ftype = '12db',
|
ftype = '12db',
|
||||||
|
fanchor = 0.5,
|
||||||
// low pass
|
// low pass
|
||||||
cutoff,
|
cutoff,
|
||||||
lpenv,
|
lpenv,
|
||||||
@ -270,6 +271,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
|||||||
lpenv,
|
lpenv,
|
||||||
t,
|
t,
|
||||||
t + hapDuration,
|
t + hapDuration,
|
||||||
|
fanchor,
|
||||||
);
|
);
|
||||||
chain.push(lp());
|
chain.push(lp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
@ -291,6 +293,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
|||||||
hpenv,
|
hpenv,
|
||||||
t,
|
t,
|
||||||
t + hapDuration,
|
t + hapDuration,
|
||||||
|
fanchor,
|
||||||
);
|
);
|
||||||
chain.push(hp());
|
chain.push(hp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
@ -300,7 +303,20 @@ export const superdough = async (value, deadline, hapDuration) => {
|
|||||||
|
|
||||||
if (bandf !== undefined) {
|
if (bandf !== undefined) {
|
||||||
let bp = () =>
|
let bp = () =>
|
||||||
createFilter(ac, 'bandpass', bandf, bandq, bpattack, bpdecay, bpsustain, bprelease, bpenv, t, t + hapDuration);
|
createFilter(
|
||||||
|
ac,
|
||||||
|
'bandpass',
|
||||||
|
bandf,
|
||||||
|
bandq,
|
||||||
|
bpattack,
|
||||||
|
bpdecay,
|
||||||
|
bpsustain,
|
||||||
|
bprelease,
|
||||||
|
bpenv,
|
||||||
|
t,
|
||||||
|
t + hapDuration,
|
||||||
|
fanchor,
|
||||||
|
);
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user