User:Frostburn/SonicWeave

Revision as of 11:28, 10 December 2023 by Frostburn (talk | contribs) (Sketch SonicWeave type system up to real linear types.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

Still very much a work in progress. Expect things to shift around as I design a parseable grammar.

Values

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.

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 integers, rationals, radicals (i.e. rationals raised to rational powers) and reals.

[math]\displaystyle{ \mathbb{Z} \subset \mathbb{Q} \subset \mathrm{radical} \subset \mathbb{R} }[/math]

Type system

Values are dressed into types to implement domain-specific operator overloading and type-aware function overloading.

Rational linear types

[math]\displaystyle{ \begin{align} \mathrm{boolean} &= \{0, 1\} \\ \mathrm{integer} &= \mathbb{Z} \supset \{1, 2, 3, 4\} \\ \mathrm{fraction} &\supset \{3/2, 5/3\} \\ \mathrm{decimal} &\supset \{(1.2), (1.4)\} \\ \mathrm{rational} &= \mathbb{Q} = \mathrm{integer} \cup \mathrm{fraction} \cup \mathrm{decimal} \end{align} }[/math]

Radical linear types

[math]\displaystyle{ \begin{align} \mathrm{radicalExpression} &\supset \{\sqrt{3}, 2^\frac{5}{3}\} \\ \mathrm{radical} &= \mathrm{rational} \cup \mathrm{radicalExpression} \end{align} }[/math]

Real linear types

[math]\displaystyle{ \begin{align} \mathrm{integer!} &\supset \{69!, 420!\} \\ \mathrm{decimal!} &\supset \{3.14159!, 2.718!\} \\ \mathrm{real} &= \mathbb{R} = \mathrm{integer!} \cup \mathrm{decimal!} \end{align} }[/math]

Note: Real linear types are mostly an artifact of the catch-all property extended time monzos. Not recommended for everyday use.