Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f037d5c

Browse files
committedJan 25, 2024
fixed envelope logic
1 parent b82a849 commit f037d5c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎step-sequencer/index.html

+4-5
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ <h2>DTMF</h2>
216216
attackControl.addEventListener(
217217
"input",
218218
(ev) => {
219-
attackTime = parseInt(ev.target.value, 10);
219+
attackTime = parseFloat(ev.target.value);
220220
},
221221
false
222222
);
@@ -226,13 +226,12 @@ <h2>DTMF</h2>
226226
releaseControl.addEventListener(
227227
"input",
228228
(ev) => {
229-
releaseTime = parseInt(ev.target.value, 10);
229+
releaseTime = parseFloat(ev.target.value);
230230
},
231231
false
232232
);
233233

234234
// Expose attack time & release time
235-
const sweepLength = 2;
236235
function playSweep(time) {
237236
const osc = new OscillatorNode(audioCtx, {
238237
frequency: 380,
@@ -246,12 +245,12 @@ <h2>DTMF</h2>
246245
sweepEnv.gain.linearRampToValueAtTime(1, time + attackTime);
247246
sweepEnv.gain.linearRampToValueAtTime(
248247
0,
249-
time + sweepLength - releaseTime
248+
time + attackTime + releaseTime
250249
);
251250

252251
osc.connect(sweepEnv).connect(audioCtx.destination);
253252
osc.start(time);
254-
osc.stop(time + sweepLength);
253+
osc.stop(time + attackTime + releaseTime);
255254
}
256255

257256
// Expose frequency & frequency modulation

0 commit comments

Comments
 (0)
Please sign in to comment.