From bdc2af9733574ae4fbe9817a426a943a3b9b329e Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 15 Jan 2024 23:25:22 +0100 Subject: [PATCH] basic pitch envelope --- packages/core/controls.mjs | 7 +++++++ packages/superdough/synth.mjs | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 97129779..13856608 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -891,6 +891,13 @@ const generic_params = [ * */ ['freq'], + // pitch envelope + ['pattack', 'patt'], + ['pdecay', 'pdec'], + ['psustain', 'psus'], + ['prelease', 'prel'], + ['penv'], + ['panchor'], // TODO // TODO: https://tidalcycles.org/docs/configuration/MIDIOSC/control-voltage/#gate ['gate', 'gat'], // ['hatgrain'], diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index 6a3e381a..d484284b 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -126,6 +126,12 @@ export function getOscillator( fmvelocity: fmVelocity, fmwave: fmWaveform = 'sine', duration, + penv, + // panchor = 0, // TODO + pattack, + pdecay, + psustain, + prelease, }, ) { let ac = getAudioContext(); @@ -196,6 +202,12 @@ export function getOscillator( vibratoOscillator.start(t); } + // pitch envelope + if (penv) { + const holdEnd = t + duration; + getParamADSR(o.detune, pattack, pdecay, psustain, prelease, 0, penv * 100, t, holdEnd, 'linear'); + } + let noiseMix; if (noise) { noiseMix = getNoiseMix(o, noise, t);