diff --git a/src/context/pattern-model.ts b/src/context/pattern-model.ts index 258a1cd..4cad815 100644 --- a/src/context/pattern-model.ts +++ b/src/context/pattern-model.ts @@ -102,6 +102,13 @@ export function movePulseUp(pattern: Pattern, pulseId: string, step: number) { pattern.pulses[targetIndex] = currentPulse; pattern.pulses[index] = targetPulse; + // If the target pulse's order is 1, swap their offsets + if (targetPulse.order === 1) { + const tempOffset = currentPulse.offset; + currentPulse.offset = targetPulse.offset; + targetPulse.offset = tempOffset; + } + // Swap their order const tempOrder = currentPulse.order; currentPulse.order = targetPulse.order; @@ -123,6 +130,13 @@ export function movePulseDown(pattern: Pattern, pulseId: string, step: number) { pattern.pulses[targetIndex] = currentPulse; pattern.pulses[index] = targetPulse; + // If the current pulse's order is 1, swap their offsets + if (currentPulse.order === 1) { + const tempOffset = currentPulse.offset; + currentPulse.offset = targetPulse.offset; + targetPulse.offset = tempOffset; + } + // Swap their order const tempOrder = currentPulse.order; currentPulse.order = targetPulse.order;