Skip to content

Commit

Permalink
Update sonic-weave dependency
Browse files Browse the repository at this point in the history
Add a new checkbox for coalescing small intervals near unison.
Adapt to root context API changes.
Fixes gas expenditure issues.
  • Loading branch information
frostburn committed Apr 18, 2024
1 parent 6ec1976 commit 38665d3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 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.13",
"version": "3.0.0-beta.14",
"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.17",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.20",
"sw-synth": "^0.1.0",
"temperaments": "^0.5.3",
"vue": "^3.3.4",
Expand Down
6 changes: 5 additions & 1 deletion src/components/modals/modification/CoalesceDuplicates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions src/stores/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -627,6 +628,7 @@ export const useModalStore = defineStore('modal', () => {
// Coalesce
tolerance,
coalescingAction,
preserveBoundary,

// Expand
simplify,
Expand Down
12 changes: 6 additions & 6 deletions src/stores/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 38665d3

Please sign in to comment.