Tuesday, July 30, 2024

The Spiral Harp

6-sided spiral harp, concept art
A spiral tuning system is a layout for string instruments based on any of the diverse configurations of a spiral polygonal chain, known as a spirangle, utilizing the segment's length as source for pitch, either as string length or frequency.

These systems are aperiodic (with exceptions) and possess an infinite range of possibilities. Among these configurations defined by their sides and segments, many prove musically practical, with potential for some to manifest as tangible instruments, such as spiral harps. (An instrument with a single wound string where pitch is linked solely to string length, and tension becomes relative.)

Each unique configuration unveils distinct chords and progressions, often showcasing geometric patterns.



This audio clip features a short melody played on a digitally modeled harp-like instrument tuned according to a six-sided spiral polygonal chain (as depicted in the concept art). The final, highest note corresponds to the shortest 'string' of the spiral.

Theory:

Each tuning can be mainly defined by the amount of sides and the margin, and can be named:

S6m1 - "S" for spiral, followed by the number of sides, "m" for margin; if its value is 1, it can be omitted (e.g., S6m1 = S6). [This tuning is of main interest.]

S5.5 - Five-and-a-half-sided spiral with margin 1 (omitted).

S1m1.05946 - One-sided spiral with a margin of the twelfth root of 2.

S7r2c1 - Seven-sided spiral with a margin of 1 (omitted), with an initial radius of 2, and constant increment c = 1. When omitted, spirals initial radius is 0, c = 1.

iS6m1 - Inverted six-sided spiral with a margin of 1.

The parameters affecting the resulting relative segment length progression are:

Amount of sides: from 0 to infinity.

Margin: usually 1 (to mimic spider-webs). This property can be (unnecessarily) employed to generate equal-division systems. For example, the angle is calculated with \( \frac {2\pi}{sides}\), so when sides are \(1\), \( \frac{1}{2}\), or \( \frac{1}{4}\), etc., it leaves the margin as the sole control for segment length increase. For instance, a one-sided spiral with a radius of approximately \( 1.05946 = \sqrt[12]{2} \) generates a 12 equal division system. From this perspective, equal-division systems can be seen as a subset of spirals.

Initial radius: usually 0 Using a different initial radius opens another dimension of progression; however, it seems to mostly affect the initial segments, and the rest of the spiral converges quickly with its version with radius 0.

Inversion: This parameter doesn't affect the progression but rather how the progression is treated, as string length or as frequency.

Spiral polygonal chains with different margins,

Spiral polygonal chains with different sides.

Construction:

Starting from the center, and considering the segment's length as string length, the first being the shortest, becomes the highest pitch so the tunings are defined inversely.
Since, in most cases, they are aperiodic, the system sizes are infinite, it will depend on how many notes one wants to calculate.
Most spiral settings cover the audible range with less than 300 segments.
For instance, a six-sided spiral harp with margin 1, comprised of 120 segments spans approximately five octaves.
The spiral can be of any size, a diameter, or scale property, while changing the length of the segments, won't alter their relative length.(if started at 0,0)
We assign a frequency to the first segment, e.g. 8000hz, and the rest of the notes are calculated from it.

Unwound spirals next to each other, firsts 10 segments. With margin 1. From 0.5 to 2 sides (150 spirals, in 0.01 step) First segment from each spiral is normalized to the same length. Segments are colored by octave, this means, every red is the same chroma. The 1-sided spiral has all its segments of the same length in this configuration with margin 1. (For the mathematicians watching the video (?) chroma color coding in music just maps log2(x) mod 1 to the hue circle, here RGB, thought I can argue endlessly on how uniform a hue circle can be haha)


Note: I just realized some of these have errors, I'll fix these when I çan, see the app for the correct and implemented formulas.

Algorithms for Segment Length Generation:

1- Euclidean distance between consecutive points on a spiral:

Given:

Radius: \(r= (z \times m)\times (m^n)\) where \(z\) is the constant size increment, \(m\) is margin and \(n\) is the point's index, starting at \(0\).

Angle \(a = \frac{2\pi}{s}\) where \(s\) is the amount of sides of the spiral

The x-coordinate and y-coordinate of a point on the spiral are calculated using:

\(x = r \times \cos(a)\)

\(y = r \times \sin(a)\)

