Skip to content

editorApplyOffset only shifts current arrangement - poisons dataset.applied for +Keys/+Drums imports #2

Description

@mogul

Restored from slopsmith/slopsmith-plugin-editor#56 — original issue, opened by @cambordas on 2026-06-14.
[restored-from: slopsmith/slopsmith-plugin-editor#56]

Bug: editorApplyOffset only shifts the current arrangement's notes

Steps to reproduce

  1. Create a song from a GP file with two or more arrangements (e.g. Lead + Rhythm)
  2. Apply an offset (e.g. +1s) via the offset toolbar while on the Lead arrangement
  3. Switch to Rhythm - notes are still at the original position (not shifted)
  4. Type 2 in the offset field to shift Rhythm -> dataset.applied is now 2
  5. Open +Keys or +Drums and import

What happens

Audio:   |----♪----♪----♪----|
Lead:    |----♪----♪----♪----|  <- user applies offset +1 here
Rhythm:  |----♪----♪----♪----|  <- NOT shifted (still at original position)
         0    1    2    3

User switches to Rhythm, sees it's broken, types 2 to fix it:

Audio:   |----♪----♪----♪----|
Lead:    |----♪----♪----♪----|  ✓  (at +1)
Rhythm:  |----♪----♪----♪----|  ✓  (at +1, but dataset.applied is now 2)
         0    1    2    3

_effectiveAudioOffset() = S.offset + dataset.applied = 0 + 2 = 2

Next +Keys or +Drums import uses audio_offset=2 - lands 1s past everything else:

Audio:   |----♪----♪----♪----|
Lead:    |----♪----♪----♪----|  at +1
Rhythm:  |----♪----♪----♪----|  at +1
Keys:    |----♪----♪----♪----|       at +2  ✗
         0    1    2    3

Pattern: each arrangement the user manually fixes adds 1 to dataset.applied,
pushing every subsequent import 1s further off (+2, +3, +4 ...).

Root cause

editorApplyOffset shifts only S.arrangements[S.currentArr].notes.
Beats and sections are already shifted globally - notes were missing the all-arrangements loop.

Possible fix

-    const nn = notes();
-    for (const n of nn) n.time += delta;
+    for (const arr of S.arrangements) {
+        for (const n of (arr.notes || [])) n.time += delta;
+        for (const ch of (arr.chords || [])) {
+            ch.time += delta;
+            for (const cn of (ch.notes || [])) cn.time += delta;
+        }
+    }

All arrangements shift together in one apply - dataset.applied stays stable,
every subsequent +Keys / +Drums import gets the correct audio_offset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions