openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
754 stars 370 forks source link

Support pannerAttr for Howler sounds + improve performance #1788

Open DigiEggz opened 4 months ago

DigiEggz commented 4 months ago

Exposes the pannerAttr field, which allows panner values to be set. By setting the panningModel to "equalpower", which results in crisp sound within Howler, resolving the problem mentioned in https://github.com/goldfire/howler.js/issues/112.

The processing performance of "equalpower" is notable compared to HRTF: https://padenot.github.io/web-audio-perf/#pannernode-when-panningmodel--hrtf

In the future, panner attributes can be passed within the HTML5AudioSource play() function, or anywhere after the sound is active. It could also make sense to set a global pannerAttr that is referenced within the init() function.

public function play():Void
{
    …
    id = parent.buffer.__srcHowl.play();

    untyped parent.buffer.__srcHowl._volume = cacheVolume;
    parent.buffer.__srcHowl.pannerAttr({coneInnerAngle: 50, panningModel: "HRTF”});) // An example of passing two new panner attributes
    // setGain (parent.gain);
    …
}