From f037d5c5819b0a73edb3b78139d5c1d39058db5d Mon Sep 17 00:00:00 2001 From: Manu Lintz Date: Thu, 25 Jan 2024 16:44:37 +0100 Subject: [PATCH] fixed envelope logic --- step-sequencer/index.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/step-sequencer/index.html b/step-sequencer/index.html index f4dd837..b679bb8 100644 --- a/step-sequencer/index.html +++ b/step-sequencer/index.html @@ -216,7 +216,7 @@

DTMF

attackControl.addEventListener( "input", (ev) => { - attackTime = parseInt(ev.target.value, 10); + attackTime = parseFloat(ev.target.value); }, false ); @@ -226,13 +226,12 @@

DTMF

releaseControl.addEventListener( "input", (ev) => { - releaseTime = parseInt(ev.target.value, 10); + releaseTime = parseFloat(ev.target.value); }, false ); // Expose attack time & release time - const sweepLength = 2; function playSweep(time) { const osc = new OscillatorNode(audioCtx, { frequency: 380, @@ -246,12 +245,12 @@

DTMF

sweepEnv.gain.linearRampToValueAtTime(1, time + attackTime); sweepEnv.gain.linearRampToValueAtTime( 0, - time + sweepLength - releaseTime + time + attackTime + releaseTime ); osc.connect(sweepEnv).connect(audioCtx.destination); osc.start(time); - osc.stop(time + sweepLength); + osc.stop(time + attackTime + releaseTime); } // Expose frequency & frequency modulation