Polyrhythms From Dots — User Guide

A deterministic two-line polyrhythm generator. Each line places an integer number of evenly spaced events inside the same bar duration, renders them as short raised-cosine-windowed tones at two pitches, routes the lines to opposite stereo sides, and optionally concatenates identical copies of the resulting bar.

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

What this does

The engine creates two regular event grids over one common bar duration. If line 1 contains n1 dots and line 2 contains n2 dots, both begin at time 0 and place their remaining events at equal intervals before the end of the bar.

This is a deterministic equal-division polyrhythm generator. There is no random timing, no swing, no microtiming, and no tempo drift.

The top line uses the selected Base frequency. The bottom line uses exactly 1.5 times that frequency. The two lines are routed asymmetrically to left and right so they remain perceptually distinguishable.

When Repeat count is greater than 1, the script does not regenerate the pattern. It synthesizes one bar, peak-scales that bar, then concatenates exact copies end to end.

Quick start

  1. Run PolyrhythmsFromDots.praat. No input Sound is required.
  2. Choose Custom or one of the eight named ratio presets.
  3. For Custom, set Dots line 1, Dots line 2, Bar duration, Repeat count, and Base frequency.
  4. Enable Edit details to change Dot duration, Sample rate, and Output peak.
  5. Run the script. One stereo bar is synthesized first; if Repeat count is greater than 1, exact copies are concatenated.

Polyrhythmic timing

Both lines divide the same bar duration T independently:

spacing1 = T / n1
spacing2 = T / n2

The actual event times are:

line 1: t1[i] = (i - 1) × T / n1, i = 1 ... n1 line 2: t2[j] = (j - 1) × T / n2, j = 1 ... n2

The bar is treated as a half-open interval [0,T). Both lines therefore contain an event at time 0, but no additional event is placed exactly at T; that point is the beginning of the next repeated bar.

Because Dot duration is independent of spacing, events can overlap within one line or across both lines when Dot duration is longer than the interval between nearby onsets.

GCD, LCM, reduced ratio, and exact coincidences

The script computes the greatest common divisor and least common multiple of the two dot counts:

GCD = gcd(n1,n2) LCM = n1 × n2 / GCD

Common temporal lattice

Every event from both lines falls on the common lattice:

lattice step = BarDuration / LCM(n1,n2)

The LCM therefore describes the finest integer subdivision needed to represent both equal-division grids inside the same bar. It does not create a separate repetition period beyond the bar itself.

Reduced ratio

The QC display reports:

reduced line 1 = n1 / GCD
reduced line 2 = n2 / GCD

For example, 4:6 reduces to 2:3.

Exact coincidences

On the half-open bar [0,T), the two grids coincide exactly GCD(n1,n2) times:

coincidence times = k × T / GCD k = 0 ... GCD - 1

This is calculated with integer arithmetic rather than by testing whether event times fall within an arbitrary temporal tolerance.

Dot sound

Each event renders one short sinusoid with a raised-cosine/Hann-shaped amplitude envelope:

g(τ) = sin(2πfτ) × [1 - cos(2πτ/D)] / 2 0 ≤ τ < D

where D is Dot duration and local time τ = x - eventTime. The carrier phase therefore restarts at zero for each dot.

The envelope is zero at both ends of a full-length dot, reducing onset and offset discontinuities.

End-of-bar truncation

If a dot begins so late that its requested duration would extend beyond the bar, its duration is shortened to end exactly at the bar boundary. Therefore the final dot of a dense pattern can be shorter than the requested Dot duration.

This keeps each synthesized bar self-contained before repetition. There is no grain tail crossing from one bar into the next.

Pitch

LineFrequency
Line 1 / topBase frequency
Line 2 / bottom1.5 × Base frequency

The 1.5 ratio is fixed in v0.5 and is not separately editable.

Fixed stereo routing

The engine does not pan individual dots across the stereo field. Each complete rhythmic line has one fixed routing:

Left channel = 0.9 × line1 + 0.3 × line2
Right channel = 0.3 × line1 + 0.9 × line2

Thus line 1 is left-dominant and line 2 is right-dominant, while both remain audible in both channels.

These are fixed linear gains, not an equal-power pan law. There is no Pan amount control in v0.5.