The distance between two consecutive points on a spiral in Cartesian coordinates \((x_1,y_1)\) and \((x_2,y_2)\) is calculated using the Euclidean distance formula:

\(d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2} \)

2- Direct Polar Calculation: Instead of converting to Cartesian coordinates, we can calculate the distance directly in polar coordinates. Let \(r_n\) and \(r_{n+1}\) be the radii of two consecutive points, and \(a\) be the constant angle between them. The distance \(d\) can be calculated using the law of cosines:

\(d = \sqrt{r_n^2 + r_{n+1}^2 - 2r_n r_{n+1}\cos(a)}\)

Since \(r_n = (z \times m) \times m^n\) and \(r_{n+1} = (z \times m) \times m^{n+1}\), we can simplify this to:

\(d = (z \times m) \times m^n \sqrt{1 + m^2 - 2m\cos(a)}\)


Properties:

One characteristic that differs from most tunings is that each successive lower octave has more notes. At first sight, the different progressions don't seem to say much. It helps to analyze each tuning by looking at its full interval matrix, revealing that some strings have many more types of minor thirds, while others have more fifths. Some completely dodge certain harmonics, regardless of how many "strings" you add; some combinations just never happen.

The crucial factor is the number of sides in the spiral, as this directly determines the chords exposed in each row. Some configurations naturally lend themselves to more intuitive chord progressions. The initial segments of the progression are the most susceptible to alteration due to the inherent truncation of the spiral at its beginning. However, even with these truncated beginnings, distinct patterns still emerge. The remainder of the progression is similar across most configurations[...]. From a string length perspective (moving away from the center, where truncation errors diminish), the progression approximates an arithmetic series, seemingly increasing at a constant rate.

Considerations for spiral tunings and possible harps:

For a real spiral, a logical number of sides starts at 3 (greater than 2, avoiding string overlap) and ends at some point depending on the expected range (e.g., 12 sides). However, a real harp beyond this will have too many or too short strings to be practical. Regarding the margin, the value is usually 1; going too far away from this eliminates the possibility of the spiral as an instrument, and so does this tuning inversion, the progression as frequency (which is interesting on its own, but not spider-web manifestable).



An open-source, virtual playable version is accessible link.

The new version is available as a interface in MIND.

The concept art is a 3d model post processed with AI.



---


Spiral Harp (Version 1.999...)


Recombined previous versions—bringing the analysis tools together with the synths and sequencers. Added MIDI key support, a new sequence generator, and minor fixes. Note: The app is still an experimental prototype!

Interface & Manual


Click Start Audio.

Spiral Settings


- Sides: Specify the number of sides of the polygonal chain (default: 12).
- Segments: Number of strings or segments in the chain (default: 100).
- Margin: The margin of the spiral or its growth rate (default: constant 1).
- Initial Radius (Init): All spirals start with a radius of zero at the origin $(x, y = 0, 0)$ by default.
- Size / Zoom: Controls the scale or size of the rendered spiral. This does not change the resulting tuning system.
- Display Chromas (ON/OFF): Activates color-coding by octave chromas in the spiral and analysis tools. Starting at RGB red by default, it maps pitch frequencies logarithmically ($\bmod 1$) to the hue wheel so that strings related by octaves share the same color. Color-coding provides quick visual insights (e.g., complementary colors represent tritones).

Spiral UI Elements


Labels N, L, F, and R stand for Number, Length, Frequency, and Ratio.

The HUD updates when playing a note (via sequencer, keyboard/MIDI, or by hovering the cursor over and playing a string on the spiral).

Number: The index number of the segment (the shortest is $N = 0$).
Length: The unit length of the segment, irrespective of zoom/scale. The first segment is always normalized to length = 1, and the rest are computed from it.
Frequency: The final frequency played by the synthesizer (frequency mappings are detailed below).
Ratio: Displays the normalized frequency ratios, inverted this time—the last segment has a frequency ratio = 1. As you change the number of strings, the last segment always becomes the unison. This is designed for traditional tuning analysis where intervals are listed as higher ratios to a lower unison (e.g., .scl files).

Frequency Mapping


Select how to map the computed strings to a frequency range by fixing either a minimum or a maximum.

