Change audioSource.pan to audioSource.position
This commit is contained in:
@@ -4,6 +4,7 @@ package lime.audio;
|
|||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
import lime.app.Event;
|
import lime.app.Event;
|
||||||
import lime.audio.openal.AL;
|
import lime.audio.openal.AL;
|
||||||
|
import lime.math.Vector4;
|
||||||
|
|
||||||
#if flash
|
#if flash
|
||||||
import flash.media.SoundChannel;
|
import flash.media.SoundChannel;
|
||||||
@@ -35,13 +36,14 @@ class AudioSource {
|
|||||||
public var length (get, set):Int;
|
public var length (get, set):Int;
|
||||||
public var loops (get, set):Int;
|
public var loops (get, set):Int;
|
||||||
public var offset:Int;
|
public var offset:Int;
|
||||||
public var pan (get, set):Float;
|
public var position (get, set):Vector4;
|
||||||
|
|
||||||
private var id:UInt;
|
private var id:UInt;
|
||||||
private var playing:Bool;
|
private var playing:Bool;
|
||||||
private var pauseTime:Int;
|
private var pauseTime:Int;
|
||||||
private var __length:Null<Int>;
|
private var __length:Null<Int>;
|
||||||
private var __loops:Int;
|
private var __loops:Int;
|
||||||
|
private var __position:Vector4;
|
||||||
|
|
||||||
#if flash
|
#if flash
|
||||||
private var channel:SoundChannel;
|
private var channel:SoundChannel;
|
||||||
@@ -69,6 +71,8 @@ class AudioSource {
|
|||||||
this.loops = loops;
|
this.loops = loops;
|
||||||
id = 0;
|
id = 0;
|
||||||
|
|
||||||
|
__position = new Vector4 ();
|
||||||
|
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
|
|
||||||
init ();
|
init ();
|
||||||
@@ -639,70 +643,52 @@ class AudioSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_pan ():Float {
|
private function get_position ():Vector4 {
|
||||||
|
|
||||||
#if html5
|
#if html5
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#elseif flash
|
#elseif flash
|
||||||
|
|
||||||
return channel.soundTransform.pan;
|
__position.x = channel.soundTransform.pan;
|
||||||
|
|
||||||
#elseif lime_console
|
#elseif lime_console
|
||||||
|
|
||||||
//if (channel.valid) {
|
|
||||||
//
|
|
||||||
//__gain = channel.getVolume ();
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return __gain;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return AL.getSource3f (id, AL.POSITION)[0];
|
var value = AL.getSource3f (id, AL.POSITION);
|
||||||
|
__position.x = value[0];
|
||||||
|
__position.y = value[1];
|
||||||
|
__position.z = value[2];
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
return __position;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function set_pan (value:Float):Float {
|
private function set_position (value:Vector4):Vector4 {
|
||||||
|
|
||||||
|
__position.x = value.x;
|
||||||
|
__position.y = value.y;
|
||||||
|
__position.z = value.z;
|
||||||
|
__position.w = value.w;
|
||||||
|
|
||||||
#if html5
|
#if html5
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#elseif flash
|
#elseif flash
|
||||||
|
|
||||||
var soundTransform = channel.soundTransform;
|
var soundTransform = channel.soundTransform;
|
||||||
soundTransform.pan = value;
|
soundTransform.pan = __position.x;
|
||||||
channel.soundTransform = soundTransform;
|
channel.soundTransform = soundTransform;
|
||||||
return value;
|
|
||||||
|
|
||||||
#elseif lime_console
|
#elseif lime_console
|
||||||
|
|
||||||
//if (channel.valid) {
|
|
||||||
//
|
|
||||||
//channel.setVolume (value);
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return __gain = value;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
AL.distanceModel (AL.NONE);
|
AL.distanceModel (AL.NONE);
|
||||||
AL.source3f (id, AL.POSITION, value, 0, -1 * Math.sqrt (1 - Math.pow (value, 2)));
|
AL.source3f (id, AL.POSITION, __position.x, __position.y, __position.z);
|
||||||
return value;
|
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
return __position;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user