Skip to content

Commit

Permalink
Update sonic-weave dependency
Browse files Browse the repository at this point in the history
Use new program execution API.
Use new `defer` feature in some of the presets.

SonicWeave changelog:
- Re-enable irrational ranges
- Restrict bra-ket syntax (`dot`)
- Reserve `~dot` for non-strict dot products
- Replace `??` with `al`
- Shorten `===` to `==`
- Replace `!==` with `<>`
- Implement deferred actions
- Implement arithmetically accumulative repetition
- Implement `vdot` and `mdot`
- Implement matrix transposition
- Implement conversion between arrays, monzos and vals
- Implement a helper for extracting the domain of an interval
- Add helpers for inlining throwing and assertions
- Add `sof` as an alternative for the binary backslash
- Implement `weilHeight` utility
  • Loading branch information
frostburn committed May 7, 2024
1 parent 8dc2f7a commit 1db8ea7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 30 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scale-workshop",
"version": "3.0.0-beta.22",
"version": "3.0.0-beta.23",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
Expand All @@ -21,7 +21,7 @@
"moment-of-symmetry": "^0.4.2",
"pinia": "^2.1.7",
"qs": "^6.12.0",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.31",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.33",
"sw-synth": "^0.1.0",
"temperaments": "^0.5.3",
"values.js": "^2.1.1",
Expand Down
4 changes: 3 additions & 1 deletion src/exporters/__tests__/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export function getTestData(appTitle: string) {
type: 'CentsLiteral',
sign: '',
whole: 100n,
fractional: ''
fractional: '',
exponent: null,
real: false,
}),
relativeC5,
new Interval(
Expand Down
6 changes: 3 additions & 3 deletions src/presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
},
"17rast": {
"name": "17edo Rast",
"source": "M2 white\nn3 gray\nP4 white\nP5 white\nM6 white\nn7 gray\nP8 white\nmap(str)\n17@\n",
"source": "defer 17@\nM2 white\nn3 gray\nP4 white\nP5 white\nM6 white\nn7 gray\nP8 white\nmap(str)\n",
"categories": ["MOS", "equal temperament"]
},
"22porcupine8": {
Expand Down Expand Up @@ -260,7 +260,7 @@
},
"31meantone19": {
"name": "31edo meantone[19]",
"source": "A♮4 = 440 Hz\nA♯4 navy\nB♭4 maroon\nB♮4 white\nC♭5 maroon\nC♮5 white\nC♯5 navy\nD♭5 maroon\nD♮5 white\nD♯5 navy\nE♭5 maroon\nE♮5 white\nE♯5 navy\nF♮5 white\nF♯5 navy\nG♭5 maroon\nG♮5 white\nG♯5 navy\nA♭5 maroon\nA♮5 white\nmap(i => str(i)[..1])\n31@\n",
"source": "defer 31@\ndefer map(i => str(i)[..1])\nA♮4 = 440 Hz\nA♯4 navy\nB♭4 maroon\nB♮4 white\nC♭5 maroon\nC♮5 white\nC♯5 navy\nD♭5 maroon\nD♮5 white\nD♯5 navy\nE♭5 maroon\nE♮5 white\nE♯5 navy\nF♮5 white\nF♯5 navy\nG♭5 maroon\nG♮5 white\nG♯5 navy\nA♭5 maroon\nA♮5 white\n",
"categories": ["MOS", "equal temperament"]
},
"46sensi11": {
Expand All @@ -275,7 +275,7 @@
},
"bohlenpierceeq": {
"name": "Bohlen-Pierce equal (13ed3)",
"source": "27/25 black 'C♯/D♭'\n25/21 white 'D'\n9/7 white 'E'\n7/5 white 'F'\n75/49 black 'F♯/G♭'\n5/3 white 'G'\n9/5 white 'H'\n49/25 black 'H♯/J♭'\n15/7 white 'J'\n7/3 white 'A'\n63/25 black 'A♯/B♭'\n25/9 white 'B'\n3/1 white 'C'\nb13@\n",
"source": "defer b13@\n27/25 black 'C♯/D♭'\n25/21 white 'D'\n9/7 white 'E'\n7/5 white 'F'\n75/49 black 'F♯/G♭'\n5/3 white 'G'\n9/5 white 'H'\n49/25 black 'H♯/J♭'\n15/7 white 'J'\n7/3 white 'A'\n63/25 black 'A♯/B♭'\n25/9 white 'B'\n3/1 white 'C'\n",
"categories": ["non-octave", "equal temperament"]
},
"bohlenpierceji": {
Expand Down
17 changes: 4 additions & 13 deletions src/stores/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ export const useScaleStore = defineStore('scale', () => {

// Declare base nominal and unison frequency
const prefixAst = parseAST(sourcePrefix.value)
for (const statement of prefixAst.body) {
visitor.visit(statement)
}
visitor.executeProgram(prefixAst)

return visitor
}
Expand All @@ -344,12 +342,7 @@ export const useScaleStore = defineStore('scale', () => {
defaults.gas = gas.value

const ast = parseAST(sourceText.value)
for (const statement of ast.body) {
const interupt = visitor.visit(statement)
if (interupt) {
throw new Error('Illegal statement.')
}
}
visitor.executeProgram(ast);
return {
defaults,
visitor
Expand All @@ -365,14 +358,12 @@ export const useScaleStore = defineStore('scale', () => {
const visitor = new StatementVisitor(globalVisitor)
visitor.isUserRoot = true;
const ast = parseAST(sourceText.value)
visitor.executeProgram(ast);
let userDeclaredPitch = false
for (const statement of ast.body) {
if (statement.type === 'PitchDeclaration') {
userDeclaredPitch = true
}
const interupt = visitor.visit(statement)
if (interupt) {
throw new Error('Illegal statement.')
break
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ export function expandCode(source: string) {
const visitor = getSourceVisitor()
const defaults = visitor.rootContext!.clone()
const ast = parseAST(source)
for (const statement of ast.body) {
const interupt = visitor.visit(statement)
if (interupt) {
throw new Error('Illegal statement.')
}
}
visitor.executeProgram(ast);
return visitor.expand(defaults)
}

Expand Down

0 comments on commit 1db8ea7

Please sign in to comment.