merge upstream

This commit is contained in:
2025-07-03 07:46:23 +00:00
9 changed files with 179 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package leenkx.logicnode;
import aura.Aura;
import aura.Types;
class GetAudioPositionNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): Dynamic {
var audio = inputs[0].get();
if (audio == null || audio.channel == null) return 0.0;
return audio.channel.floatPosition / audio.channel.sampleRate;
}
}

View File

@ -0,0 +1,33 @@
package leenkx.logicnode;
#if lnx_audio
import iron.object.SpeakerObject;
import kha.audio1.AudioChannel;
#end
class GetPositionSpeakerNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): Dynamic {
#if lnx_audio
var object: SpeakerObject = cast(inputs[0].get(), SpeakerObject);
if (object == null || object.sound == null) return 0.0;
if (object.channels.length == 0) return 0.0;
var channel = object.channels[0];
var position = 0.0;
if (channel != null) {
position = @:privateAccess channel.get_position();
}
return position;
#else
return 0.0;
#end
}
}

View File

@ -0,0 +1,23 @@
package leenkx.logicnode;
import aura.Aura;
import aura.Types;
class SetAudioPositionNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
var audio = inputs[1].get();
if (audio == null) return;
var positionInSeconds:Float = inputs[2].get();
if (positionInSeconds < 0.0) positionInSeconds = 0.0;
audio.channel.floatPosition = positionInSeconds * audio.channel.sampleRate;
runOutput(0);
}
}

View File

@ -0,0 +1,39 @@
package leenkx.logicnode;
#if lnx_audio
import iron.object.SpeakerObject;
import kha.audio1.AudioChannel;
import iron.system.Audio;
#end
class SetPositionSpeakerNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
#if lnx_audio
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
if (object == null || object.sound == null) return;
var positionInSeconds:Float = inputs[2].get();
if (positionInSeconds < 0) positionInSeconds = 0;
var volume = object.data.volume;
var loop = object.data.loop;
var stream = object.data.stream;
object.stop();
var channel = Audio.play(object.sound, loop, stream);
if (channel != null) {
object.channels.push(channel);
channel.volume = volume;
@:privateAccess channel.set_position(positionInSeconds);
}
#end
runOutput(0);
}
}