Bar repetition

The script first creates and peak-scales exactly one stereo bar. Repeat count then determines how many identical copies are concatenated.

total duration = BarDuration × RepeatCount

For Repeat count > 1:

Because every repeated bar is an exact copy, the peak of the repeated result is the same as the peak-scaled single bar.

Controls

Main page

ControlDefaultRange / behaviorMeaning
PresetCustomCustom + 8 named presetsOverrides the principal ratio/timing/frequency values listed below.
Dots line 15Integer ≥1Number of evenly spaced top-line events per bar.
Dots line 27Integer ≥1Number of evenly spaced bottom-line events per bar.
Bar duration2.0 sPositiveCommon duration occupied by both equal-division grids.
Repeat count11–64Number of bit-identical bars concatenated in the final output.
Base frequency220 HzPositiveLine-1 oscillator frequency; line 2 is fixed at 1.5× this value.
Edit detailsoffbooleanOpens Dot duration, Sample rate, and Output peak.

Details page

ControlDefaultBehavior
Dot duration.05 sRequested tone-kernel duration; must occupy at least four samples. Late dots can be truncated at the bar boundary.
Sample rate44100 HzDirect synthesis and final output sample rate; minimum 1000 Hz.
Output peak.90Target peak normalization for the synthesized single bar; valid range >0…1.
Output peak is normalization, not a safety ceiling. The single bar is always scaled to the selected target peak. The old global Amplitude control was removed because this final peak normalization mathematically cancelled any common amplitude multiplier.

Presets

The names are retained as labels from the script. They should not be interpreted as claims that a ratio uniquely belongs to a particular musical style or cultural tradition.

PresetRatioBarBase frequencyAdditional override
3 vs 4 (Waltz)3:43.0 s196 HzDot duration remains current/default .05 s.
5 vs 7 (Complex)5:73.5 s220 HzDot duration remains current/default .05 s.
2 vs 3 (Simple)2:32.0 s165 HzDot duration remains current/default .05 s.
4 vs 5 (Jazz)4:54.0 s262 HzDot duration remains current/default .05 s.
3 vs 5 (African)3:52.5 s147 HzDot duration remains current/default .05 s.
7 vs 8 (Dense)7:84.0 s330 HzDot duration preset to .03 s.
4 vs 7 (Progressive)4:73.0 s196 HzDot duration remains current/default .05 s.
5 vs 9 (Math Rock)5:95.0 s220 HzDot duration preset to .04 s.

Repeat count is not overridden by these presets. The Details page can also override the preset's Dot duration after preset selection.

Sampling and frequency safety

The higher oscillator is:

f2 = 1.5 × BaseFrequency

The script requires this frequency to remain below:

0.95 × Nyquist

If the upper oscillator reaches or exceeds that boundary, the script stops and asks for a lower Base frequency or a higher Sample rate.

The script also checks:

No resampling or oversampling stage is used.

Output and level

PropertyBehavior
InputNo selected Sound is required.
ChannelsStereo.
Single-bar durationExactly Bar duration.
Final durationBar duration × Repeat count.
Sample rateExactly the Details-page sample rate.
RandomnessNone.
NormalizationThe single bar is always peak-scaled to Output peak before repetition.
Crossfade between barsNone.
Object namepolyrhythm_N1vsN2; repeated outputs add _xN.

Visualization and QC

PanelWhat it shows
A — Common latticeOne bar of actual dot locations on both lines, the common T/LCM temporal lattice, and exact coincidence lines derived from the GCD.
B — Dot kernel → stereo routingThe two raised-cosine-windowed oscillator kernels at their actual frequencies, plus the fixed 0.9/0.3 stereo routing law.
C — Bar assembly → repetitionThe event schedule across repeated bars. Up to the first eight bars are shown when Repeat count is large.
D — Measured output confirmationThe final measured left/right waveforms on a fixed amplitude scale. It confirms the output but is not used to explain the rhythmic model.

The QC summary reports the original and reduced ratios, both spacings, common-lattice step, GCD, LCM, exact coincidences per bar, events per bar, repeat count, Dot duration in milliseconds and samples, minimum spacing in samples, both oscillator frequencies, total duration, target/measured peak, and RMS.

Further reading