Skip to content

Commit

Permalink
Lily/SoundExpanded: fix set volume and start looping w/ start (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin authored Jun 11, 2024
1 parent 22928f9 commit 24cff03
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/Lily/SoundExpanded.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@

_startLooping(util, sound, loopStart, loopEnd) {
const index = this._getSoundIndex(sound, util);
if (index < 0) return 0;
if (index < 0) return;

const target = util.target;
const sprite = util.target.sprite;

Expand All @@ -336,9 +337,12 @@
}

if (!soundPlayer.outputNode) return;

soundPlayer.outputNode.loop = true;
soundPlayer.outputNode.loopStart = loopStart;
soundPlayer.outputNode.loopEnd = loopEnd;
// If loopEnd is the default of 0, then loopStart is ignored
soundPlayer.outputNode.loopEnd =
loopEnd || soundPlayer.outputNode.buffer.duration;
}

startLooping(args, util) {
Expand Down Expand Up @@ -565,7 +569,7 @@
}

setProjectVolume(args) {
const value = Scratch.Cast.toNumber(args.VALUE);
const value = Scratch.Cast.toNumber(args.VALUE) / 100;
const newVolume = Scratch.Cast.toNumber(Math.max(Math.min(value, 1), 0));
runtime.audioEngine.inputNode.gain.value = newVolume;
}
Expand Down

0 comments on commit 24cff03

Please sign in to comment.