Browse Source

started added dynamic add/remove inlets

Jonathan Higgins 3 months ago
parent
commit
52f2d1a3bf

+ 13 - 0
scenes/Nodes/addremoveinlets.gd

@@ -0,0 +1,13 @@
+extends Control
+
+signal add_inlet
+signal remove_inlet
+
+
+
+func _on_add_inlet_button_button_down() -> void:
+	add_inlet.emit()
+
+
+func _on_remove_inlet_button_button_down() -> void:
+	remove_inlet.emit()

+ 1 - 0
scenes/Nodes/addremoveinlets.gd.uid

@@ -0,0 +1 @@
+uid://ddy27yplob87l

+ 41 - 0
scenes/Nodes/addremoveinlets.tscn

@@ -0,0 +1,41 @@
+[gd_scene load_steps=2 format=3 uid="uid://cho3fvni7kadi"]
+
+[ext_resource type="Script" uid="uid://ddy27yplob87l" path="res://scenes/Nodes/addremoveinlets.gd" id="1_1pgec"]
+
+[node name="Control" type="Control"]
+custom_minimum_size = Vector2(270, 57)
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_right = -1010.0
+offset_bottom = -663.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_1pgec")
+
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
+layout_mode = 0
+offset_right = 40.0
+offset_bottom = 40.0
+
+[node name="Label" type="Label" parent="VBoxContainer"]
+layout_mode = 2
+text = "Add/Remove Inlets"
+
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
+custom_minimum_size = Vector2(270, 0)
+layout_mode = 2
+
+[node name="AddInletButton" type="Button" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+text = "+"
+
+[node name="RemoveInletButton" type="Button" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+size_flags_horizontal = 3
+text = "-"
+
+[connection signal="button_down" from="VBoxContainer/HBoxContainer/AddInletButton" to="." method="_on_add_inlet_button_button_down"]
+[connection signal="button_down" from="VBoxContainer/HBoxContainer/RemoveInletButton" to="." method="_on_remove_inlet_button_button_down"]

+ 30 - 0
scenes/Nodes/node_logic.gd

@@ -17,6 +17,11 @@ func _ready() -> void:
 	btn.connect("pressed", Callable(self, "_open_help")) #pass key (process name) when button is pressed
 	btn.connect("pressed", Callable(self, "_open_help")) #pass key (process name) when button is pressed
 	titlebar.add_child(btn)
 	titlebar.add_child(btn)
 	
 	
+	if self.has_node("addremoveinlets"):
+		var addremove = self.get_node("addremoveinlets")
+		addremove.add_inlet.connect(add_inlet_to_node)
+		addremove.remove_inlet.connect(remove_inlet_from_node)
+	
 
 
 func _get_all_hsliders(node: Node) -> Array:
 func _get_all_hsliders(node: Node) -> Array:
 	#moves through all children recusively to find nested sliders
 	#moves through all children recusively to find nested sliders
@@ -60,3 +65,28 @@ func _on_slider_value_changed(value: float, changed_slider: HSlider) -> void:
 
 
 func _open_help():
 func _open_help():
 	open_help.emit(self.get_meta("command"), self.title)
 	open_help.emit(self.get_meta("command"), self.title)
+
+func add_inlet_to_node():
+	var inlet_count = self.get_input_port_count()
+	var child_count = self.get_child_count()
+	
+	if child_count < inlet_count + 1:
+		var control = Control.new()
+		control.custom_minimum_size.y = 57
+		control.set_meta("dummynode", true)
+		add_child(control)
+		move_child(get_node("addremoveinlets"), get_child_count() - 1)
+	
+	set_slot(inlet_count, true, get_input_port_type(0), get_input_port_color(0), false, 0, get_input_port_color(0))
+	
+func remove_inlet_from_node():
+	var inlet_count = self.get_input_port_count()
+	var child_count = self.get_child_count()
+	
+	set_slot(inlet_count - 1, false, get_input_port_type(0), get_input_port_color(0), false, 0, get_input_port_color(0))
+	
+	if get_child(child_count - 2).has_meta("dummynode"):
+		get_child(child_count - 2).queue_free()
+		await get_tree().process_frame
+		update_minimum_size()
+		size.y = get_combined_minimum_size().y

+ 29 - 0
scenes/main/process_help.json

@@ -2612,6 +2612,35 @@
 	"subcategory": "misc",
 	"subcategory": "misc",
 	"title": "Invert Polarity"
 	"title": "Invert Polarity"
   },
   },
