Skip to content

Commit

Permalink
Implement a "repeat" modifier
Browse files Browse the repository at this point in the history
ref #406
  • Loading branch information
frostburn committed Apr 4, 2024
1 parent 2662edc commit fa9cc73
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Feature: Scott Dakota's prime rings on the lattice tab [#551](https://github.com/xenharmonic-devs/scale-workshop/issues/551)
* Feature: Tonnetz prime ellipse coordinates on the lattice tab [#588](https://github.com/xenharmonic-devs/scale-workshop/issues/588)
* Feature: New `latticeView()` command for displaying the order of intervals (prior to sorting) [#597](https://github.com/xenharmonic-devs/scale-workshop/issues/597)
* Feature: New "repeat" modifier [#406](https://github.com/xenharmonic-devs/scale-workshop/issues/406)
* Bug fix: Extreme ratios now only break parts of the tuning table that do not have IEEE floating point representation and format better when non-finite [#631](https://github.com/xenharmonic-devs/scale-workshop/issues/631), [#632](https://github.com/xenharmonic-devs/scale-workshop/issues/632)
* Alpha cycle issues: [#574](https://github.com/xenharmonic-devs/scale-workshop/issues/574), [#579](https://github.com/xenharmonic-devs/scale-workshop/issues/579)

## 2.4.1
Expand Down
8 changes: 8 additions & 0 deletions src/components/ModifyScale.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const RandomModal = defineAsyncComponent(
() => import('@/components/modals/modification/RandomVariance.vue')
)
const RepeatModal = defineAsyncComponent(
() => import('@/components/modals/modification/RepeatScale.vue')
)
const RotateModal = defineAsyncComponent(
() => import('@/components/modals/modification/RotateScale.vue')
)
Expand Down Expand Up @@ -79,6 +83,7 @@ const showEqualizeModal = ref(false)
const showExpandModal = ref(false)
const showMergeOffsetsModal = ref(false)
const showRandomModal = ref(false)
const showRepeatModal = ref(false)
const showRotateModal = ref(false)
const showStretchModal = ref(false)
const showSubsetModal = ref(false)
Expand All @@ -95,6 +100,7 @@ function closeModals() {
showExpandModal.value = false
showMergeOffsetsModal.value = false
showRandomModal.value = false
showRepeatModal.value = false
showRotateModal.value = false
showStretchModal.value = false
showSubsetModal.value = false
Expand Down Expand Up @@ -156,6 +162,7 @@ defineExpose({ blur })
<a href="#" @click="reduce"><li>Reduce</li></a>
<a href="#" @click="retrovert"><li>Retrovert</li></a>
<a href="#" @click="clickRotate"><li>Rotate</li></a>
<a href="#" @click="showRepeatModal = true"><li>Repeat</li></a>
<a href="#" @click="clickSubset"><li>Subset</li></a>
<a href="#" @click="showStretchModal = true"><li>Stretch/compress</li></a>
<a href="#" @click="showRandomModal = true"><li>Random variance</li></a>
Expand Down Expand Up @@ -214,6 +221,7 @@ defineExpose({ blur })
@cancel="showMergeOffsetsModal = false"
/>
<RandomModal v-if="showRandomModal" @done="closeModals" @cancel="showRandomModal = false" />
<RepeatModal v-if="showRepeatModal" @done="closeModals" @cancel="showRepeatModal = false" />
<RotateModal v-if="showRotateModal" @done="closeModals" @cancel="showRotateModal = false" />
<StretchModal v-if="showStretchModal" @done="closeModals" @cancel="showStretchModal = false" />
<SubsetModal v-if="showSubsetModal" @done="closeModals" @cancel="showSubsetModal = false" />
Expand Down
44 changes: 44 additions & 0 deletions src/components/modals/modification/RepeatScale.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script setup lang="ts">
import Modal from '@/components/ModalDialog.vue'
import { useModalStore } from '@/stores/modal'
import { useScaleStore } from '@/stores/scale'
const emit = defineEmits(['done', 'cancel'])
const modal = useModalStore()
const scale = useScaleStore()
function modify(expand = true) {
scale.sourceText += `\nrepeat(${modal.numRepeats})`
if (expand) {
const { visitor, defaults } = scale.getVisitors()
scale.sourceText = visitor.expand(defaults)
}
scale.computeScale()
emit('done')
}
</script>

<template>
<Modal @confirm="modify" @cancel="$emit('cancel')">
<template #header>
<h2>Repeat scale</h2>
</template>
<template #body>
<div class="control-group">
<p>Repeatedly stack the scale on top of itself.</p>
<div class="control">
<label for="num-repeats">Number of repeats</label>
<input type="number" id="num-repeats" min="0" step="1" v-model="modal.numRepeats" />
</div>
</div>
</template>
<template #footer>
<div class="btn-group">
<button @click="modify(true)">OK</button>
<button @click="$emit('cancel')">Cancel</button>
<button @click="modify(false)">Raw</button>
</div>
</template>
</Modal>
</template>
6 changes: 6 additions & 0 deletions src/stores/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ export const useModalStore = defineStore('modal', () => {
const varianceAmount = ref(10)
const varyEquave = ref(false)

// Repeat scale
const numRepeats = ref(2)

// Rotate scale
const newUnison = ref(0)

Expand Down Expand Up @@ -546,6 +549,9 @@ export const useModalStore = defineStore('modal', () => {
varianceAmount,
varyEquave,

// Repeat
numRepeats,

// Rotate
newUnison,

Expand Down

0 comments on commit fa9cc73

Please sign in to comment.