Add emit loop delay control for item emit audio
This commit is contained in:
@@ -13,6 +13,7 @@ EDITABLE_PROPERTIES: tuple[str, ...] = (
|
||||
"emitVolume",
|
||||
"emitSoundSpeed",
|
||||
"emitSoundTempo",
|
||||
"emitLoopDelay",
|
||||
"emitEffect",
|
||||
"emitEffectValue",
|
||||
"useSound",
|
||||
@@ -33,6 +34,7 @@ DEFAULT_PARAMS: dict = {
|
||||
"emitVolume": 100,
|
||||
"emitSoundSpeed": 50,
|
||||
"emitSoundTempo": 50,
|
||||
"emitLoopDelay": 0,
|
||||
"emitEffect": "off",
|
||||
"emitEffectValue": 50,
|
||||
"useSound": "",
|
||||
@@ -46,6 +48,7 @@ PARAM_KEYS: tuple[str, ...] = (
|
||||
"emitVolume",
|
||||
"emitSoundSpeed",
|
||||
"emitSoundTempo",
|
||||
"emitLoopDelay",
|
||||
"emitEffect",
|
||||
"emitEffectValue",
|
||||
"useSound",
|
||||
@@ -83,6 +86,11 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||
"tooltip": "Playback tempo percent for emitted sound. 50 is normal, 0 is half, 100 is double. Using speed and tempo together may sound weird.",
|
||||
"range": {"min": 0, "max": 100, "step": 0.1},
|
||||
},
|
||||
"emitLoopDelay": {
|
||||
"valueType": "number",
|
||||
"tooltip": "Delay in seconds between each playing of this audio.",
|
||||
"range": {"min": 0, "max": 300, "step": 0.1},
|
||||
},
|
||||
"emitEffect": {"valueType": "list", "tooltip": "Effect applied to emitted sound.", "options": list(EFFECT_OPTIONS)},
|
||||
"emitEffectValue": {
|
||||
"valueType": "number",
|
||||
|
||||
@@ -56,6 +56,14 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
||||
raise ValueError("emitSoundTempo must be between 0 and 100.")
|
||||
next_params["emitSoundTempo"] = round(emit_tempo, 1)
|
||||
|
||||
try:
|
||||
emit_loop_delay = float(next_params.get("emitLoopDelay", item.params.get("emitLoopDelay", 0)))
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValueError("emitLoopDelay must be a number between 0 and 300.") from exc
|
||||
if not (0 <= emit_loop_delay <= 300):
|
||||
raise ValueError("emitLoopDelay must be between 0 and 300.")
|
||||
next_params["emitLoopDelay"] = round(emit_loop_delay, 1)
|
||||
|
||||
emit_effect = str(next_params.get("emitEffect", item.params.get("emitEffect", "off"))).strip().lower()
|
||||
if emit_effect not in EFFECT_OPTIONS:
|
||||
raise ValueError("emitEffect must be one of reverb, echo, flanger, high_pass, low_pass, off.")
|
||||
|
||||
Reference in New Issue
Block a user