Skip to content

Commit

Permalink
Fix merging negative offsets
Browse files Browse the repository at this point in the history
ref #511
  • Loading branch information
frostburn committed Dec 21, 2023
1 parent bba6506 commit b52559f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/components/modals/modification/MergeOffset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,28 @@ function modify() {
} else if (overflowType.value === 'reduce') {
transposed = transposed.reduce()
}
const scale = props.scale.merge(transposed)
let scale: Scale;
if (overflowType.value === 'intuitive') {
scale = props.scale.variant([...props.scale.intervals]);
let unison: Interval;
if (scale.intervals.length) {
const highest = scale.intervals.pop()!
const equave = scale.equave
if (highest.compare(equave) > 0) {
scale.intervals.push(equave)
scale.equave = highest
scale.sortInPlace()
unison = scale.intervals.shift()!
scale = props.scale.merge(transposed)
if (scale.intervals.length) {
const highest = scale.intervals.pop()!
const equave = scale.equave
if (highest.compare(equave) > 0) {
scale.intervals.push(equave)
scale.equave = highest
scale.sortInPlace()
}
}
scale.intervals.unshift(unison!);
} else {
scale = props.scale.merge(transposed)
}
} else {
scale = props.scale.merge(transposed)
}
emit('update:scale', scale)
}
Expand Down

0 comments on commit b52559f

Please sign in to comment.