console: implement AudioSource.gain
This commit is contained in:
@@ -46,6 +46,7 @@ class AudioSource {
|
|||||||
private var channel:SoundChannel;
|
private var channel:SoundChannel;
|
||||||
#elseif lime_console
|
#elseif lime_console
|
||||||
private var channel:FMODChannel;
|
private var channel:FMODChannel;
|
||||||
|
private var __gain:Float = 1.0;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if (cpp || neko || nodejs)
|
#if (cpp || neko || nodejs)
|
||||||
@@ -164,7 +165,10 @@ class AudioSource {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
channel = buffer.src.play ();
|
channel = buffer.src.play ();
|
||||||
channel.setLoopCount (this.__loops);
|
channel.setLoopCount (__loops);
|
||||||
|
if (__gain < 1.0) {
|
||||||
|
channel.setVolume (__gain);
|
||||||
|
}
|
||||||
|
|
||||||
var old = setFmodActive (channel, this);
|
var old = setFmodActive (channel, this);
|
||||||
|
|
||||||
@@ -484,8 +488,13 @@ class AudioSource {
|
|||||||
|
|
||||||
#elseif lime_console
|
#elseif lime_console
|
||||||
|
|
||||||
lime.Lib.notImplemented ("AudioSource.get_gain");
|
if (channel.valid) {
|
||||||
return 1;
|
|
||||||
|
__gain = channel.getVolume ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gain;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -511,8 +520,13 @@ class AudioSource {
|
|||||||
|
|
||||||
#elseif lime_console
|
#elseif lime_console
|
||||||
|
|
||||||
lime.Lib.notImplemented ("AudioSource.set_gain");
|
if (channel.valid) {
|
||||||
return value;
|
|
||||||
|
channel.setVolume (value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gain = value;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ extern class FMODChannel {
|
|||||||
// setLoopCount sets the channel to loop count times before stopping.
|
// setLoopCount sets the channel to loop count times before stopping.
|
||||||
public function setLoopCount (count:Int):Void;
|
public function setLoopCount (count:Int):Void;
|
||||||
|
|
||||||
|
// getVolume retrieves the current linear volume level of the channel.
|
||||||
|
public function getVolume ():cpp.Float32;
|
||||||
|
|
||||||
|
// setVolume sets the channel's linear volume level.
|
||||||
|
public function setVolume (volume:cpp.Float32):Void;
|
||||||
|
|
||||||
|
|
||||||
// INVALID represents an invalid channel handle
|
// INVALID represents an invalid channel handle
|
||||||
public static var INVALID (get, never):FMODChannel;
|
public static var INVALID (get, never):FMODChannel;
|
||||||
|
|||||||
Reference in New Issue
Block a user