By default, the maximum is set to 8000 Hz. The shortest string of the spiral is fixed to this frequency, and the rest of the notes are calculated from it.
When selecting min, you define the pitch of the current largest string (e.g., 100 Hz).

Scale Display


In a logarithmic scale, this displays the current spiral tuning against a fixed ruler of 1:2 octaves. This lets you quickly inspect metrics such as the audible range/number of octaves available on the harp, or how different settings (sides, margin) alter the resulting pitch sequence. The ruler switches from base-left to base-right depending on your frequency mapping. These segments are also playable with the cursor.

Main Settings


Master Volume: Controls the final volume of both synths.
Play with Cursor (ON/OFF): Enables or disables playing the spiral harp with the cursor.
Play with Keyboard (ON/OFF): Enables or disables playing with the computer keyboard.
Keyboard Range: If you don't have a MIDI device, the app includes a built-in PC keyboard mapping. However, a standard keyboard cannot cover large spirals (even MIDI with 128 keys falls short for massive spirals with 500 segments, where the sequencer gets wild), so exactly 21 keys are assigned by default to the first 21 shortest strings. This range slider lets you map to a different subset of these strings. Its maximum is bound to the number of segments, so sliding it fully to the right always maps to the final 21 strings (keys: `q` through `m`).
MIDI (ON/OFF) and MIDI SCAN: Rescans for MIDI devices (browsers will prompt for permission). (MIDI maps C0 to the central segment of the spiral)


---

Synthesizers Settings


The app includes two similar synths—one for the keyboard/mouse and another for the sequencer, which features a few extra options. Both synths are straightforward with independent volume controls.

Sound: Select built-in sounds and instruments, ranging from basic waveforms (sine, square, triangle, saw) to Strings, Keys (Electric Piano), and Xentone (which builds a weird, complex spectrum derived from the spiral configuration).
Envelope: Attack, Release, and Note Length.

Fixed Effects


Vibrato: Amount and Speed (ON/OFF).
Delay: Time (ms), Feedback, Dry (ON/OFF).

---

Sequencer Settings


Sequence: Text box for the sequence, using comma-separated numbers. Numbers represent segment indices for the sequencer to play; if an entry exceeds the current number of segments, it simply wraps around.
PLAY and STOP buttons
Speed: In milliseconds. (Note: This is not a MIDI player; it is a fixed-speed, monophonic sequencer.)
Set Order: Rewrites the current sequence using typical arpeggiator behaviors: Up, Down, Converge, Diverge, and Random.

---

Chord Finder


Search For: Text box for a list of frequency ratios to search for within the spiral (entered as decimal ratios—for example, searching for a perfect fifth 3/2 means writing 1.5).
The search includes a cent tolerance parameter (default: 15 cents) and accounts for octave chromas, as almost all built-in instruments are harmonic and exhibit chroma  equivalence at the octave 1:2 (2/1, 2.0, excluding the Xentone).

Once you set a list, clicking a string will search for matching chords, populate the sequence box, and trigger the sequencer.

Tip: If you only write 1.5 and click a string, it will only play fifths starting from that string. To include the root/unison, write 1, 1.5 or 1.5, 2. In short: always include a 1 or a 2 as your reference unison.
By default, it contains a 5EDO scale.

Presets: Min, Maj, Dim, Aug, 12edo, 5edo. Clicking any of these instantly updates the search list so you can rapidly start building chord progressions.

Mini Tutorial


Spiral configurations don't share the exact same harmonic content, and not every string has access to every chord—this is what makes the space explorable.

1. Using the default spiral (12 sides, 100 segments, margin 1, init 0), activate Display Chromas.
2. Turn off "Play with Cursor" to prevent accidental note triggers while hovering (allowing you to use click-to-trigger with the sequencer).
3. Click the Maj preset and click around different strings (default tolerance is 15 cents).
4. You will notice that most blue-ish strings contain a complete major chord. Moving toward green and yellow, chords become sparser (some may yield only a fifth or a major third). By the time you reach red and magenta, major chords disappear entirely—right before cycling back to blue, which boasts the densest major collections.

Questions to explore: What typical chords are available in the red region? Are there privileged intervals, chords, or scales that most strings or spirals relate to? As a 1D dynamical system, its octave density ($\log_2(n) \bmod 1$) is non-uniform—interesting properties await. Combined with the included analysis tools, these patterns become much easier to parse.

