Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/audio/Audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
var source = this.context.createBufferSource();

source.buffer = this.buffer;
source.detune.value = this.detune;
this.setDetune( this.detune );
Copy link
Collaborator

@Mugen87 Mugen87 Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a problem if you set detune like this. Since isPlaying is still false at this line, the value is actually not assigned to the AudioBufferSourceNode.

Copy link
Owner

@mrdoob mrdoob Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely worth investigating, but I'll merge this for now so we no longer break in iOS 12.

source.loop = this.loop;
source.onended = this.onEnded.bind( this );
source.playbackRate.setValueAtTime( this.playbackRate, this.startTime );
Expand Down Expand Up @@ -228,6 +228,13 @@ 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.isPlaying === true ) {

this.source.detune.setTargetAtTime( this.detune, this.context.currentTime, 0.01 );
Expand Down