diff --git a/src/components/modals/generation/GeneratorSequence.vue b/src/components/modals/generation/GeneratorSequence.vue index 8b800799..814a461b 100644 --- a/src/components/modals/generation/GeneratorSequence.vue +++ b/src/components/modals/generation/GeneratorSequence.vue @@ -88,7 +88,7 @@ function generate(kind: 'expanded' | 'raw' | 'lattice' = 'expanded') { source += `repeat(${modal.numPeriods})\n` } source += 'unshift(pop())\n' - source += 'latticeView()\n' + source += `latticeView(${modal.period})\n` source += 'sort()\n' } else { source = `gs(${arrayToString(modal.generators)}, ${modal.size}` diff --git a/src/stores/scale.ts b/src/stores/scale.ts index 83f722c6..d17b1ec5 100644 --- a/src/stores/scale.ts +++ b/src/stores/scale.ts @@ -91,6 +91,7 @@ export const useScaleStore = defineStore('scale', () => { const sourceText = ref('') const relativeIntervals = ref(INTERVALS_12TET) const latticeIntervals = ref(INTERVALS_12TET) + const latticeEquave = ref(undefined) const colors = ref(defaultColors(baseMidiNote.value)) const labels = ref(defaultLabels(baseMidiNote.value, accidentalPreference.value)) const error = ref('') @@ -293,7 +294,7 @@ export const useScaleStore = defineStore('scale', () => { syncValues({ accidentalPreference, hasLeftOfZ, gas }) // Extra builtins - function latticeView(this: ExpressionVisitor) { + function latticeView(this: ExpressionVisitor, equave?: Interval) { const scale = this.currentScale for (let i = 0; i < scale.length; ++i) { scale[i] = scale[i].shallowClone() @@ -302,8 +303,11 @@ export const useScaleStore = defineStore('scale', () => { } const rel = relative.bind(this) latticeIntervals.value = scale.map((i) => rel(i)) + + latticeEquave.value = equave } - latticeView.__doc__ = 'Store the current scale to be displayed in the lattice tab.' + latticeView.__doc__ = + 'Store the current scale to be displayed in the lattice tab. Optionally with an explicit equave.' latticeView.__node__ = builtinNode(latticeView) function warn(this: ExpressionVisitor, ...args: any[]) { @@ -366,6 +370,7 @@ export const useScaleStore = defineStore('scale', () => { error.value = '' warning.value = '' latticeIntervals.value = [] + latticeEquave.value = undefined const globalVisitor = getGlobalScaleWorkshopVisitor() const visitor = new StatementVisitor(globalVisitor) visitor.isUserRoot = true @@ -457,6 +462,7 @@ export const useScaleStore = defineStore('scale', () => { scale, relativeIntervals, latticeIntervals, + latticeEquave, colors, labels, error, diff --git a/src/views/LatticeView.vue b/src/views/LatticeView.vue index 3bba661f..ff1a79ba 100644 --- a/src/views/LatticeView.vue +++ b/src/views/LatticeView.vue @@ -98,6 +98,11 @@ function inferConfig() { return } + let equave = monzos[monzos.length - 1] + if (scale.latticeEquave) { + equave = scale.latticeEquave.value + } + let isFractional = true let isEqualTemperament = true for (const monzo of monzos) { @@ -121,7 +126,6 @@ function inferConfig() { } let equaveIndex = 0 - const equave = monzos.pop()! const { n, d } = equave.toFraction() if (d === 1 && isPrime(n)) { equaveIndex = primeLimit(n, true) - 1 @@ -140,7 +144,6 @@ function inferConfig() { } if (isEqualTemperament) { - const equave = monzos.pop()! if (!equave.isFractional()) { return }