Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pannerAttr(o) doesn't apply passed options the first time it is called #1497

Closed
MCArth opened this issue Jul 18, 2021 · 1 comment
Closed

Comments

@MCArth
Copy link

MCArth commented Jul 18, 2021

The source of this bug is in code located in howler.spatial.js within Howl.prototype.pannerAttr

The variable pa is set to an object instead of mutated. Then, sound._panner does not exist, and the updated pa variable is discarded

See the following:

       var pa = sound._pannerAttr;
        pa = {
          coneInnerAngle: typeof o.coneInnerAngle !== 'undefined' ? o.coneInnerAngle : pa.coneInnerAngle,
          coneOuterAngle: typeof o.coneOuterAngle !== 'undefined' ? o.coneOuterAngle : pa.coneOuterAngle,
          coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : pa.coneOuterGain,
          distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : pa.distanceModel,
          maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : pa.maxDistance,
          refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : pa.refDistance,
          rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : pa.rolloffFactor,
          panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : pa.panningModel
        };

        // Update the panner values or create a new panner if none exists.
        var panner = sound._panner;
        if (panner) {
          panner.coneInnerAngle = pa.coneInnerAngle;
          panner.coneOuterAngle = pa.coneOuterAngle;
          panner.coneOuterGain = pa.coneOuterGain;
          panner.distanceModel = pa.distanceModel;
          panner.maxDistance = pa.maxDistance;
          panner.refDistance = pa.refDistance;
          panner.rolloffFactor = pa.rolloffFactor;
          panner.panningModel = pa.panningModel;
        } else {
          // Make sure we have a position to setup the node with.
          if (!sound._pos) {
            sound._pos = self._pos || [0, 0, -0.5];
          }

          // Create a new panner node.
          setupPanner(sound, 'spatial');
        }

I am calling pannerAttr directly after Howl construction, perhaps sound._panner would have existed if I had called play first.

I've worked around this by calling pannerAttr twice - which solves the issue.

Presumably this could be fixed by directly mutating sound._pannerAttr so the correct values can be used within setupPanner.

@MCArth MCArth changed the title pannerAttr(o) doesn't apply the passed options the first time it is called pannerAttr(o) doesn't apply passed options the first time it is called Jul 18, 2021
@thibka
Copy link

thibka commented Aug 12, 2021

Same issue here.

I hope @goldfire will be able to fix this, but in the meantime here's a quick fix I'm using to declare the options twice:

var sound = new Howl({
    src: ['path/to/audio.mp3')],
});
    
sound.pannerAttr({
    // your options here
});

sound.pannerAttr( sound.pannerAttr() ); // <- add this right after defining pannerAttr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants