frequency mod
This commit is contained in:
parent
31c694b596
commit
e86850b6d8
3 changed files with 49 additions and 5 deletions
|
|
@ -1319,6 +1319,18 @@ export const { lpsync } = registerControl('lpsync');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const { lpdepth } = registerControl('lpdepth');
|
export const { lpdepth } = registerControl('lpdepth');
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the lowpass filter, in HZ
|
||||||
|
*
|
||||||
|
* @name lpdepthfrequency
|
||||||
|
* @synonyms
|
||||||
|
* lpdethfreq
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).lpdepthfrequency("<200 500 100 0>")
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const { lpdepthfrequency } = registerControl('lpdepthfrequency', 'lpdepthfreq');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the LFO for the lowpass filter
|
* Shape of the LFO for the lowpass filter
|
||||||
|
|
@ -1368,6 +1380,19 @@ export const { bpsync } = registerControl('bpsync');
|
||||||
*/
|
*/
|
||||||
export const { bpdepth } = registerControl('bpdepth');
|
export const { bpdepth } = registerControl('bpdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the bandpass filter, in HZ
|
||||||
|
*
|
||||||
|
* @name bpdepthfrequency
|
||||||
|
* @synonyms
|
||||||
|
* bpdethfreq
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).bpdepthfrequency("<200 500 100 0>")
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const { bpdepthfrequency } = registerControl('bpdepthfrequency', 'bpdepthfreq');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the LFO for the bandpass filter
|
* Shape of the LFO for the bandpass filter
|
||||||
*
|
*
|
||||||
|
|
@ -1414,7 +1439,20 @@ export const { hpsync } = registerControl('hpsync');
|
||||||
* @name hpdepth
|
* @name hpdepth
|
||||||
* @param {number | Pattern} depth depth of modulation
|
* @param {number | Pattern} depth depth of modulation
|
||||||
*/
|
*/
|
||||||
export const { hpdepth } = registerControl('hpdepth');
|
export const { hpdepth, hpdepthfreq } = registerControl('hpdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Depth of the LFO for the hipass filter, in hz
|
||||||
|
*
|
||||||
|
* @name hpdepthfrequency
|
||||||
|
* @synonyms
|
||||||
|
* hpdethfreq
|
||||||
|
* @param {number | Pattern} depth depth of modulation
|
||||||
|
* @example
|
||||||
|
* note("<c c c# c c c4>*16").s("sawtooth").lpf(600).hpdepthfrequency("<200 500 100 0>")
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const { hpdepthfrequency } = registerControl('hpdepthfrequency', 'hpdepthfreq');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the LFO for the highpass filter
|
* Shape of the LFO for the highpass filter
|
||||||
|
|
|
||||||
|
|
@ -201,12 +201,14 @@ export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
q = 1,
|
q = 1,
|
||||||
drive = 0.69,
|
drive = 0.69,
|
||||||
depth,
|
depth,
|
||||||
|
depthfrequency,
|
||||||
dcoffset = -0.5,
|
dcoffset = -0.5,
|
||||||
skew,
|
skew,
|
||||||
shape,
|
shape,
|
||||||
rate,
|
rate,
|
||||||
sync,
|
sync,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
let frequencyParam, filter;
|
let frequencyParam, filter;
|
||||||
if (model === 'ladder') {
|
if (model === 'ladder') {
|
||||||
filter = getWorklet(context, 'ladder-processor', { frequency, q, drive });
|
filter = getWorklet(context, 'ladder-processor', { frequency, q, drive });
|
||||||
|
|
@ -237,12 +239,13 @@ export function createFilter(context, start, end, params, cps, cycle) {
|
||||||
if (sync != null) {
|
if (sync != null) {
|
||||||
rate = cps * sync;
|
rate = cps * sync;
|
||||||
}
|
}
|
||||||
const hasLFO = [depth, skew, shape, rate].some((v) => v !== undefined);
|
const hasLFO = [depth, depthfrequency, skew, shape, rate].some((v) => v !== undefined);
|
||||||
if (hasLFO) {
|
if (hasLFO) {
|
||||||
depth = depth ?? 1;
|
depth = depth ?? 1;
|
||||||
const time = cycle / cps;
|
const time = cycle / cps;
|
||||||
|
const modDepth = depthfrequency ?? (depth ?? 1) * frequency;
|
||||||
const lfoValues = {
|
const lfoValues = {
|
||||||
depth: (depth ?? 1) * frequency,
|
depth: modDepth,
|
||||||
dcoffset,
|
dcoffset,
|
||||||
skew,
|
skew,
|
||||||
shape,
|
shape,
|
||||||
|
|
|
||||||
|
|
@ -553,6 +553,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
rate: 'lprate',
|
rate: 'lprate',
|
||||||
sync: 'lpsync',
|
sync: 'lpsync',
|
||||||
depth: 'lpdepth',
|
depth: 'lpdepth',
|
||||||
|
depthfrequency: 'lpdepthfrequency',
|
||||||
shape: 'lpshape',
|
shape: 'lpshape',
|
||||||
dcoffset: 'lpdc',
|
dcoffset: 'lpdc',
|
||||||
skew: 'lpskew',
|
skew: 'lpskew',
|
||||||
|
|
@ -581,13 +582,14 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
rate: 'hprate',
|
rate: 'hprate',
|
||||||
sync: 'hpsync',
|
sync: 'hpsync',
|
||||||
depth: 'hpdepth',
|
depth: 'hpdepth',
|
||||||
|
depthfrequency: 'hpdepthfrequency',
|
||||||
shape: 'hpshape',
|
shape: 'hpshape',
|
||||||
dcoffset: 'hpdc',
|
dcoffset: 'hpdc',
|
||||||
skew: 'hpskew',
|
skew: 'hpskew',
|
||||||
};
|
};
|
||||||
const hpParams = pickAndRename(value, hpMap);
|
const hpParams = pickAndRename(value, hpMap);
|
||||||
hpParams.type = 'highpass';
|
hpParams.type = 'highpass';
|
||||||
let hp = () => createFilter(ac, t, end, hpParams, cps);
|
let hp = () => createFilter(ac, t, end, hpParams, cps, cycle);
|
||||||
chain.push(hp());
|
chain.push(hp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(hp());
|
chain.push(hp());
|
||||||
|
|
@ -609,13 +611,14 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||||
rate: 'bprate',
|
rate: 'bprate',
|
||||||
sync: 'bpsync',
|
sync: 'bpsync',
|
||||||
depth: 'bpdepth',
|
depth: 'bpdepth',
|
||||||
|
depthfrequency: 'bpdepthfrequency',
|
||||||
shape: 'bpshape',
|
shape: 'bpshape',
|
||||||
dcoffset: 'bpdc',
|
dcoffset: 'bpdc',
|
||||||
skew: 'bpskew',
|
skew: 'bpskew',
|
||||||
};
|
};
|
||||||
const bpParams = pickAndRename(value, bpMap);
|
const bpParams = pickAndRename(value, bpMap);
|
||||||
bpParams.type = 'bandpass';
|
bpParams.type = 'bandpass';
|
||||||
let bp = () => createFilter(ac, t, end, bpParams, cps);
|
let bp = () => createFilter(ac, t, end, bpParams, cps, cycle);
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
if (ftype === '24db') {
|
if (ftype === '24db') {
|
||||||
chain.push(bp());
|
chain.push(bp());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue