OffsetMaskByNormalizedAmplitude
This node takes a MASK-type mask and a NORMALIZED_AMPLITUDE-type normalized amplitude sequence as primary inputs.
Offset Mask By Normalized Amplitude
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 Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
normalized_amp | NORMALIZED_AMPLITUDE | Yes | - | - | : The normalized amplitude sequence, with values clamped between 0.0 and 1.0, used to drive the mask's offset and rotation amount. |
mask | MASK | Yes | - | - | : The mask to be offset or rotated. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
x | INT | Yes | 0 | -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. |
y | INT | Yes | 0 | -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. |
rotate | BOOLEAN | Yes | False | - | : Boolean switch. When set to True, enables amplitude-based mask rotation. |
angle_multiplier | FLOAT | Yes | 0.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 Name | Data Type | Description |
|---|---|---|
| mask | MASK | : 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.
OffsetMaskByNormalizedAmplitude Node Source Code Link
The OffsetMaskByNormalizedAmplitude node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.