Nodes/afloy_audio_tools/Afloy Audio Trim
ComfyUI Node

Afloy Audio Trim

Cut audio on the waveform, not by guessing seconds

By afloy011-spec·Created 5 months ago·Updated 2 months ago· 6
Afloy Audio Trim
  • audio
  • audio
  • waveform_preview
  • duration_sec
  • timecode
start_sec0.00
end_sec-1.00

Here's the ComfyUI audio workflow you're probably running right now: open a DAW or Audacity, trim the clip, export, drag it back in, and pray the sync still holds. Afloy Audio Trim exists to kill that round-trip. It puts a DAW-style waveform right inside the node - draggable start/end markers, playback, zoom, the works - and slices the AUDIO tensor for you, so the trimmed clip stays in-graph and downstream nodes see it immediately.

It's the flagship of the afloy_audio_tools pack, installed once and delivering three nodes under Add Node → audio → Afloy Audio Tools.

How it works

Inputs are straightforward: audio (AUDIO), start_sec (FLOAT, default 0), and end_sec (FLOAT, default -1, which means "end of file"). The node converts your seconds to sample indices at the clip's actual sample rate, slices the waveform tensor, and hands back:

  • audio (AUDIO) - the trimmed segment, same sample rate as the source
  • waveform_preview (IMAGE) - a static rendered picture of the whole clip with the selection highlighted; wire it into any image preview
  • duration_sec (FLOAT) - how long the segment is
  • timecode (STRING) - MM:SS (hundredths) of the segment

The interesting part is the interactive widget, which lives in the pack's web/trim_audio.js. That's real editing, not slider-fiddling: drag the yellow start and orange end markers (they snap to zero-crossings, so your cuts land on the silence between transients instead of on an audible click), drag inside the selection to move both at once, click to place the scrub cursor, Space to play/stop, +/- or the mouse wheel to zoom up to 50×. Tab switches which marker is active, I and O set start/end from the cursor, and Shift + ←/→ nudges the active marker by a second. The widget writes your edits straight into start_sec/end_sec.

One subtlety the README is right to call out: the widget and the tensor refresh on different triggers. The node overrides IS_CHANGED so a new clip in Load Audio invalidates the cache and re-trims automatically - but the waveform you're looking at is drawn client-side, so after you swap the file you'll want F5 (or the Reload button) to redraw it. That trips people up more than anything else in this pack.

Installing it

Same as the other two nodes in the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/afloy011-spec/afloy_audio_tools.git "Afloy Audio Tools"

Restart ComfyUI. Or find it via ComfyUI Manager - search "Afloy Audio Tools". The web widget is bundled in the repo, so there's nothing extra to download: no models, no requirements.txt, just numpy, Pillow, and torch from ComfyUI's own environment. That "no dependencies" part is worth appreciating when the average custom node brings along a small war.

Troubleshooting

The one hard error you'll see is a Python exception saying the input has no samples - that means Load Audio handed over an empty clip, so check the source file before blaming the trim. If the markers look like they're ignoring your clicks, remember the F5 reload dance above. And a friendly warning: set start_sec after end_sec won't crash - the code quietly enforces a one-sample minimum - but it also won't swap them for you, so "end before start" silently becomes a sliver of a segment. Decide the selection in the widget and you'll never hit it.

Pair it with Afloy Audio Duration in the same pack and you can cut a clip, verify the exact trimmed length, and hand both to a video-out node - a genuinely decent little audio post station that never leaves the graph.

Categoryaudio/Afloy Audio Tools

Inputs (3)

NameTypeDefaultDescription
audioAUDIO
start_secFLOAT0.000–99999
end_secFLOAT-1.00-1–99999

Outputs (4)

NameTypeDescription
audioAUDIO
waveform_previewIMAGE
duration_secFLOAT
timecodeSTRING