Add aliases for distort types

This commit is contained in:
Aria 2025-10-01 00:36:59 -05:00
parent c5f1085bd9
commit a14bf4d97b
3 changed files with 59 additions and 12 deletions

View file

@ -3537,6 +3537,41 @@ export const morph = (frompat, topat, bypat) => {
return frompat.innerBind((from) => topat.innerBind((to) => bypat.innerBind((by) => _morph(from, to, by)))); return frompat.innerBind((from) => topat.innerBind((to) => bypat.innerBind((by) => _morph(from, to, by))));
}; };
/**
* Soft-clipping distortion
*
* @name soft
* @param {number | Pattern} distortion
*
*/
/**
* Hard-clipping distortion
*
* @name hard
* @param {number | Pattern} distortion
*
*/
/**
* Cubic polynomial distortion
*
* @name cubic
* @param {number | Pattern} distortion
*
*/
/**
* Diode-emulating distortion
*
* @name diode
* @param {number | Pattern} distortion
*
*/
/**
* Asymmetrical diode distortion
*
* @name asym
* @param {number | Pattern} distortion
*
*/
/** /**
* Wavefolding distortion * Wavefolding distortion
* *
@ -3544,13 +3579,25 @@ export const morph = (frompat, topat, bypat) => {
* @param {number | Pattern} distortion * @param {number | Pattern} distortion
* *
*/ */
export const fold = register('fold', function (amt, vol = 1, pat) { /**
return pat.withvValue((v) => { * Wavefolding distortion composed with sinusoid
return { *
...v, * @name sinefold
distortion: amt, * @param {number | Pattern} distortion
distortvol: vol, *
distorttype: 'fold', */
/**
* Distortion via Chebyshev polynomials
*
* @name chebyshev
* @param {number | Pattern} distortion
*
*/
const algoNames = ['scurve', 'soft', 'hard', 'cubic', 'diode', 'asym', 'fold', 'sinefold', 'chebyshev'];
for (const name of algoNames) {
Pattern.prototype[name] = function (args) {
const argsPat = reify(args).fmap((v) => (Array.isArray(v) ? [...v, name] : [v, 1, name]));
return this.distort(argsPat);
}; };
}).innerJoin(); }
});

View file

@ -475,7 +475,6 @@ export const getDistortionAlgorithm = (algo) => {
}; };
export const getDistortion = (distort, postgain, algorithm) => { export const getDistortion = (distort, postgain, algorithm) => {
debugger;
return getWorklet(getAudioContext(), 'distort-processor', { distort, postgain }, { processorOptions: { algorithm } }); return getWorklet(getAudioContext(), 'distort-processor', { distort, postgain }, { processorOptions: { algorithm } });
}; };

View file

@ -155,6 +155,7 @@ let defaultDefaultValues = {
phaserdepth: 0.75, phaserdepth: 0.75,
shapevol: 1, shapevol: 1,
distortvol: 1, distortvol: 1,
distorttype: 0,
delay: 0, delay: 0,
byteBeatExpression: '0', byteBeatExpression: '0',
delayfeedback: 0.5, delayfeedback: 0.5,
@ -455,7 +456,7 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
shapevol = getDefaultValue('shapevol'), shapevol = getDefaultValue('shapevol'),
distort, distort,
distortvol = getDefaultValue('distortvol'), distortvol = getDefaultValue('distortvol'),
distorttype, distorttype = getDefaultValue('distorttype'),
pan, pan,
vowel, vowel,
delay = getDefaultValue('delay'), delay = getDefaultValue('delay'),