KJNodes/deprecatedgenerated

Create Audio Mask(CreateAudioMask)

This node loads a WAV audio file from a specified path and uses the librosa library to compute its Short-Time Fourier Transform to obtain spectral data.

Create Audio Mask

IMAGE
invert
frames
16
scale
0.50
audio_path
audio.wav
width
256
height
256
KJNodes

Deprecated: This node has been deprecated and moved to the KJNodes/deprecated category. It may be removed in future updates. Consider using alternative nodes for audio-driven mask generation.

The Create Audio Mask node loads a WAV audio file from a specified path and uses the librosa library to compute its Short-Time Fourier Transform (STFT) to obtain spectral data.

The Create Audio Mask node dynamically generates a series of image masks based on the spectral information of an audio file. Its core function is to transform amplitude variations in the audio into a sequence of visual circular masks, providing visual elements synchronized with the audio rhythm for subsequent image processing or video synthesis.

Node Function

This node loads a WAV audio file from a specified path and uses the librosa library to compute its Short-Time Fourier Transform (STFT) to obtain spectral data. Based on the set number of frames, the node extracts the average amplitude for corresponding time segments from the spectrum. This amplitude value is then multiplied by a scaling factor to calculate a circle's radius. Finally, a white circle (or a black circle after inversion) image is generated at the center of a canvas with the specified dimensions.

Node Parameter Description - Create Audio Mask

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
invertBOOLEANYesFalse-invert (input parameter): Inverts the mask color. Generates a white background with a black circle when False, and a black background with a white circle when True.
framesINTYes161 - 255 (step: 1)frames (input parameter): Sets the total number of image mask frames to generate. Valid range is 1 to 255.
scaleFLOATYes0.50.0 - 2.0 (step: 0.01)scale (input parameter): Controls the scaling factor for the circle's radius. Valid range is 0.0 to 2.0, with a step of 0.01.
audio_pathSTRINGYesaudio.wav-audio_path (input parameter): Specifies the path string for the input audio file. By default, it reads the "audio.wav" file in the current directory.
widthINTYes25616 - 4096 (step: 1)width (input parameter): Sets the width in pixels for the output mask image. Valid range is 16 to 4096.
heightINTYes25616 - 4096 (step: 1)height (input parameter): Sets the height in pixels for the output mask image. Valid range is 16 to 4096.

Output

Parameter NameData TypeDescription
IMAGEIMAGEIMAGE (output parameter): Outputs the generated image sequence, which is the visual mask corresponding to the audio spectrum.

Use Cases

This node is highly useful in workflows for creating music visualization shorts or effects requiring audio-visual synchronization. You can connect the generated image sequence (masks) to nodes for image blending or repainting areas to control the appearance or disappearance range of certain elements (such as glows or particles) in a video according to the music's rhythm, thereby achieving audio-driven visual changes.

Notes

This node relies on the librosa library. If not installed, it will cause a runtime error. The default audio path is "audio.wav". If the file is not in the ComfyUI root directory, you may need to use an absolute path to ensure the node can read the file correctly.

The Create Audio Mask node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…