Beat-Synced ZigZag - User Guide

Reverses alternating tempo-grid segments in place: segment 1 backward, segment 2 forward, segment 3 backward, and so on. The grid can use bars, quarter-note beats, eighths, sixteenths, or thirty-seconds.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.4.1 (2026) License: MIT License Repo: GitHub
Contents:

What this does

Beat-Synced ZigZag divides a selected Sound into complete, tempo-synchronized segments and reverses every odd-numbered segment while leaving every even-numbered segment forward. Segment order is not changed: each segment stays in its original time position, but its playback direction alternates.

Original: [A ->] [B ->] [C ->] [D ->] ZigZag: [<- A] [B ->] [<- C] [D ->]

The script can process the whole Sound or only a quantized tail region. It does not analyze beats from the audio signal, does not time-stretch segments, and does not change pitch deliberately. Segments are extracted with a rectangular window, reversed when required, and concatenated back in chronological order.

No crossfade or edge smoothing is applied. Reversal changes the samples presented at segment boundaries, so discontinuities or clicks can occur on material whose grid boundaries are not naturally smooth.

What is ZigZag?

Here, zigzag means alternating playback direction across adjacent musical-grid segments. It is not a back-and-forth read pointer inside one continuous buffer and it is not a reordering of segments.

Segment 1: reversed in place
Segment 2: forward
Segment 3: reversed in place
Segment 4: forward
etc.

Changing the subdivision changes the scale of the transformation. Bars create large phrase-level reversals; sixteenths or thirty-seconds create rapid local reversals and a more fragmented texture.

Quick start

  1. Select exactly one Sound object in Praat.
  2. Run Beat-Synced_ZigZag.praat.
  3. Choose a preset or keep Custom.
  4. Choose Whole sound or Tail only (quantized from midpoint).
  5. Choose Fit bars to duration if the Sound contains a known number of complete bars, or use Manual BPM.
  6. Select the time signature and subdivision.
  7. Keep Keep_trailing_audio enabled if a final incomplete subdivision should remain in the result.
  8. Click OK. The result is named <source>_zigzag_<subdivision>.

Presets

The six named presets change only Mode and/or Subdivision. They do not replace the current BPM mode, bar count, manual BPM, time signature, trailing-audio setting, visualization setting, or playback setting.

PresetModeSubdivision
Beat Stutter (quarter notes)Whole soundBeats (quarter notes)
Fast Glitch (16ths)Whole soundSixteenth notes
Ultra Glitch (32nds)Whole soundThirty-second notes
Bar Flip (whole bars)Whole soundBars
Eighth Note BounceWhole soundEighth notes
Tail Only (from midpoint)Tail onlyBeats (quarter notes)

Tempo, meter & subdivision

BPM convention

BPM always means quarter-note BPM in this script, for every time signature. This is especially important in 6/8: one 6/8 bar is treated as six eighth notes = three quarter-note units.

Time signatureQuarter-note units per bar
4/44
3/43
6/83
5/45

Fit bars to duration

This mode is a calculation from declared musical structure; it is not automatic tempo detection from audio content.

quarter-note units = Number_of_bars x quarter-note units per bar BPM = (quarter-note units / Sound duration) x 60

For example, a Sound declared as four bars of 4/4 is treated as 16 quarter-note units spread across the full Sound duration.

Subdivision duration

quarter duration = 60 / BPM Bars: quarter duration x quarter-note units per bar Beats: quarter duration Eighth notes: quarter duration / 2 Sixteenths: quarter duration / 4 Thirty-seconds: quarter duration / 8
6/8 note: Beats (quarter notes) still means quarter notes. The script does not reinterpret the beat subdivision as a dotted-quarter pulse.

Processing modes

Whole sound

The tempo grid is anchored at the Sound start. The script processes as many complete subdivisions as fit. Odd segments are reversed and even segments remain forward.

Tail only (quantized from midpoint)

The first part remains untouched. The script finds the first subdivision boundary at or after the exact midpoint and begins the alternating reversal there. This keeps the processed tail on the same grid that is anchored at the Sound start.

midpoint offset = duration / 2 grid index = ceiling(midpoint offset / segment duration) processing start = grid index x segment duration

If the midpoint already lies on a subdivision boundary, processing starts there.

Parameters

ParameterDefaultDescription
PresetCustomCustom or one of six mode/subdivision presets.
ModeWhole soundProcess the whole Sound or a grid-quantized tail beginning at or after the midpoint.
Bpm_modeFit bars to durationDerive quarter-note BPM from Sound duration and declared bar count, or use Manual BPM.
Number_of_bars4Positive bar count used only by Fit bars to duration.
Manual_bpm120Positive quarter-note BPM used in Manual BPM mode.
Time_signature4/44/4, 3/4, 6/8, or 5/4. Determines bar length and affects fit-to-duration BPM.
SubdivisionBeatsBars, quarter-note beats, eighths, sixteenths, or thirty-seconds.
Keep_trailing_audioOnKeeps an incomplete final subdivision unchanged. If Off, that remainder is omitted.
Draw_visualizationOnDraws Source, direction map, Output, and Summary.
Play_resultOnPlays the new Sound after processing.

Safety limits

Output & visualization

Audio behavior

Visualization

The visualization uses four levels:

Source and Output waveforms are displayed with the same fixed amplitude range, allowing a direct visual comparison of waveform magnitude.