From 5cf90cc2eb2049e9fd36e7f8403e4ae541230b79 Mon Sep 17 00:00:00 2001 From: Lumi Pakkanen <lumi.pakkanen@gmail.com> Date: Wed, 17 Apr 2024 14:48:16 +0300 Subject: [PATCH] Update sonic-weave dependency Add a new checkbox for coalescing small intervals near unison. Adapt to root context API changes. Fixes gas expenditure issues. --- package-lock.json | 10 +++++----- package.json | 4 ++-- .../modals/modification/CoalesceDuplicates.vue | 6 +++++- src/stores/modal.ts | 2 ++ src/stores/scale.ts | 12 ++++++------ src/utils.ts | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6aead423..0a10c5b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "scale-workshop", - "version": "3.0.0-beta.13", + "version": "3.0.0-beta.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "scale-workshop", - "version": "3.0.0-beta.13", + "version": "3.0.0-beta.14", "dependencies": { "isomorphic-qwerty": "^0.0.2", "ji-lattice": "^0.0.3", @@ -14,7 +14,7 @@ "moment-of-symmetry": "^0.4.2", "pinia": "^2.1.7", "qs": "^6.12.0", - "sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.17", + "sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.20", "sw-synth": "^0.1.0", "temperaments": "^0.5.3", "vue": "^3.3.4", @@ -5400,8 +5400,8 @@ } }, "node_modules/sonic-weave": { - "version": "0.0.17", - "resolved": "git+ssh://git@github.com/xenharmonic-devs/sonic-weave.git#0033a815351b713c76da1da7ca46550065d9b230", + "version": "0.0.20", + "resolved": "git+ssh://git@github.com/xenharmonic-devs/sonic-weave.git#7d5a97f82ce23a4316a0cf71ab831106f73a7eb5", "license": "MIT", "dependencies": { "moment-of-symmetry": "^0.4.2", diff --git a/package.json b/package.json index 85e45ef3..fda1d654 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scale-workshop", - "version": "3.0.0-beta.13", + "version": "3.0.0-beta.14", "scripts": { "dev": "vite", "build": "run-p type-check \"build-only {@}\" --", @@ -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.17", + "sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.20", "sw-synth": "^0.1.0", "temperaments": "^0.5.3", "vue": "^3.3.4", diff --git a/src/components/modals/modification/CoalesceDuplicates.vue b/src/components/modals/modification/CoalesceDuplicates.vue index ede92711..855efaf9 100644 --- a/src/components/modals/modification/CoalesceDuplicates.vue +++ b/src/components/modals/modification/CoalesceDuplicates.vue @@ -10,7 +10,7 @@ const modal = useModalStore() const scale = useScaleStore() function modify(expand = true) { - scale.sourceText += `\ncoalesce(${centString(modal.tolerance)}, '${modal.coalescingAction}')` + scale.sourceText += `\ncoalesce(${centString(modal.tolerance)}, '${modal.coalescingAction}', ${modal.preserveBoundary})` if (expand) { const { visitor, defaults } = scale.getVisitors() scale.sourceText = visitor.expand(defaults) @@ -93,6 +93,10 @@ function modify(expand = true) { <label for="action-geoavg">Geometric</label> </span> </div> + <div class="control checkbox-container"> + <input type="checkbox" id="preserve-boundary" v-model="modal.preserveBoundary" /> + <label for="preserve-boundary">Preserve small intervals near unison</label> + </div> </div> </template> <template #footer> diff --git a/src/stores/modal.ts b/src/stores/modal.ts index b7bfbafa..acbae2a5 100644 --- a/src/stores/modal.ts +++ b/src/stores/modal.ts @@ -449,6 +449,7 @@ export const useModalStore = defineStore('modal', () => { const coalescingAction = ref<'avg' | 'havg' | 'geoavg' | 'lowest' | 'highest' | 'simplest'>( 'simplest' ) + const preserveBoundary = ref(false) // Concordance shell const mediumInteger = ref(32) @@ -627,6 +628,7 @@ export const useModalStore = defineStore('modal', () => { // Coalesce tolerance, coalescingAction, + preserveBoundary, // Expand simplify, diff --git a/src/stores/scale.ts b/src/stores/scale.ts index 43effe68..b953fa25 100644 --- a/src/stores/scale.ts +++ b/src/stores/scale.ts @@ -315,7 +315,7 @@ export const useScaleStore = defineStore('scale', () => { warn } const visitor = getSourceVisitor(true, extraBuiltins) - visitor.rootContext.gas = gas.value + visitor.rootContext!.gas = gas.value // Declare base nominal and unison frequency const prefixAst = parseAST(sourcePrefix.value) @@ -329,8 +329,8 @@ export const useScaleStore = defineStore('scale', () => { // Methods function getVisitors() { const globalVisitor = getGlobalVisitor() - const visitor = new StatementVisitor(globalVisitor.rootContext, globalVisitor) - const defaults = visitor.rootContext.clone() + const visitor = new StatementVisitor(globalVisitor) + const defaults = visitor.rootContext!.clone() defaults.gas = gas.value const ast = parseAST(sourceText.value) @@ -352,7 +352,7 @@ export const useScaleStore = defineStore('scale', () => { warning.value = '' latticeIntervals.value = [] const globalVisitor = getGlobalVisitor() - const visitor = new StatementVisitor(globalVisitor.rootContext, globalVisitor) + const visitor = new StatementVisitor(globalVisitor) const ast = parseAST(sourceText.value) let userDeclaredPitch = false for (const statement of ast.body) { @@ -374,8 +374,8 @@ export const useScaleStore = defineStore('scale', () => { } const ratios = relativeIntervals.value.map((i) => i.value.valueOf()) let visitorBaseFrequency = mtof(baseMidiNote.value) - if (visitor.rootContext.unisonFrequency) { - visitorBaseFrequency = visitor.rootContext.unisonFrequency.valueOf() + if (visitor.rootContext!.unisonFrequency) { + visitorBaseFrequency = visitor.rootContext!.unisonFrequency.valueOf() } if (ratios.length) { const name = str.bind(ev) diff --git a/src/utils.ts b/src/utils.ts index 3be3ddb4..a0d0e3a5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -61,8 +61,8 @@ export function splitText(text: string) { export function expandCode(source: string) { const globalVisitor = getSourceVisitor() - const defaults = globalVisitor.rootContext.clone() - const visitor = new StatementVisitor(globalVisitor.rootContext, globalVisitor) + const defaults = globalVisitor.rootContext!.clone() + const visitor = new StatementVisitor(globalVisitor) const ast = parseAST(source) for (const statement of ast.body) { const interupt = visitor.visit(statement)