add optional stack remember on batch to AUdioMathNode
This commit is contained in:
@@ -48,6 +48,14 @@ class AudioMathNode(io.ComfyNode):
|
||||
tooltip="How to handle mismatched image batch sizes. tile: repeat shorter inputs; error: raise error on mismatch; pad: treat missing frames as zero."
|
||||
),
|
||||
io.Int.Input(id="batching", default=0),
|
||||
io.Bool.Input(
|
||||
id="remember_stack",
|
||||
default=False,
|
||||
display_name="Remember stack across batch",
|
||||
tooltip=(
|
||||
"If enabled, stack is copied at output leading to changes being remembered during batch operations (node runs multiple times in sucession). If disabled each batch gets it's own copy of the stack."
|
||||
),
|
||||
),
|
||||
MrmthStack.Input(id="stack", tooltip="Access stack between nodes",optional=True)
|
||||
],
|
||||
outputs=[
|
||||
@@ -57,17 +65,17 @@ class AudioMathNode(io.ComfyNode):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",batching=0,stack={}):
|
||||
def check_lazy_status(cls, Expression, V, F, length_mismatch="tile",batching=0,, remember_stack=False,stack={}):
|
||||
return checkLazyNew(Expression,V,F)
|
||||
|
||||
|
||||
@classmethod
|
||||
def execute(cls, V, F, Expression, length_mismatch="tile",batching=0,stack={}):
|
||||
def execute(cls, V, F, Expression, length_mismatch="tile",batching=0,, remember_stack=False, stack={}):
|
||||
# Identify all present audio inputs and their keys
|
||||
tensor_keys = [k for k, v in V.items() if v is not None and isinstance(v, dict) and "waveform" in v]
|
||||
if not tensor_keys:
|
||||
raise ValueError("At least one audio input is required.")
|
||||
stack = copy.deepcopy(stack) if stack is not None else {}
|
||||
stack = stack if remember_stack else (copy.deepcopy(stack) if stack is not None else {})
|
||||
waveforms = {k: V[k]["waveform"] for k in tensor_keys}
|
||||
sample_rates = {k + "sr": V[k].get("sample_rate", 44100) for k in tensor_keys}
|
||||
|
||||
@@ -142,4 +150,6 @@ class AudioMathNode(io.ComfyNode):
|
||||
res_list.append({"waveform": result_chunk, "sample_rate": sample_rate})
|
||||
return (res_list, stack)
|
||||
else:
|
||||
stack = stack if remember_stack else copy.deepcopy(stack)
|
||||
|
||||
return ([{"waveform": result, "sample_rate": sample_rate}], stack)
|
||||
|
||||
Reference in New Issue
Block a user