goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.74k stars 2.22k forks source link

pos is delayed by half a second #836

Closed johnsmith1243 closed 4 years ago

johnsmith1243 commented 6 years ago

I am trying to set the position of an audio file ("wind"). When I activate the audio files, the audio files plays for a half a second without any set position, and then suddenly changes to the position I have set (1, 0, 1) after half a second. Is there a way to fix this?

    function wind(){
     var wind = new Howl({
     src: ['wind.ogg'],
     loop: true,
     volume: 0

    });

  wind.pos(1, 0, 1);
  wind.play();
  wind.fade(0, 1, 1000);

  }
micktaiwan commented 6 years ago

Same problem here with stereo() It seems that stereo takes time to be activated as if a panning nob were turned slowly.

Even using a event listener.

    const self = this;
    this.sounds[name].stereo(stereo).once('stereo', function() {
      self.sounds[name].play();
    });
goldfire commented 6 years ago

Do you have a test case showing this happening? I'm not seeing this behavior in the tests (https://howlerjs.com/#basic) or in our games.

goldfire commented 4 years ago

Closing due to inactivity. If this is still an issue, reply with more info and I'll reopen.

johnsmith1324 commented 3 years ago

I recently had this problem again and figured out a workaround. If you place .pos inside of a function it is delayed half a second the first time the sound is played. If you place .pos outside of the function it works fine, and then you can change the position further without delay. The delay seems to only occur if you try to determine the .pos at the same time as playing the sound. This is what worked for me:

     var sound = new Howl({
     src: ['sound.ogg'],
     loop: true,
     volume: 1
    });

{sound.pos(1, 0, 1);}

function playsound() {
sound.play();
}