Skip to content

Commit c68dba8

Browse files
committed
fix: use end
1 parent f99557c commit c68dba8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/superdough/sampler.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
302302
bufferSource.start(time, offset);
303303
const envGain = ac.createGain();
304304
const node = bufferSource.connect(envGain);
305-
let holdEnd = t + duration;
306305
if (clip == null && loop == null && value.release == null) {
307306
const bufferDuration = bufferSource.buffer.duration / bufferSource.playbackRate.value;
308-
holdEnd = t + bufferDuration;
307+
duration = (end - begin) * bufferDuration;
309308
}
309+
let holdEnd = t + duration;
310310

311311
getParamADSR(node.gain, attack, decay, sustain, release, 0, 1, t, holdEnd, 'linear');
312312

0 commit comments

Comments
 (0)