diff --git a/core/IvmiScene.gd b/core/IvmiScene.gd index 9e23e8d0ee7686d13294adbe3886aa5681dd9a61..0ab41add3e8fb211cfbaf414f832d26f2a91985e 100644 --- a/core/IvmiScene.gd +++ b/core/IvmiScene.gd @@ -16,12 +16,12 @@ var _osc_discov : GodOSC #PD variables @export_file("*.pd") var _pd_patch var _gdpd -var _audio_stream -var _audio_player -var _input_buffer -var _output_buffer -var _buffer_size = 64 -var phase = 0 +#var _audio_stream +#var _audio_player +#var _input_buffer +#var _output_buffer +#var _buffer_size = 64 +#var phase = 0 @export var _debug_osc: bool = false @@ -85,18 +85,18 @@ func _ready(): if _pd_mode==PdMode.LIBPD : var gdpdir = DirAccess.open("res://addons/gdpd") if gdpdir : - _gdpd = load("res://addons/gdpd/gdpd.gdextension").new() + _gdpd = ClassDB.instantiate("GdPd") add_child(_gdpd) - _input_buffer = PackedVector2Array() - _input_buffer.resize(_buffer_size) - _output_buffer = PackedVector2Array() - _output_buffer.resize(_buffer_size) if _pd_patch!="" : - #initialize pd - _gdpd.init(2, 2, 44100) - #open patch - var patch_name = _pd_patch.right(_pd_patch.rfind("/")+1) - var patch_dir = (_pd_patch.rstrip(patch_name)).right(6) + # Get all input and output devices + var inps = _gdpd.get_available_input_devices() + var outs = _gdpd.get_available_output_devices() + # Initialise the first ones + _gdpd.init_devices(inps[0], outs[0]) + # Open patch + var global_patch = ProjectSettings.globalize_path(_pd_patch) + var patch_name = global_patch.split("/")[-1] + var patch_dir = global_patch.trim_suffix(patch_name) _gdpd.openfile(patch_name, patch_dir) else : print("IVMI : Could not load gdpd addon") @@ -241,8 +241,8 @@ func _on_found_server(server_ip, port) : func _on_timeout() : - #we haven't found an existing server - #if peer become a server and connect to it + # We haven't found an existing server + # If peer, become a server and connect to it if _network_mode==NetMode.Peer and _network_server==null: _network_mode=NetMode.Server _network_discov.set_server(_server_port) @@ -294,9 +294,9 @@ func send(address, tags, args) : PdMode.OSC : _osc_to_pd.send_msg(addr, tags, args) PdMode.LIBPD : - var split = address.split("/") + var split : Array = address.split("/") _gdpd.start_message(args.size()+split.size()) - split.remove(0) + split.pop_front() for s in split : _gdpd.add_symbol(s) for a in args :