Updated Howler to enable sound position (#1243)

Updated Howler to version 2.0.15

For what we use, we could use the "stereo()" function but as we already generated the coordinates, I settled for the "pos()" function.

My knowledge of sound isn't enough to understand where the "w" variable of the position goes (as "pos()" uses only x, y and z). My guess is that "pannerAttr()" might have the access to what we are looking for, but again I don't fully understand sound.
This commit is contained in:
miltoncandelero
2018-09-24 14:04:02 -03:00
committed by Joshua Granick
parent e10fdf0afc
commit 14f12a41da
3 changed files with 53 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@@ -280,7 +280,13 @@ class HTML5AudioSource {
#if lime_howlerjs
// TODO: Use 3D audio plugin
//This should work, but it returns null (But checking the inside of the howl, the _pos is actually null... so ¯\_(ツ)_/¯)
/*
var arr = parent.buffer.__srcHowl.pos())
position.x = arr[0];
position.y = arr[1];
position.z = arr[2];
*/
#end
@@ -298,7 +304,8 @@ class HTML5AudioSource {
#if lime_howlerjs
// TODO: Use 3D audio plugin
parent.buffer.__srcHowl.pos (position.x, position.y, position.z, id);
//There are more settings to the position of the sound on the "pannerAttr()" function of howler. Maybe somebody who understands sound should look into it?
#end

View File

@@ -237,10 +237,34 @@ class Howl {
}
/**
* Get/set the 3D spatial position of the audio source for this sound or group relative to the global listener.
* @param x The x-position of the audio source.
* @param y The y-position of the audio source.
* @param z The z-position of the audio source.
* @param id The sound ID. If none is passed, all in group will be updated.
* @return Returns self or the current 3D spatial position: [x, y, z].
*/
public function pos (?x:Float, ?y:Float, ?z:Float, ?id:Int):Dynamic {
return null;
}
/**
* Get/set the stereo panning of the audio source for this sound or all in the group.
* @param pan A value of -1.0 is all the way left and 1.0 is all the way right.
* @param id (optional) The sound ID. If none is passed, all in group will be updated.
* @return Returns self or the current stereo panning value.
*/
public function stereo (?pan:Float, ?id:Int):Dynamic {
return null;
}
}
#else
@@ -299,6 +323,15 @@ extern class Howl {
@:overload(function(vol:Float, id:Int):Howl {})
public function volume ():Float;
@:overload(function(pan:Float):Howl {})
@:overload(function(pan:Float, id:Int):Howl {})
public function stereo():Float;
@:overload(function(x:Float):Howl {})
@:overload(function(x:Float,y:Float):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<Float>;
}