diff --git a/src/lime/_internal/backend/html5/HTML5AudioSource.hx b/src/lime/_internal/backend/html5/HTML5AudioSource.hx index bde1499be..f2b9fe80b 100644 --- a/src/lime/_internal/backend/html5/HTML5AudioSource.hx +++ b/src/lime/_internal/backend/html5/HTML5AudioSource.hx @@ -26,7 +26,23 @@ class HTML5AudioSource public function dispose():Void {} - public function init():Void {} + public function init():Void + { + #if lime_howlerjs + // Initialize the panner with default values + parent.buffer.src.pannerAttr( + { + coneInnerAngle: 360, + coneOuterAngle: 360, + coneOuterGain: 0, + distanceModel: "inverse", + maxDistance: 10000, + refDistance: 1, + rolloffFactor: 1, + panningModel: "equalpower" // Default to equalpower for better performance + }); + #end + } public function play():Void { @@ -218,10 +234,9 @@ class HTML5AudioSource #if lime_howlerjs parent.buffer.__srcHowl.rate(value); #end - + return getPitch(); } - public function getPosition():Vector4 { diff --git a/src/lime/media/howlerjs/Howl.hx b/src/lime/media/howlerjs/Howl.hx index 60f659f7b..aa1235fb5 100644 --- a/src/lime/media/howlerjs/Howl.hx +++ b/src/lime/media/howlerjs/Howl.hx @@ -216,6 +216,40 @@ class Howl { return null; } + + /** + * Get/set the panner node's attributes for a sound or group of sounds. This method can optionally take 0, 1 or 2 arguments. + * pannerAttr() -> Returns the group's values. + * pannerAttr(id) -> Returns the sound id's values. + * pannerAttr(o) -> Set's the values of all sounds in this Howl group. + * pannerAttr(o, id) -> Set's the values of passed sound id. + * + * Attributes: + * coneInnerAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees, + * inside of which there will be no volume reduction. + * coneOuterAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees, + * outside of which the volume will be reduced to a constant value of coneOuterGain. + * coneOuterGain - (0 by default) A parameter for directional audio sources, this is the gain outside of the + * coneOuterAngle. It is a linear value in the range [0, 1]. + * distanceModel - ('inverse' by default) Determines algorithm used to reduce volume as audio moves away from + * listener. Can be linear, inverse or `exponential. + * maxDistance - (10000 by default) The maximum distance between source and listener, after which the volume + * will not be reduced any further. + * refDistance - (1 by default) A reference distance for reducing volume as source moves further from the listener. + * This is simply a variable of the distance model and has a different effect depending on which model + * is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance. + * rolloffFactor - (1 by default) How quickly the volume reduces as source moves from listener. This is simply a + * variable of the distance model and can be in the range of [0, 1] with linear and [0, ∞] + * with inverse and exponential. + * panningModel - ('HRTF' by default) Determines which spatialization algorithm is used to position audio. + * Can be HRTF or equalpower. + * + * @return Returns self or current panner attributes. + */ + public function pannerAttr(args:PannerAttr, ?id:Int):Howl + { + return this; + } } #else import haxe.Constraints.Function; @@ -267,6 +301,7 @@ extern class Howl @:overload(function(x:Float, y:Float, z:Float):Howl {}) @:overload(function(x:Float, y:Float, z:Float, id:Int):Howl {}) public function pos():Array; + public function pannerAttr(args:PannerAttr, ?id:Int):Howl; } #end @@ -295,4 +330,16 @@ typedef HowlOptions = ?onseek:Function, ?onfade:Function } + +typedef PannerAttr = +{ + ?coneInnerAngle:Float, + ?coneOuterAngle:Float, + ?coneOuterGain:Float, + ?distanceModel:String, + ?maxDistance:Float, + ?refDistance:Float, + ?rolloffFactor:Float, + ?panningModel:String +} #end