+  "sfedit_join": {
+	"category": "time",
+	"description": "This process takes each the sound at the first inlet and appends the sound on the second inlet to the end of the file. This is repeated for all subsequent inlets.\n",
+	"inputtype": "[0, 0]",
+	"outputisstereo": false,
+	"outputtype": "[0]",
+	"parameters": {
+	  "param1": {
+		"paramname": "",
+		"paramdescription": "",
+		"automatable": false,
+		"outputduration": false,
+		"time": false,
+		"min": false,
+		"max": false,
+		"flag": "",
+		"minrange": 2.0,
+		"maxrange": -1.0,
+		"step": "",
+		"value": "",
+		"exponential": false,
+		"uitype": "addremoveinlets"
+	  }
+	},
+	"short_description": "Append multiple sounds end to end",
+	"stereo": true,
+	"subcategory": "misc",
+	"title": "Join"
+  },
   "sfedit_excise_1": {
   "sfedit_excise_1": {
 	"category": "time",
 	"category": "time",
 	"description": "Unlike the trim function, this process removes the selected segment of audio out of the audio file keeping only the audio that is outside of the start and end points. Once it has removed the segment of audio it puts the start and end of the file together to close the gap. ",
 	"description": "Unlike the trim function, this process removes the selected segment of audio out of the audio file keeping only the audio that is outside of the start and end points. Once it has removed the segment of audio it puts the start and end of the file together to close the gap. ",

+ 17 - 1
scenes/main/scripts/graph_edit.gd

@@ -9,6 +9,7 @@ var copied_nodes_data = [] #stores node data on ctrl+c
 var copied_connections = [] #stores all connections on ctrl+c
 var copied_connections = [] #stores all connections on ctrl+c
 var node_data = {} #stores json with all nodes in it
 var node_data = {} #stores json with all nodes in it
 var valueslider = preload("res://scenes/Nodes/valueslider.tscn") #slider scene for use in nodes
 var valueslider = preload("res://scenes/Nodes/valueslider.tscn") #slider scene for use in nodes
+var addremoveinlets = preload("res://scenes/Nodes/addremoveinlets.tscn") #add remove inlets scene for use in nodes
 var node_logic = preload("res://scenes/Nodes/node_logic.gd") #load the script logic
 var node_logic = preload("res://scenes/Nodes/node_logic.gd") #load the script logic
 
 
 
 
@@ -226,12 +227,25 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
 						#set flag meta
 						#set flag meta
 						optionbutton.set_meta("flag", flag)
 						optionbutton.set_meta("flag", flag)
 						
 						
-						#add margin size for ertical spacing
+						#add margin size for vertical spacing
 						margin.add_theme_constant_override("margin_bottom", 4)
 						margin.add_theme_constant_override("margin_bottom", 4)
 						
 						
 						graphnode.add_child(label)
 						graphnode.add_child(label)
 						graphnode.add_child(optionbutton)
 						graphnode.add_child(optionbutton)
 						graphnode.add_child(margin)
 						graphnode.add_child(margin)
+					elif param_data.get("uitype", "") == "addremoveinlets":
+						var addremove = addremoveinlets.instantiate()
+						addremove.name = "addremoveinlets"
+						
+						#get parameters
+						var minrange = param_data.get("minrange", 0)
+						var maxrange = param_data.get("maxrange", 10)
+						
+						#set meta
+						addremove.set_meta("min", minrange)
+						addremove.set_meta("max", maxrange)
+						
+						graphnode.add_child(addremove)
 				
 				
 				control_script.changesmade = true
 				control_script.changesmade = true
 			
 			
@@ -241,6 +255,8 @@ func _make_node(command: String, skip_undo_redo := false) -> GraphNode:
 				var control = Control.new()
 				var control = Control.new()
 				control.custom_minimum_size.y = 57
 				control.custom_minimum_size.y = 57
 				graphnode.add_child(control)
 				graphnode.add_child(control)
+				if graphnode.has_node("addremoveinlets"):
+					graphnode.move_child(graphnode.get_node("addremoveinlets"), graphnode.get_child_count() - 1)
 			
 			
 			#add ports
 			#add ports
 			for i in range(portcount):
 			for i in range(portcount):