mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-06-14 13:50:30 -04:00
Merge pull request #118 from adroitwhiz/fix-volume-stutter
Don't setValueAtTime in volume effect
This commit is contained in:
commit
b279a63e70
3 changed files with 7 additions and 11 deletions
|
@ -299,8 +299,8 @@ class SoundPlayer extends EventEmitter {
|
|||
taken.finished().then(() => taken.dispose());
|
||||
|
||||
taken.volumeEffect.set(0);
|
||||
const {currentTime, DECAY_WAIT, DECAY_DURATION} = this.audioEngine;
|
||||
taken.outputNode.stop(currentTime + DECAY_WAIT + DECAY_DURATION);
|
||||
const {currentTime, DECAY_DURATION} = this.audioEngine;
|
||||
taken.outputNode.stop(currentTime + DECAY_DURATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,9 +42,8 @@ class VolumeEffect extends Effect {
|
|||
this.value = value;
|
||||
|
||||
const {gain} = this.outputNode;
|
||||
const {currentTime, DECAY_WAIT, DECAY_DURATION} = this.audioEngine;
|
||||
gain.setValueAtTime(gain.value, currentTime + DECAY_WAIT);
|
||||
gain.linearRampToValueAtTime(value / 100, currentTime + DECAY_WAIT + DECAY_DURATION);
|
||||
const {currentTime, DECAY_DURATION} = this.audioEngine;
|
||||
gain.linearRampToValueAtTime(value / 100, currentTime + DECAY_DURATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,7 +71,7 @@ tap.test('SoundPlayer', suite => {
|
|||
});
|
||||
|
||||
suite.test('stop decay', t => {
|
||||
t.plan(7);
|
||||
t.plan(5);
|
||||
soundPlayer.play();
|
||||
soundPlayer.connect(audioEngine);
|
||||
const outputNode = soundPlayer.outputNode;
|
||||
|
@ -88,13 +88,10 @@ tap.test('SoundPlayer', suite => {
|
|||
inputs: [outputNode.toJSON()]
|
||||
}], 'output node connects to gain node to input node');
|
||||
|
||||
audioContext.$processTo(audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION / 2);
|
||||
const engineInputs = help.engineInputs;
|
||||
t.notEqual(engineInputs[0].gain.value, 1, 'gain value should not be 1');
|
||||
t.notEqual(engineInputs[0].gain.value, 0, 'gain value should not be 0');
|
||||
audioContext.$processTo(audioEngine.DECAY_DURATION / 2);
|
||||
t.equal(outputNode.$state, 'PLAYING');
|
||||
|
||||
audioContext.$processTo(audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.001);
|
||||
audioContext.$processTo(audioEngine.DECAY_DURATION + 0.001);
|
||||
t.deepEqual(help.engineInputs, [{
|
||||
name: 'GainNode',
|
||||
gain: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue