Nodes/ComfyUI-Apt_Preset/Amp_drive_String
ComfyUI Node

Amp_drive_String

Cycle prompt lines off a threshold, not a frame count

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Amp_drive_String
    • text
    textRabbit Dog Cat One prompt per line
    normalized_amp
    triggering_threshold0.60
    looptrue
    shufflefalse

    Normal prompt-scheduling setups switch text every N frames, on a clock. This one switches on a trigger instead - the moment your amplitude signal crosses a threshold, it advances to the next line of your prompt list. That's a meaningfully different tool: a clock-based scheduler gives you evenly-paced changes; this gives you changes that land exactly on the beats, onsets, or spikes in whatever signal you're driving it with. It's the sibling of Amp_drive_mask and Amp_drive_value in this pack's AD (AnimateDiff) category - all three exist to turn one amplitude curve into different flavors of animation control, which lines up with the audio-reactive corner of the AnimateDiff community: separate the audio into stems, use the resulting energy curve to drive keyframe transitions instead of hand-placing them.

    How it works

    You give it a block of text - one prompt per line, using the default placeholder text (Rabbit / Dog / Cat / One prompt per line) as the template - plus your driving value in normalized_amp and a triggering_threshold (0-1, defaulting to 0.6). Every time normalized_amp crosses that threshold, the node advances to the next line and outputs it as text. Below the threshold, it just holds whatever line it's currently on. Practically: set the threshold low and it fires on almost every ripple in your signal; set it high (closer to 1.0) and it only advances on genuine peaks - the difference between prompt changes on every snare hit versus only on the loudest drop.

    The inputs and outputs that matter

    The three you'll actually set: text (your list, one prompt per line - this is the whole point of the node, so don't skip writing a real one), normalized_amp (the driving curve), and triggering_threshold (how hard the signal has to spike before it advances). Two optional toggles change the cycling behavior: loop (default true) wraps back to the first line after the last one instead of just repeating the final line forever, and shuffle (default false) randomizes the order it steps through instead of going top to bottom - useful if you want the prompt changes to feel less mechanically sequential. The single output, text (STRING), wires straight into whatever encodes your prompt - a CLIP Text Encode node, or this same pack's basicIn_clip.

    Installing it

    Search "ComfyUI-Apt_Preset" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    then run install.bat on Windows (pip install -r requirements.txt on Linux/Mac) and restart. Nothing here needs a model download - it's pure string logic.

    Where this actually bites

    The whole node is only as good as the shape of your normalized_amp curve. If your signal is noisy - jittering above and below the threshold rapidly, rather than settling clearly on each side - you'll get the text advancing multiple lines in a single beat instead of one clean step per hit, because the node doesn't debounce for you. If your prompt list needs to hold on line 3 for exactly one bar of music and you're getting a stutter, smooth or gate your amplitude signal upstream rather than fighting it here. And a boring but common trap: this node reads plain lines, so a blank line at the end of your list (which the default multiline box practically invites) counts as an actual empty prompt in the rotation - trim it before you rely on loop cycling back cleanly.

    CategoryApt_Preset/AD

    Inputs (5)

    NameTypeDefaultDescription
    textSTRINGRabbit Dog Cat One prompt per line
    normalized_ampFLOAT
    triggering_thresholdFLOAT0.600–1
    loopoptBOOLEANtrue
    shuffleoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    textSTRING