Skip to content

Commit

Permalink
fixed envelope logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuLintz committed Jan 25, 2024
1 parent b82a849 commit f037d5c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions step-sequencer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h2>DTMF</h2>
attackControl.addEventListener(
"input",
(ev) => {
attackTime = parseInt(ev.target.value, 10);
attackTime = parseFloat(ev.target.value);
},
false
);
Expand All @@ -226,13 +226,12 @@ <h2>DTMF</h2>
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,
Expand All @@ -246,12 +245,12 @@ <h2>DTMF</h2>
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
Expand Down

0 comments on commit f037d5c

Please sign in to comment.