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