Browse Source

updated json to include all current processes parameters

Jonathan Higgins 6 months ago
parent
commit
25c5a82269

+ 55 - 47
dev_tools/helpers/sort_json.py

@@ -1,67 +1,75 @@
 import json
 import json
 import sys
 import sys
-from collections import OrderedDict
 
 
-# --- Custom category order ---
+# Use command-line argument for JSON path
+if len(sys.argv) < 2:
+    print("Usage: python sort_json.py <path_to_json>")
+    sys.exit(1)
+
+json_path = sys.argv[1]
+
+# Define custom category order
 CATEGORY_ORDER = ["time", "pvoc", "utility"]
 CATEGORY_ORDER = ["time", "pvoc", "utility"]
 
 
-# --- Desired param key order ---
-PARAM_ORDER = [
-    "paramname",
-    "paramdescription",
-    "automatable",
-    "time",
-    "min",
-    "max",
-    "flag",
-    "minrange",
-    "maxrange",
-    "step",
-    "value",
-    "exponential",
-    "uitype"
+# Define desired parameter field order
+FIELD_ORDER = [
+    "paramname", "paramdescription", "automatable", "time",
+    "min", "max", "flag", "minrange", "maxrange", "step",
+    "value", "exponential", "uitype"
 ]
 ]
 
 
-# --- Load JSON path from args ---
-if len(sys.argv) < 2:
-    print("Usage: python sort_json.py path_to_json")
-    sys.exit(1)
+def category_sort_key(item):
+    category = item.get("category", "").lower()
+    return CATEGORY_ORDER.index(category) if category in CATEGORY_ORDER else len(CATEGORY_ORDER)
 
 
-json_path = sys.argv[1]
+def extract_param_index(param_key):
+    # Extract number from param key like 'param1', 'param10'
+    try:
+        return int(''.join(filter(str.isdigit, param_key)))
+    except:
+        return float('inf')
+
+def reorder_param_fields(param):
+    # Reorder fields within a single parameter dict
+    ordered = {field: param[field] for field in FIELD_ORDER if field in param}
+    for k in param:
+        if k not in ordered:
+            ordered[k] = param[k]
+    return ordered
 
 
+# Load JSON
 with open(json_path, "r", encoding="utf-8") as f:
 with open(json_path, "r", encoding="utf-8") as f:
     data = json.load(f)
     data = json.load(f)
 
 
-# --- Reorder parameter fields ---
-def reorder_param_fields(param):
-    return OrderedDict((k, param[k]) for k in PARAM_ORDER if k in param)
-
-# --- Convert to sortable items ---
+# Convert dict to sortable list
 items = [{"key": k, **v} for k, v in data.items()]
 items = [{"key": k, **v} for k, v in data.items()]
 
 
-# --- Sort by category, subcategory, title ---
-items_sorted = sorted(
-    items,
-    key=lambda item: (
-        CATEGORY_ORDER.index(item.get("category", "")) if item.get("category", "") in CATEGORY_ORDER else 999,
-        item.get("subcategory", "").lower(),
-        item.get("title", "").lower()
-    )
-)
+# Sort items by category, subcategory, and title
+items_sorted = sorted(items, key=lambda item: (
+    category_sort_key(item),
+    item.get("subcategory", "").lower(),
+    item.get("title", "").lower()
+))
 
 
-# --- Rebuild with sorted parameter fields ---
-sorted_data = {}
+# Process each item's parameters
 for item in items_sorted:
 for item in items_sorted:
