Skip to content

Commit

Permalink
Inform the user when equal temperament modal caps scale size
Browse files Browse the repository at this point in the history
ref #402
  • Loading branch information
frostburn committed Jan 17, 2025
1 parent cbe2071 commit 3634f1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Feature: Accept fractional values for CS variety margin [#821](https://github.com/xenharmonic-devs/scale-workshop/issues/821)
* Feature: Add a button for calculating more MOS sizes in Rank 2 modal [#832](https://github.com/xenharmonic-devs/scale-workshop/issues/832)
* Feature: Linear MIDI output mode (uses the numbers in the "#" column and assumes you tune the target device yourself) [#834](https://github.com/xenharmonic-devs/scale-workshop/issues/834)
* Feature: Display a warning when the user tries to create a scale larger than 1024 notes in *New scale -> Equal temperament* [#402](https://github.com/xenharmonic-devs/scale-workshop/issues/402)
* Bug fix: Fix a crash in Rank 2 caused by temperaments with a negative number of periods per equave [#837](https://github.com/xenharmonic-devs/scale-workshop/issues/837)

## 3.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/components/modals/generation/EqualTemperament.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { OCTAVE } from '@/constants'
import { ref, watch } from 'vue'
import Modal from '@/components/ModalDialog.vue'
import ScaleLineInput from '@/components/ScaleLineInput.vue'
import { useModalStore } from '@/stores/modal'
import { MAX_EQUAL_TEMPERAMENT_SIZE, useModalStore } from '@/stores/modal'
import { setAndReportValidity } from '@/utils'
import { useScaleStore } from '@/stores/scale'
Expand Down Expand Up @@ -111,6 +111,9 @@ function generate(expand = true) {
/>
</div>
</div>
<div class="warning" v-if="modal.divisions !== modal.safeScaleSize">
<p>Warning: Scale will be capped at {{ MAX_EQUAL_TEMPERAMENT_SIZE }} notes.</p>
</div>
</template>
<template #footer>
<div class="btn-group">
Expand Down
6 changes: 5 additions & 1 deletion src/stores/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function scaleGet(monzos: TimeMonzo[], index: number) {
return monzos[mmod(index, monzos.length)].mul(equave.pow(numEquaves))
}

export const MAX_EQUAL_TEMPERAMENT_SIZE = 1024

export const useModalStore = defineStore('modal', () => {
// Generic
const equaveString = ref('2/1')
Expand Down Expand Up @@ -57,7 +59,9 @@ export const useModalStore = defineStore('modal', () => {
const singleStepOnly = computed(
() => divisions.value !== Math.round(divisions.value) || divisions.value < 1
)
const safeScaleSize = computed(() => Math.round(clamp(1, 1024, divisions.value)))
const safeScaleSize = computed(() =>
Math.round(clamp(1, MAX_EQUAL_TEMPERAMENT_SIZE, divisions.value))
)
const jumps = computed(() => splitText(jumpsString.value).map((token) => parseInt(token, 10)))
const degrees = computed(() => splitText(degreesString.value).map((token) => parseInt(token, 10)))

Expand Down

0 comments on commit 3634f1e

Please sign in to comment.