mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-22 14:02:29 -05:00
New name and value for DECAY_TIME
This commit is contained in:
parent
1c8a545a8a
commit
734f976585
2 changed files with 7 additions and 9 deletions
|
@ -41,8 +41,8 @@ class PanEffect {
|
||||||
const leftVal = Math.cos(p * Math.PI / 2);
|
const leftVal = Math.cos(p * Math.PI / 2);
|
||||||
const rightVal = Math.sin(p * Math.PI / 2);
|
const rightVal = Math.sin(p * Math.PI / 2);
|
||||||
|
|
||||||
this.leftGain.gain.setTargetAtTime(leftVal, 0, this.audioEngine.ONE_THIRD_FRAME);
|
this.leftGain.gain.setTargetAtTime(leftVal, 0, this.audioEngine.DECAY_TIME);
|
||||||
this.rightGain.gain.setTargetAtTime(rightVal, 0, this.audioEngine.ONE_THIRD_FRAME);
|
this.rightGain.gain.setTargetAtTime(rightVal, 0, this.audioEngine.DECAY_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
12
src/index.js
12
src/index.js
|
@ -122,7 +122,7 @@ class AudioPlayer {
|
||||||
this.panEffect.set(0);
|
this.panEffect.set(0);
|
||||||
this.pitchEffect.set(0, this.activeSoundPlayers);
|
this.pitchEffect.set(0, this.activeSoundPlayers);
|
||||||
if (this.audioEngine === null) return;
|
if (this.audioEngine === null) return;
|
||||||
this.effectsNode.gain.setTargetAtTime(1.0, 0, this.audioEngine.ONE_THIRD_FRAME);
|
this.effectsNode.gain.setTargetAtTime(1.0, 0, this.audioEngine.DECAY_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,7 @@ class AudioPlayer {
|
||||||
*/
|
*/
|
||||||
setVolume (value) {
|
setVolume (value) {
|
||||||
if (this.audioEngine === null) return;
|
if (this.audioEngine === null) return;
|
||||||
this.effectsNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.ONE_THIRD_FRAME);
|
this.effectsNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,15 +167,13 @@ class AudioEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The duration in seconds of one third of one frame, at 30 frames per second.
|
* A short duration, for use as a time constant for exponential audio parameter transitions.
|
||||||
* This is useful for setting web audio time constants. For example, in order for
|
|
||||||
* a gain to reach 95% of its target value in one frame, use this time constant.
|
|
||||||
* See:
|
* See:
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/setTargetAtTime
|
* https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/setTargetAtTime
|
||||||
* @const {number}
|
* @const {number}
|
||||||
*/
|
*/
|
||||||
get ONE_THIRD_FRAME () {
|
get DECAY_TIME () {
|
||||||
return (1 / 30) / 3;
|
return 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue