Skip to content

Commit 905e8ae

Browse files
authored
Merge pull request #34 from rpgtkoolmv/fix_fadein
fix can't change volume after it fadein
2 parents 603ed88 + f4d260f commit 905e8ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/rpg_core/WebAudio.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ WebAudio._createMasterGainNode = function() {
112112
var context = WebAudio._context;
113113
if (context) {
114114
this._masterGainNode = context.createGain();
115-
this._masterGainNode.gain.value = 1;
115+
this._masterGainNode.gain.setValueAtTime(1, context.currentTime);
116116
this._masterGainNode.connect(context.destination);
117117
}
118118
};
@@ -278,7 +278,7 @@ Object.defineProperty(WebAudio.prototype, 'volume', {
278278
set: function(value) {
279279
this._volume = value;
280280
if (this._gainNode) {
281-
this._gainNode.gain.value = this._volume;
281+
this._gainNode.gain.setValueAtTime(this._volume, WebAudio._context.currentTime);
282282
}
283283
},
284284
configurable: true
@@ -539,9 +539,9 @@ WebAudio.prototype._createNodes = function() {
539539
this._sourceNode.buffer = this._buffer;
540540
this._sourceNode.loopStart = this._loopStart;
541541
this._sourceNode.loopEnd = this._loopStart + this._loopLength;
542-
this._sourceNode.playbackRate.value = this._pitch;
542+
this._sourceNode.playbackRate.setValueAtTime(this._pitch, context.currentTime);
543543
this._gainNode = context.createGain();
544-
this._gainNode.gain.value = this._volume;
544+
this._gainNode.gain.setValueAtTime(this._volume, context.currentTime);
545545
this._pannerNode = context.createPanner();
546546
this._pannerNode.panningModel = 'equalpower';
547547
this._updatePanner();

0 commit comments

Comments
 (0)