Răsfoiți Sursa

Audio: Fix usage of detune

Mugen87 6 ani în urmă
părinte
comite
7db59ab8cb
1 a modificat fișierele cu 4 adăugiri și 8 ștergeri
  1. 4 8
      src/audio/Audio.js

+ 4 - 8
src/audio/Audio.js

@@ -95,10 +95,8 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 		var source = this.context.createBufferSource();
 
 		source.buffer = this.buffer;
-		this.setDetune( this.detune );
 		source.loop = this.loop;
 		source.onended = this.onEnded.bind( this );
-		source.playbackRate.setValueAtTime( this.playbackRate, this.startTime );
 		this.startTime = this.context.currentTime;
 		source.start( this.startTime, this.offset );
 
@@ -106,6 +104,9 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		this.source = source;
 
+		this.setDetune( this.detune );
+		this.setPlaybackRate( this.playbackRate );
+
 		return this.connect();
 
 	},
@@ -228,12 +229,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		this.detune = value;
 
-		if ( this.source.detune === undefined ) {
-
-			console.warn( 'THREE.Audio: AudioBufferSourceNode.detune not supported by the browser.' );
-			return;
-
-		}
+		if ( this.source.detune === undefined ) return; // only set detune when available
 
 		if ( this.isPlaying === true ) {