---

Sequence Generator


Designed to generate "random" quick sequences that retain enough structure to sound musical. It relies on modular arithmetic and concatenates a series of generation steps.

How It Works


It takes a multiplicative group modulo an integer (e.g., the default $Z/18Z^*$), lists its elements, generates the subgroup for each, and concatenates them into a single string.

These are fascinating to explore because the resulting sequences naturally possess enough structural integrity to sound melodic (sometimes even motif/theme-like). Setting the group to a moderately large prime like 47 generates a sequence of 1,521 numbers where recurring melodic themes emerge organically from the inherent symmetry of these groups.

Options


Order: Sets the order/size of the group. Next to it, the app displays the number of elements using Euler's totient function.
Sequence Length Control: FULL, /2, /4. These control sequence length. FULL renders all generator steps, while /2 or /4 produce shorter sequences based on a randomized control using fewer generators. Displays the final sequence size.
Index Padding: Lets you sweep the sequence through the harp. For example, if you have a simple sequence like 1, 7, 13, 1..., padding +5 shifts all values 6, 12, 18, 6.... It wraps safely around the total number of strings.
Invert (ON/OFF): Reflects the sequence. In un-inverted sequences, 1 tends to occur more frequently because it represents the identity in concatenated subgroups. Reflecting the sequence inverts this dynamic so lower notes become the unison.
SET Button: Writes the sequence to the sequencer list without starting playback automatically. Click SET, then click PLAY in the sequencer.

---

Analysis Tools


Octave Density


Displays the distribution of pitches modulo octaves, color-coded by default. These marks are also interactive: hovering over them (e.g., over the green region) highlights and plays the corresponding green strings in the spiral.

- Features a fixed 12-EDO ruler in the background to quickly identify interval density against a familiar grid. Because the matrix is folded from the shortest string, you can observe how drastically it changes across different spirals—even though all converge to an arithmetic series as $N \to \infty$. The real action happens around the centers of "error".
- Auto-Update (ON/OFF): Enables or disables live automatic updates of this display when modifying the spiral (can be disabled if performance drops).
- Scale: Linear or Logarithmic.
- DRAW / CLEAR buttons.

Spiral Sides Length Comparison


Renders the segments side-by-side. If set to a larger number (e.g., 100), all spirals flatten into an almost constant line with no discernible difference. By default, it is set to 20 strings so you can inspect how minimal changes to the spiral make the first segment chromatically distinct from the rest, altering the available chords row by row. Includes a fixed octave ruler and bar width controls in pixels.

Multi-Spiral Segment Comparison


Disabled by default. Renders a series of unwound spirals side-by-side with stacked segment lengths, letting you inspect precisely what drives the "error" at the initial segments.

Sides (From / To): Determines the range of spiral sides to draw (default: 0 to 10).
Step: Defines the resolution of spiral sampling (default: 0.1).
Combined effect: Draws 100 spirals starting at 0 with increments of 0.1 up to a 10-sided spiral, using 10 segments by default. All spirals normalize the first segment to the same size, with octave chromas active (starting at red by default).

---

Scale Output


Export your tuning as a standard Scala tuning file (`.scl`).

Conversion Types


CENTS: Converts the spiral strings directly into cents.
QUICK: Generates a rough fraction of the current decimal ratio. For example, if the ratio is 1.458927123, it simplifies it to 145892/100000.
RATIONAL APPROXIMATION: Builds a cleaner fraction using a GCD algorithm within a small tolerance (epsilon defaults to $10^{-6}$). Observing how the spiral truncates to simpler intervals at low tolerances looks interesting.


---

mathematical over-extensions:

The geometry of a spirangle (a polygonal Archimedean spiral) generates a discrete sequence of segment lengths $L_n$, a self-similar, non-logarithmic progression

Free Generated Set / Sequence: the "spiral harp" is an indexed geometric sequence in a metric space, or a point set generated by a 1D discrete dynamical system.


Convergence to Arithmetic Progression:

For $m=1$, the radius grows linearly: $r_n = z \cdot n$. with the polar distance equation, the $n$-th segment length simplifies:

$$L_n = z \sqrt{n^2 + (n+1)^2 - 2n(n+1)\cos(a)}$$