-    key = item.pop("key")
-    if "parameters" in item:
-        item["parameters"] = {
-            param_key: reorder_param_fields(param_val)
-            for param_key, param_val in item["parameters"].items()
-        }
-    sorted_data[key] = item
+    parameters = item.get("parameters", {})
+    # Sort parameter keys like param1, param2, ..., param10
+    sorted_keys = sorted(parameters.keys(), key=extract_param_index)
+    # Reorder fields inside each parameter
+    sorted_parameters = {
+        k: reorder_param_fields(parameters[k]) for k in sorted_keys
+    }
+    item["parameters"] = sorted_parameters
+
+# Rebuild dictionary with sorted keys
+sorted_data = {
+    item["key"]: {k: item[k] for k in item if k != "key"}
+    for item in items_sorted
+}
 
 
-# --- Overwrite the original file ---
+# Overwrite original file
 with open(json_path, "w", encoding="utf-8") as f:
 with open(json_path, "w", encoding="utf-8") as f:
     json.dump(sorted_data, f, indent=2, ensure_ascii=False)
     json.dump(sorted_data, f, indent=2, ensure_ascii=False)
 
 
-print(f"Sorted JSON saved to {json_path}")
+print(f"Sorted and overwritten: {json_path}")

+ 40 - 0
dev_tools/json_editor/process_help_copy.json → dev_tools/json_editor/process_help_backup.json

@@ -1820,6 +1820,46 @@
 	"subcategory": "",
 	"subcategory": "",
 	"title": "Output File"
 	"title": "Output File"
   },
   },
+  "note_to_hz": {
+	"category": "utility",
+	"description": "Utility for quickly getting frequencies, values are truncated to two decimal places so are not entirely accurate. Particularly useful for tuning filters and filterbanks. Note, you can highlight and copy a frequency and then paste that into the value for the slider.\n",
+	"parameters": {
+	  "param1": {
+		"paramname": "Note",
+		"paramdescription": "The note to get the frequency of",
+		"automatable": false,
+		"time": false,
+		"min": false,
+		"max": false,
+		"flag": "",
+		"minrange": "",
+		"maxrange": "",
+		"step": "",
+		"value": "",
+		"exponential": false,
+		"uitype": ""
+	  },
+	  "param2": {
+		"paramname": "Accidental",
+		"paramdescription": "Sets how sharp or flat the note is in quarter tones",
+		"automatable": false,
+		"time": false,
+		"min": false,
+		"max": false,
+		"flag": "",
+		"minrange": "",
+		"maxrange": "",
+		"step": "",
+		"value": "",
+		"exponential": false,
+		"uitype": ""
+	  }
+	},
+	"short_description": "Converts from musical notes to Hz",
+	"stereo": false,
+	"subcategory": "utility",
+	"title": "Convert Note to Hz"
+  },
   "notes": {
   "notes": {
 	"category": "utility",
 	"category": "utility",
 	"description": "Doesn't do anything other than giving you a space to take notes. You can right click in the text box to copy and paste and use special characters like emojis 😊.\n",
 	"description": "Doesn't do anything other than giving you a space to take notes. You can right click in the text box to copy and paste and use special characters like emojis 😊.\n",

+ 2 - 2
scenes/Nodes/nodes.tscn

@@ -1452,7 +1452,7 @@ text = "Lowest Band"
 [node name="HSlider" parent="filter_bank_1/VBoxContainer3/HSplitContainer" index="0"]
 [node name="HSlider" parent="filter_bank_1/VBoxContainer3/HSplitContainer" index="0"]
 min_value = 20.0
 min_value = 20.0
 max_value = 12000.0
 max_value = 12000.0
-step = 0.01
+step = 0.001
 value = 55.0
 value = 55.0
 exp_edit = true
 exp_edit = true
 
 
@@ -2144,7 +2144,7 @@ max_value = 10.0
 step = 0.01
 step = 0.01
 value = 0.251
 value = 0.251
 exp_edit = true
 exp_edit = true
-metadata/brk = false
+metadata/brk = true
 
 
 [node name="modify_brassage_4" type="GraphNode" parent="."]
 [node name="modify_brassage_4" type="GraphNode" parent="."]
 layout_mode = 0
 layout_mode = 0

File diff suppressed because it is too large
+ 294 - 294
scenes/main/process_help.json


Some files were not shown because too many files changed in this diff