User:Frostburn/SonicWeave

From Xenharmonic Wiki
Jump to navigation Jump to search

This is a description of the design philosophy behind the Domain Specific Language (DSL) called SonicWeave for manipulating frequencies, ratios and pitches in Scale Workshop 3.

Units as vectors

Let's first establish that it makes sense to talk about quantities as vectors. We can choose a basis consisting of the exponents of the second, the metre and the kilogram. Now we can plot Hertz at -1 on the exponents-of-second axis, Newton at coordinates (-2, 1, 1) and Pascal at coordinates (-2, -1, 1).

Hertz, Newton and Pascal plotted on a basis consisting of the exponents of SI base units.

Rational frequencies as vectors

When dealing with musical data we mostly care about frequencies measured in Hertz. To represent frequencies other than 1 Hz we need more basis vectors and by the fundamental theorem of arithmetic we can choose the exponents of prime numbers to get a vector representation of any rational multiple of 1 Hz.

Using the basis of (the exponents of) the second, prime 2 and prime 3 we can plot 1 Hz at (-1, 0, 0), 2 Hz at (-1, 1, 0), 3 Hz at (-1, 0, 1) and 4/3 Hz at (-1, 2, -1). [TODO: image]

To make sense of vector addition we say that objects in this space represent the frequency you get at the intersection of the line from origin and the Hertz plane e.g. the sum of 9 Hz and 4 Hz is 36 Hz² and represent the frequency 6 Hz i.e. the geometric average of 9 Hz and 4 Hz. This is one part of what the ablog (short for absolute logarithmic) function in SonicWeave does. [TODO: image]

This works for everything except for objects with 0 as the exponent of the second. These objects form the relative echelon in Sonic Weave where the conversion from linear factors to logarithmic pitch is handled by the logarithmic function. In this document we notate it using a right-facing arrow:

[math]\overrightarrow{2^x 3^y 5^z \ldots} \mapsto x e_2 + y e_3 + z e_5 + \ldots, x, y, z, \ldots \in \mathbb{Q}[/math]

Relative logarithmic vector addition is the same as multiplication of the represented linear values.

[math]\overrightarrow{a} + \overrightarrow{b} = \overrightarrow{a b}[/math]

Conversion from relative to absolute

The second part of ablog requires a unison frequency declaration like 1/1 = 440 Hz. In this document we denote [math]e_0 = \overrightarrow{1 Hz}[/math] and the declared unison frequency as [math]e_0'[/math] e.g [math]e_0' = \overrightarrow{440 Hz}[/math]

Relative logarithmic values are converted to absolute logarithmic frequencies simply by adding [math]e_0'[/math]. e.g. ablog(logarithmic(81/55)) is

[math] \overrightarrow{\frac{81}{55}} + e_0' = (4 e_3 - e_5 - e_{11}) + (3 e_2 + e_5 + e_{11} + e_0) = 3 e_2 + 4 e_3 + e_0 = \overrightarrow{648 Hz} [/math]