This is my second attempt at creating a a Domain Specific Language (DSL) called ''SonicWeave'' for manipulating frequencies, ratios and pitches in Scale Workshop 3.
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.
Still very much a work in progress. Expect things to shift around as I design a parseable grammar.
== Units as vectors ==
== Values ==
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).
Values consist of strings, functions and extended time monzos which combine a rational time exponent, rational prime exponents, a multiplicative rational residual and a catch-all real cents offset.
[[File:Units-as-vectors.png|thumb|Hertz, Newton and Pascal plotted on a basis consisting of the exponents of SI base units.]]
== Domains ==
Theres a linear domain where 3/2 + 3/2 means 3 (as a ratio of two frequencies) and a logarithmic domain where 3\2 + 3\2 means 8 (as a ratio of two frequencies).
== Tiers ==
Types are organized into tiers consisting of booleans, integers, rationals, radicals (i.e. rationals raised to rational powers) and reals.
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 [[Wikipedia:Fundamental theorem of arithmetic|fundamental theorem of arithmetic]] we can choose the exponents of prime numbers to get a vector representation of any rational multiple of 1 Hz.
</math>
== Type system ==
Values are dressed into types to implement domain-specific operator overloading and type-aware function overloading.
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.