KJNodes/audiogenerated

OffsetMaskByNormalizedAmplitude

This node takes a MASK-type mask and a NORMALIZED_AMPLITUDE-type normalized amplitude sequence as primary inputs.

Offset Mask By Normalized Amplitude

normalized_amp
mask
mask
x
INT
y
INT
rotate
angle_multiplier
0.000
KJNodes

The OffsetMaskByNormalizedAmplitude node receives a MASK-type mask and a NORMALIZED_AMPLITUDE-type normalized amplitude sequence as its primary inputs. It serves as a bridge to the AudioScheduler nodes (https://github.com/a1lazydog/ComfyUI-AudioScheduler).

The OffsetMaskByNormalizedAmplitude node is an audio-driven mask transformation tool. Its core function is to dynamically translate or rotate a mask image based on the input normalized amplitude values, thereby transforming the rhythm or intensity changes of audio into visual dynamic effects.

Node Function

This node receives a MASK-type mask and a NORMALIZED_AMPLITUDE-type normalized amplitude sequence as its primary inputs. Internally, it calculates the displacement or rotation angle for each frame of the mask by multiplying the amplitude values by preset offsets (x, y) or an angle multiplier (angle_multiplier), and performs the transformation using PyTorch's roll and rotate functions. Amplitude values are automatically clipped to the range [0, 1] to ensure transformation stability.

Node Parameter Description - OffsetMaskByNormalizedAmplitude

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
normalized_ampNORMALIZED_AMPLITUDEYes--: The normalized amplitude sequence, with values clamped between 0.0 and 1.0, used to drive the mask's offset and rotation amount.
maskMASKYes--: The mask to be offset or rotated.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
xINTYes0-4096 - MAX_RESOLUTION (Step: 1): Controls the baseline offset intensity of the mask in the horizontal direction (X-axis). The value range is -4096 to MAX_RESOLUTION, with a step of 1.
yINTYes0-4096 - MAX_RESOLUTION (Step: 1): Controls the baseline offset intensity of the mask in the vertical direction (Y-axis). The value range is -4096 to MAX_RESOLUTION, with a step of 1.
rotateBOOLEANYesFalse-: Boolean switch. When set to True, enables amplitude-based mask rotation.
angle_multiplierFLOATYes0.0-1.0 - 1.0 (Step: 0.001): Rotation angle multiplier, which together with the amplitude determines the rotation angle. The value range is -1.0 to 1.0, with a step of 0.001.

Output

Parameter NameData TypeDescription
maskMASK: The new mask after offset or rotation transformation.

Usage Scenarios

In practical applications, this node is often used in conjunction with AudioScheduler series nodes to create music visualizations or audio-reactive animations. For example, in a video generation workflow, the amplitude analysis results of a piece of music can be fed into this node to control the position or rotation of a foreground mask, synchronizing the mask's movement rhythm with the music's beat, thereby generating dynamic visual effects.

Notes

When using this node, note that the mask's offset and rotation are calculated based on the instantaneous amplitude values. Excessively large displacement values may cause unwanted cyclic wrapping effects at the image boundaries. Additionally, ensure the amplitude input data is normalized.

The OffsetMaskByNormalizedAmplitude node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…