so as $n \to \infty$, the ratio $L_n / n$ converges to a constant dependent on $a = \frac{2\pi}{s}$:

$$\lim_{n\to\infty} \frac{L_n}{n} = \sqrt{2(1 - \cos a)} = 2 \sin\left(\frac{\pi}{s}\right)$$


this means that far from the origin, $L_n \approx 2z \sin(\pi/s) \cdot n$. The string lengths form an approximate arithmetic sequence, which implies the frequencies $f_n \propto \frac{1}{n}$ form an overtone series (harmonic series) as $n \to \infty$.



the segment sequence $L_n(s, m, z)$.

the standard case ($m = 1$, constant step $z$):

$$L_n = z \sqrt{2n^2 + 2n + 1 - 2n(n+1)\cos\left(\frac{2\pi}{s}\right)}$$

Or:

$$L_n = z \sqrt{4n(n+1)\sin^2\left(\frac{\pi}{s}\right) + 1}$$

This closed form highlights the geometry, when $n$ is large, $L_n \approx 2z \sin(\pi/s) \cdot (n + 1/2)$, showing the linear asymptotic growth and the pitch interval (in millioctaves) between adjacent notes $n$ and $n+1$ is:

$$\Delta I_n = \log_2\left(\frac{L_{n+1}}{L_n}\right)$$

Because $L_n$ grows linearly, $\Delta I_n \to 0$ as $n \to \infty$, meaning the pitch intervals become progressively smaller, microtonal density increases with string length.




the microtonal asymmetry of the sequence and physical playability

the chord finder: by scanning the sequence via $\log_2(L_n) \pmod 1$ within a cent tolerance window $\epsilon$, we construct a geometric chord lookup table (see later)


geometric patterns emergence (log-spiral intersections)

When the auto-chord-finder highlights major/minor triads or scales, the visual patterns on the physical 2D spirangle aren't random they form secondary geometric curves.

Because the strings lie on a 2D spiral and pitch is proportional to radius/length, looking for a specific interval ratio $r = f_2 / f_1$ translates to finding pairs of indices $(n, k)$ such that $\frac{L_k}{L_n} \approx r$


On the polygonal chain:

Octaves ($r \approx 2$): String indices that yield octaves scale quadratically or near-exponentially in index distance, forming expanding logarithmic spirals across the frame.

Fifths ($r \approx 1.5$), Major Thirds ($r \approx 1.25$): these form family curves (similar to the phyllotaxis spirals seen in sunflower seed heads or pinecones)

Connecting all nodes that contain a valid Major triad on the 2D layout yields a lattice of intersecting Archimedean rays.

---

Brute-Force Chord Finder

search algorithm for the app documentation, 

Tolerance Interval Match Function:

Let $P_n = \log_2(L_n) \pmod 1$ be the pitch class (in octave fractions, $P_n \in [0, 1)$).

A set of indices $\{n_1, n_2, \dots, n_k\}$ forms a target chord $C = \{c_1, c_2, \dots, c_k\}$ (where $c_i$ are target pitch classes in cents $/ 1200$) under tolerance $\epsilon$ if there exists a root offset $R$ such that:

$$\min_{m \in \mathbb{Z}} \left\vert{} (P_{n_i} - R) - c_i - m \right\vert{} < \frac{\epsilon}{1200} \quad \forall i \in \{1, \dots, k\}$$

because $P_n$ is monotonic-ish with decaying increments, it dosn't even need full $O(N^k)$ brute-force scans across all strings: Calculate $P_n = \log_2(L_n) \pmod 1$ once. $L_n$ grows predictably. binary search or two-pointer bounds to find all intervals within $\epsilon$ in $O(N \log N)$ time.



In microtonal theory and mathematical musicology, pitch space is typically mapped to either frequency space $\mathbb{R}^+$ (measured in Hz), string length space $\mathbb{R}^+$, or logarithmic pitch-class space $\mathbb{T} = \mathbb{R}/\mathbb{Z} \cong [0, 1)$ (measured in cents or octave fractions).


1. The Fundamental Length Set $\mathcal{L}$

The core geometric object is the ordered infinite set (or sequence) of discrete segment lengths $\mathcal{L}(s, m, z)$.

For the standard Archimedean case ($m = 1$, increment $z$, and $s$ sides):

$$\mathcal{L}(s, m, z) = \left\{ L_n \in \mathbb{R}^+ \;\middle\vert{}\; L_n = (z \cdot m) m^n \sqrt{1 + m^2 - 2m\cos\left(\frac{2\pi}{s}\right)}, \, n \in \mathbb{N}_0 \right\}$$

When $m = 1$, this simplifies to:

$$\mathcal{L}(s, z) = \left\{ z \sqrt{4n(n+1)\sin^2\left(\frac{\pi}{s}\right) + 1} \;\middle\vert{}\; n \in \mathbb{N}_0 \right\}$$



2. The Frequency Spectrum Set $\mathcal{F}$

To convert lengths to physical pitch, we define a mapping function $f: \mathbb{R}^+ \to \mathbb{R}^+$. Given a fundamental base frequency $f_0$ anchored to the shortest segment $L_0$, the pitch spectrum $\mathcal{F}$ is:

$$\mathcal{F}(s, z, f_0) = \left\{ f_n \in \mathbb{R}^+ \;\middle\vert{}\; f_n = f_0 \cdot \frac{L_0}{L_n}, \, L_n \in \mathcal{L}(s, z), \, n \in \mathbb{N}_0 \right\}$$

(If using the frequency inversion parameter $iS$, $f_n = f_0 \cdot \frac{L_n}{L_0}$ instead).




3. The Pitch-Class Set $\mathcal{P}$ on the Octave Torus $\mathbb{T}$

To analyze octave-equivalent pitch structures (chroma), we map frequencies or lengths into the unit interval $[0, 1) \cong \mathbb{R}/\mathbb{Z}$ using base-2 logarithms(the app uses mostly harmonic timbres, so chroma is effectively octave based, except for the spiral timbre which is far more complex to analyze meaningfully):

$$\mathcal{P}(s, z) = \left\{ p_n \in [0, 1) \;\middle\vert{}\; p_n = \log_2\left(\frac{L_n}{L_0}\right) \pmod 1, \, n \in \mathbb{N}_0 \right\}$$

In mocts, this set is simply $1000 \cdot \mathcal{P}$.




4. The Interval Set (Dyadic Structure) $\mathcal{I}$

the Interval Set represents all available intervals (ratios) formed between any two strings $i$ and $j$ in the system:

$$\mathcal{I}(s, z) = \left\{ r_{i,j} \in \mathbb{R}^+ \;\middle\vert{}\; r_{i,j} = \frac{L_j}{L_i}, \, (i, j) \in \mathbb{N}_0^2 \right\}$$

On the octave torus, the set of pitch-class intervals $\Delta \mathcal{P}$ is the non-transitive difference set:

$$\Delta \mathcal{P}(s, z) = \left\{ \delta_{i,j} \in [0, 1) \;\middle\vert{}\; \delta_{i,j} = \vert{}p_j - p_i\vert{} \pmod 1, \, p_i, p_j \in \mathcal{P} \right\}$$



5. The Interval Density Function

(the "matrix accumulation"), take $\mathcal{P}$ as a discrete point measure $\mu_N$ on the circle $\mathbb{S}^1$ as $N \to \infty$:

$$\mu_N = \frac{1}{N} \sum_{n=0}^{N-1} \delta_{p_n}$$

where $\delta_{p_n}$ is the Dirac delta measure centered at pitch class $p_n$.

the IDF $\rho(\theta)$ on the interval $\theta \in [0, 1200)$ cents is the pushforward limit density of pairwise differences:

$$\rho(\theta) = \lim_{N \to \infty} \frac{1}{N^2} \sum_{i=0}^{N-1} \sum_{j=0}^{N-1} \mathbf{1}_{\{[\Delta p_{i,j} - \theta\vert{} < \epsilon\}}$$

Because $L_n \approx c \cdot n$, the sequence of pitch classes $p_n \sim \log_2(n) \pmod 1$ is non-uniformly distributed over the torus, meaning $\rho(\theta)$ yields a smooth, continuous density function with distinct peaks rather than a flat uniform distribution! (see s6 matrix!)







No comments:

Post a Comment

Quasicrystal Drum Machine, Aperiodic Rhythms

Musical rhythm does not require repetition. A listener can perceive a distinct groove from balance, distribution, and local predictability, ...