Trying out alias approach
This commit is contained in:
parent
e4466082eb
commit
b73f624058
2 changed files with 82 additions and 62 deletions
|
|
@ -2097,7 +2097,8 @@ export const { envAttack, envatt, envattack } = registerControl('envAttack', 'en
|
||||||
* .envDepth("4800:400")
|
* .envDepth("4800:400")
|
||||||
* .envTarget("source:lpf")
|
* .envTarget("source:lpf")
|
||||||
* .envParam("detune:frequency")
|
* .envParam("detune:frequency")
|
||||||
* .envDecay("0.03:0.15").envCurve("exp:exp")
|
* .envDecay("0.03:0.15")
|
||||||
|
* .envDCurve(-0.4)
|
||||||
*/
|
*/
|
||||||
export const { envDecay, envdec, envdecay } = registerControl('envDecay', 'envdec', 'envdecay');
|
export const { envDecay, envdec, envdecay } = registerControl('envDecay', 'envdec', 'envdecay');
|
||||||
|
|
||||||
|
|
@ -2112,7 +2113,7 @@ export const { envDecay, envdec, envdecay } = registerControl('envDecay', 'envde
|
||||||
* .envDepth("4800:400")
|
* .envDepth("4800:400")
|
||||||
* .envTarget("source:lpf")
|
* .envTarget("source:lpf")
|
||||||
* .envParam("detune:frequency")
|
* .envParam("detune:frequency")
|
||||||
* .envDecay("0.03:0.15").envCurve("exp:exp")
|
* .envACurve(0.6).envDCurve(-0.2)
|
||||||
* .envSustain(0.2)
|
* .envSustain(0.2)
|
||||||
*/
|
*/
|
||||||
export const { envSustain, envs, envsustain } = registerControl('envSustain', 'envs', 'envsustain');
|
export const { envSustain, envs, envsustain } = registerControl('envSustain', 'envs', 'envsustain');
|
||||||
|
|
@ -2129,29 +2130,12 @@ export const { envSustain, envs, envsustain } = registerControl('envSustain', 'e
|
||||||
* .envDepth("4800:400")
|
* .envDepth("4800:400")
|
||||||
* .envTarget("source:lpf")
|
* .envTarget("source:lpf")
|
||||||
* .envParam("detune:frequency")
|
* .envParam("detune:frequency")
|
||||||
* .envDecay("0.03:0.15").envCurve("exp:exp")
|
* .envDecay("0.03:0.15").envRCurve(0.5)
|
||||||
* .envSustain(0.5)
|
* .envSustain(0.5)
|
||||||
* .envRelease(3)
|
* .envRelease(3)
|
||||||
*/
|
*/
|
||||||
export const { envRelease, envr, envrelease } = registerControl('envRelease', 'envr', 'envrelease');
|
export const { envRelease, envr, envrelease } = registerControl('envRelease', 'envr', 'envrelease');
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects the style of envelope: `exp` or `lin` (exponential or linear).
|
|
||||||
*
|
|
||||||
* @name envCurve
|
|
||||||
* @synonyms envc, envcurve
|
|
||||||
* @param {string | Pattern} envCurve Envelope curve style.
|
|
||||||
* @example
|
|
||||||
* n(irand(12).seg(8)).scale("F#3:minor").room(1)
|
|
||||||
* .lpf(100).release(2)
|
|
||||||
* .envTarget("source:lpf")
|
|
||||||
* .envParam("detune:frequency")
|
|
||||||
* .envDepth("500:4000")
|
|
||||||
* .envDecay("0.3:0.15")
|
|
||||||
* .envCurve("lin:exp")
|
|
||||||
*/
|
|
||||||
export const { envCurve, envc, envcurve } = registerControl('envCurve', 'envc', 'envcurve');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the modulation depth of the envelope.
|
* Sets the modulation depth of the envelope.
|
||||||
*
|
*
|
||||||
|
|
@ -2167,6 +2151,36 @@ export const { envCurve, envc, envcurve } = registerControl('envCurve', 'envc',
|
||||||
*/
|
*/
|
||||||
export const { envDepth, envd, envdepth } = registerControl('envDepth', 'envd', 'envdepth');
|
export const { envDepth, envd, envdepth } = registerControl('envDepth', 'envd', 'envdepth');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the curvature of the attack portion of the envelope. Positive values are snappy,
|
||||||
|
* negative values are slow
|
||||||
|
*
|
||||||
|
* @name envACurve
|
||||||
|
* @synonyms envac, envacurve
|
||||||
|
* @param {number | Pattern} envACurve Curvature amount (between -1 and 1).
|
||||||
|
*/
|
||||||
|
export const { envACurve, envac, envacurve } = registerControl('envACurve', 'envac', 'envacurve');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the curvature of the decay portion of the envelope. Positive values are snappy,
|
||||||
|
* negative values are slow
|
||||||
|
*
|
||||||
|
* @name envDCurve
|
||||||
|
* @synonyms envdc, envdcurve
|
||||||
|
* @param {number | Pattern} envDCurve Curvature amount (between -1 and 1).
|
||||||
|
*/
|
||||||
|
export const { envDCurve, envdc, envdcurve } = registerControl('envDCurve', 'envdc', 'envdcurve');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the curvature of the release portion of the envelope. Positive values are snappy,
|
||||||
|
* negative values are slow
|
||||||
|
*
|
||||||
|
* @name envRCurve
|
||||||
|
* @synonyms envrc, envrcurve
|
||||||
|
* @param {number | Pattern} envRCurve Curvature amount (between -1 and 1).
|
||||||
|
*/
|
||||||
|
export const { envRCurve, envrc, envrcurve } = registerControl('envRCurve', 'envrc', 'envrcurve');
|
||||||
|
|
||||||
// TODO: slide param for certain synths
|
// TODO: slide param for certain synths
|
||||||
export const { slide } = registerControl('slide');
|
export const { slide } = registerControl('slide');
|
||||||
// TODO: detune? https://tidalcycles.org/docs/patternlib/tutorials/synthesizers/#supersquare
|
// TODO: detune? https://tidalcycles.org/docs/patternlib/tutorials/synthesizers/#supersquare
|
||||||
|
|
|
||||||
|
|
@ -3688,42 +3688,43 @@ export const phases = (list) => {
|
||||||
return _ensureListPattern(list).as('phases');
|
return _ensureListPattern(list).as('phases');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
const configAliases = new Map();
|
||||||
* Selects which LFO number to use for modulation. Multiple LFOs
|
const addConfigAlias = (funcName, canonical, ...aliases) => {
|
||||||
* can be applied using the ':' mininotation. There are an arbitrary number
|
const lowerFunc = String(funcName).toLowerCase();
|
||||||
* of LFOs available -- the number is only used to share LFOs across targets
|
const aliasMap = configAliases.get(lowerFunc) ?? new Map();
|
||||||
* if desired (and to conserve processing power)
|
const allKeys = new Set([canonical, ...aliases]);
|
||||||
*
|
for (const alias of allKeys) {
|
||||||
* @name lfoNum
|
aliasMap.set(String(alias).toLowerCase(), canonical);
|
||||||
* @param {number | Pattern} lfoNum Index of the LFO.
|
}
|
||||||
* setup: note("F2").sound("supersaw")
|
configAliases.set(lowerFunc, aliasMap);
|
||||||
* .lpf(100)
|
};
|
||||||
* .lfoDepth(1000)
|
|
||||||
* .lfoRate(0.25)
|
|
||||||
* .lfoSynced(1)
|
|
||||||
* .lfoTarget("lpf")
|
|
||||||
* .lfoParam("frequency")
|
|
||||||
* .lfoNum(2)
|
|
||||||
*
|
|
||||||
* reuse: note("F3").sound("square").lpf(50)
|
|
||||||
* .lfoTarget("lpf")
|
|
||||||
* .lfoParam("frequency")
|
|
||||||
* .lfoNum(2) // uses the same LFO
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
const resolveConfigKey = (funcName, key) => {
|
||||||
* Sets the target destination for the envelope modulation. Names are typically related
|
const aliasMap = configAliases.get(String(funcName).toLowerCase());
|
||||||
* to existing controls ("source", "lpf", "vibrato", etc.). You can try a value
|
if (!aliasMap) return key;
|
||||||
* and if it fails, the console will print the available options.
|
const normalized = String(key).toLowerCase();
|
||||||
*
|
return aliasMap.get(normalized) ?? key;
|
||||||
* @name envTarget
|
};
|
||||||
* @param {number | Pattern} envTarget Target identifier for modulation.
|
|
||||||
* n(irand(12).seg(8)).scale("F#3:minor").room(1)
|
addConfigAlias('lfo', 'lfoTarget', 'lfot', 'lfotarget', 'target', 't');
|
||||||
* .lpf(100)
|
addConfigAlias('lfo', 'lfoParam', 'lfop', 'lfoparam', 'param', 'parameter', 'p');
|
||||||
* .envDepth("4800:400")
|
addConfigAlias('lfo', 'lfoRate', 'lfor', 'lforate', 'rate', 'r');
|
||||||
* .envTarget("source:lpf")
|
addConfigAlias('lfo', 'lfoDepth', 'lfod', 'lfodepth', 'depth', 'd');
|
||||||
* .envParam("detune:frequency")
|
addConfigAlias('lfo', 'lfoDCOffset', 'lfodc', 'lfodcoffset', 'dcoffset', 'offset', 'dc');
|
||||||
*/
|
addConfigAlias('lfo', 'lfoShape', 'lfosh', 'lfoshape', 'shape', 'sh');
|
||||||
|
addConfigAlias('lfo', 'lfoSkew', 'lfosk', 'lfoskew', 'skew', 'sk');
|
||||||
|
addConfigAlias('lfo', 'lfoCurve', 'lfoc', 'lfocurve', 'curve', 'c');
|
||||||
|
addConfigAlias('lfo', 'lfoSync', 'lfos', 'lfosync', 'sync', 'synced', 's');
|
||||||
|
addConfigAlias('env', 'envTarget', 'envt', 'envtarget');
|
||||||
|
addConfigAlias('env', 'envParam', 'envp', 'envparam');
|
||||||
|
addConfigAlias('env', 'envAttack', 'envatt', 'envattack');
|
||||||
|
addConfigAlias('env', 'envDecay', 'envdec', 'envdecay');
|
||||||
|
addConfigAlias('env', 'envSustain', 'envs', 'envsustain');
|
||||||
|
addConfigAlias('env', 'envRelease', 'envr', 'envrelease');
|
||||||
|
addConfigAlias('env', 'envDepth', 'envd', 'envdepth');
|
||||||
|
addConfigAlias('env', 'envACurve', 'envac', 'envacurve');
|
||||||
|
addConfigAlias('env', 'envDCurve', 'envdc', 'envdcurve');
|
||||||
|
addConfigAlias('env', 'envRCurve', 'envrc', 'envrcurve');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes a signal chain. Can be called in sequence like pat.chain(...).chain(...) and so forth
|
* Establishes a signal chain. Can be called in sequence like pat.chain(...).chain(...) and so forth
|
||||||
|
|
@ -3738,12 +3739,17 @@ export const phases = (list) => {
|
||||||
* @param {Pattern | Pattern[]} patterns Patterns to combine into a single chain
|
* @param {Pattern | Pattern[]} patterns Patterns to combine into a single chain
|
||||||
* @returns Pattern
|
* @returns Pattern
|
||||||
*/
|
*/
|
||||||
Pattern.prototype.chain = function (...pats) {
|
Pattern.prototype.lfo = function (config) {
|
||||||
pats = pats.map(reify);
|
if (config == null || typeof config !== 'object') {
|
||||||
return this.withValue((v) => (vEff) => {
|
return this;
|
||||||
const currChain = v.chain ?? [];
|
}
|
||||||
return { ...v, chain: currChain.concat(vEff) };
|
let output = this;
|
||||||
}).appLeft(parray(pats));
|
for (const [rawKey, value] of Object.entries(config)) {
|
||||||
|
const key = resolveConfigKey('lfo', rawKey);
|
||||||
|
const pat = reify(value);
|
||||||
|
output = output.set(pat.as(key));
|
||||||
|
}
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const chain = (pats) => pure({}).chain(pats);
|
export const lfo = (config) => pure({}).lfo(config);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue