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.
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.
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
- Run
PolyrhythmsFromDots.praat. No input Sound is required. - Choose Custom or one of the eight named ratio presets.
- For Custom, set Dots line 1, Dots line 2, Bar duration, Repeat count, and Base frequency.
- Enable Edit details to change Dot duration, Sample rate, and Output peak.
- 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:
spacing2 = T / n2
The actual event times are:
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:
Common temporal lattice
Every event from both lines falls on the common lattice:
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 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:
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:
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
| Line | Frequency |
|---|---|
| Line 1 / top | Base frequency |
| Line 2 / bottom | 1.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:
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.
Bar repetition
The script first creates and peak-scales exactly one stereo bar. Repeat count then determines how many identical copies are concatenated.
For Repeat count > 1:
- the original bar is copied
N - 1times; - all copies are concatenated in one operation;
- there is no crossfade between bars;
- there is no timing variation between repetitions;
- there is no resynthesis or phase randomization from bar to bar.
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
| Control | Default | Range / behavior | Meaning |
|---|---|---|---|
| Preset | Custom | Custom + 8 named presets | Overrides the principal ratio/timing/frequency values listed below. |
| Dots line 1 | 5 | Integer ≥1 | Number of evenly spaced top-line events per bar. |
| Dots line 2 | 7 | Integer ≥1 | Number of evenly spaced bottom-line events per bar. |
| Bar duration | 2.0 s | Positive | Common duration occupied by both equal-division grids. |
| Repeat count | 1 | 1–64 | Number of bit-identical bars concatenated in the final output. |
| Base frequency | 220 Hz | Positive | Line-1 oscillator frequency; line 2 is fixed at 1.5× this value. |
| Edit details | off | boolean | Opens Dot duration, Sample rate, and Output peak. |
Details page
| Control | Default | Behavior |
|---|---|---|
| Dot duration | .05 s | Requested tone-kernel duration; must occupy at least four samples. Late dots can be truncated at the bar boundary. |
| Sample rate | 44100 Hz | Direct synthesis and final output sample rate; minimum 1000 Hz. |
| Output peak | .90 | Target peak normalization for the synthesized single bar; valid range >0…1. |
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.
| Preset | Ratio | Bar | Base frequency | Additional override |
|---|---|---|---|---|
| 3 vs 4 (Waltz) | 3:4 | 3.0 s | 196 Hz | Dot duration remains current/default .05 s. |
| 5 vs 7 (Complex) | 5:7 | 3.5 s | 220 Hz | Dot duration remains current/default .05 s. |
| 2 vs 3 (Simple) | 2:3 | 2.0 s | 165 Hz | Dot duration remains current/default .05 s. |
| 4 vs 5 (Jazz) | 4:5 | 4.0 s | 262 Hz | Dot duration remains current/default .05 s. |
| 3 vs 5 (African) | 3:5 | 2.5 s | 147 Hz | Dot duration remains current/default .05 s. |
| 7 vs 8 (Dense) | 7:8 | 4.0 s | 330 Hz | Dot duration preset to .03 s. |
| 4 vs 7 (Progressive) | 4:7 | 3.0 s | 196 Hz | Dot duration remains current/default .05 s. |
| 5 vs 9 (Math Rock) | 5:9 | 5.0 s | 220 Hz | Dot 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:
The script requires this frequency to remain below:
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:
- Dot duration spans at least four samples.
- The densest inter-dot spacing is at least one sample.
- Repeat count does not exceed 64.
No resampling or oversampling stage is used.
Output and level
| Property | Behavior |
|---|---|
| Input | No selected Sound is required. |
| Channels | Stereo. |
| Single-bar duration | Exactly Bar duration. |
| Final duration | Bar duration × Repeat count. |
| Sample rate | Exactly the Details-page sample rate. |
| Randomness | None. |
| Normalization | The single bar is always peak-scaled to Output peak before repetition. |
| Crossfade between bars | None. |
| Object name | polyrhythm_N1vsN2; repeated outputs add _xN. |
Visualization and QC
| Panel | What it shows |
|---|---|
| A — Common lattice | One 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 routing | The two raised-cosine-windowed oscillator kernels at their actual frequencies, plus the fixed 0.9/0.3 stereo routing law. |
| C — Bar assembly → repetition | The event schedule across repeated bars. Up to the first eight bars are shown when Repeat count is large. |
| D — Measured output confirmation | The 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
- Pressing, J. (2002). “Black Atlantic Rhythm: Its Computational and Transcultural Foundations.” Music Perception, 19(3), 285–310. DOI: 10.1525/mp.2002.19.3.285.
- Locke, D. (1982). “Principles of Offbeat Timing and Cross-Rhythm in Southern Ewe Dance Drumming.” Ethnomusicology, 26(2), 217–246. DOI: 10.2307/851524.