Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
description: "Tasks for spec 042: move, copy and paste devices in rack chains"
Tasks: Move, copy and paste devices in rack chains
Input: Design documents from specs/042-rack-device-clipboard/:
- spec.md, plan.md, research.md, data-model.md;
- the contracts c-abi.md and ui.md;
- quickstart.md.
Tests: The smoke test is the project's gate (constitution IV), and the plan asks for a section racks: chain device clipboard. So each story gets smoke tasks, written before its implementation where the engine is involved.
Organization: by user story: US1 reorder and move between chains (P1), US2 the clipboard inside racks (P1), US3 across the track and rack chains (P2).
Format: [ID] [P?] [Story] Description
- [P]: can run in parallel (different files, no dependency on an unfinished task)
- [Story]: US1 / US2 / US3
Phase 1: Setup
- T001 Create
tests/Nota.SmokeTest/RackClipboardTests.cs:- AGPL-3.0-only SPDX two-line header;
- an
internal static class RackClipboardTestswithSections()yielding("racks: chain device clipboard", …), followingRackChainMidiTests.cs; - register it in the
--rackslist intests/Nota.SmokeTest/Program.cs(RackSections()).
- T002 [P] Add
MenuKit.DuplicateKey(Cmd(Key.D)) next toCopyKey/CutKey/PasteKeyinsrc/managed/Nota.App/MenuKit.cs.
Phase 2: Foundational (blocks US1 cross-chain, US2, US3)
Purpose: the engine primitives and the managed selection every story uses.
- T003 In
src/native/nota.engine/src/devices/racks/RackCore.h/.cpp, addint32_t insertChainDeviceInstance(int32_t chain, std::shared_ptr<Device> dev, int32_t at, bool prepare = true)andint32_t insertChainMidiDeviceInstance(int32_t chain, std::shared_ptr<MidiDevice> dev, int32_t at).- Each is one
copyState/commit, and returns the new index. - Insert at
at; −1 or past the end means the end. - Shift that chain's mappings at or after
atup by one: for audio,deviceIndex >= at; for MIDI,isMidiTargetwithmidiTargetIndex >= at, rewritten withmidiTarget(j+1). - The MIDI variant refuses kinds outside 0..5, like
addChainMidiDeviceInstance.
- Each is one
- T004 In
RackCore.h/.cpp, addint32_t moveChainDeviceToChain(int32_t chain, int32_t idx, int32_t toChain)andint32_t moveChainMidiDeviceToChain(…).- Each is one fork: erase from
chain, append totoChain's matching section. - The device's mappings are rewritten to
(toChain, newIndex);chain's mappings afteridxshift down. - Returns the new index, or −1 for a bad address or
toChain == chain.
- Each is one fork: erase from
- T005 In
src/native/nota.engine/src/engine/Engine.handEngine_Rack.cpp, add these on top ofrackCoreAt/rackForEditand the shared clipboardclipDevice_/clipMidi_:rackChainDeviceCopy/rackChainMidiCopyset the clipboard tocloneDevice/cloneMidiDeviceof the chain device, and clear the other slot.rackChainDevicePaste(t, di, c, at)/rackChainMidiPastereturn codes per data-model.md:- −1: nothing to paste or a bad address;
- −2: the wrong family, or the rack has no such section — a MIDI Effect Rack has no audio effects; an Audio Effect Rack and a Drum Rack pad have no MIDI effects;
- −3: a
RackDeviceorMidiRackclone; - −4: a hosted plug-in where
!chainsHostPlugin-style hosting isn't allowed (matchIRackAccess.HostsPluginsper rack kind); - −5: MIDI past
RackInstrument::kMaxMidiChainsfordi == -1.
- An audio clone gets
setSidechainSourceTrackId(-1)before the insert. rackChainDeviceDuplicate/rackChainMidiDuplicateinsert a clone at idx+1 without touching the clipboard.rackChainDeviceMoveTo/rackChainMidiMoveTokeep the 16-chain rule for MIDI in Instrument Racks.- After any insert into an Audio Effect Rack, call
recomputePdc()as the existing chain-device add does.
- T006 Add
bool deviceClipboardSidechain() constinsrc/native/nota.engine/src/engine/Engine_Devices.cppandEngine.h: true whenclipDevice_hassidechainSourceTrackId() >= 0. - T007 Add the C ABI functions exactly as in contracts/c-abi.md, with comments:
- declare them in
src/native/nota.engine/include/nota/nota_engine.h; - implement them in
src/native/nota.engine/src/abi/nota_engine_rack.cpp(nota_rackdev_chain_*) andsrc/native/nota.engine/src/abi/nota_engine_device.cpp(nota_device_clipboard_sidechain).
- declare them in
- T008 [P] Add the P/Invoke declarations and wrappers listed in contracts/c-abi.md ("Managed mirror") in:
src/managed/Nota.Infrastructure/Interop/NativeMethods.Rack.cs;src/managed/Nota.Infrastructure/Interop/NotaEngine.Rack.cs;src/managed/Nota.Application/Engine/IAudioEngine.cs.
- T009 Extend
IRackAccessinsrc/managed/Nota.App/DeviceCards/Rack/IRackAccess.cs:- add default members
CopyChainDevice/CopyChainMidi,PasteChainDevice/PasteChainMidi(int at),DuplicateChainDevice/DuplicateChainMidi,MoveChainDeviceTo/MoveChainMidiTo(default −1/false); - implement them for
InstrumentRackAccess(di −1),EffectRackAccess(di) andMidiRackAccess(−1000 − mi, MIDI only); - the Rhythm / Drum accesses keep the defaults unless their pad strip already shows effects.
- add default members
- T010 Add the rack device selection to
src/managed/Nota.App/DeviceCards/DeviceCardContext.csandsrc/managed/Nota.App/DeviceChainView.cs/DeviceChainView.Clipboard.cs:- a
RackDeviceSel(int Rack, int Chain, bool Midi, int Index)record; DeviceCardContext.RackSelection(get) andSelectRackDevice(RackDeviceSel?);- in
DeviceChainView, setting a rack selection clears_selDeviceIndex, and selecting a track device clears the rack selection (FR-005); Show(track)clears both.
- a
Checkpoint: the engine and interop build, and scripts/build.sh passes with no behaviour change.
Phase 3: User Story 1 — Reorder and move a chain's effects (P1) 🎯 MVP
Goal: drag by the header with a drop bar inside a section; drop on another chain's row to move there; Move left / Move right in the menu.
Independent Test: quickstart Q1 + Q2; the smoke checks below.
Smoke for US1
- T011 [US1] In
tests/Nota.SmokeTest/RackClipboardTests.cs:- Audio Effect Rack chain 0 = EQ-3, Compressor, Reverb. Move Reverb to 0, check the order, check that Undo restores it. Map a macro to the Compressor's Threshold, move the Compressor, and check that the macro still drives it.
- Move the Compressor to chain 1 with
RackDevChainDeviceMoveTo. Check it is at the end of chain 1 with its params, that the macro still drives it, and that one Undo puts it back in chain 0. - The same for a MIDI effect between Instrument Rack chains. A move into chain 16 returns −5.
Implementation for US1
- T012 [US1] Replace
RcGripReorderwith header drag insrc/managed/Nota.App/DeviceCards/Rack/RackCard.Chains.cs, modelled onDeviceChainView.HookDeviceDrag.- On header press, capture; after 5 px, dim the card to 0.55 and show a 3-px
NotaPalette.AccentBrightdrop bar at the gap among the same section's cards in the lane strip (tag the cards with(chain, slot, idx)). - On release,
MoveChainDevice/MoveChainMidito the gap (to = gap > from ? gap - 1 : gap), keep the device selected, thenDeferRebuild(). - The grip glyph starts the same drag.
- The instrument card never drags.
- On header press, capture; after 5 px, dim the card to 0.55 and show a 3-px
- T013 [US1] Add chain-row drop for a dragged lane device in
RackCard.Chains.cs.- While a lane drag is active, the pointer over a chain row (hit-test the chain list rows) shows that row's drop outline (
NotaPalette.AccentBrightborder, as for Browser drops) only if the chain can take it. - "Can take it" means a different chain; a MIDI effect needs
_rp.TakesMidiEffects, and for the Instrument Rack chain index < 16. - On release over the row, call
MoveChainDeviceTo/MoveChainMidiTo, setSelto that chain, select the moved device, andDeferRebuild().
- While a lane drag is active, the pointer over a chain row (hit-test the chain list rows) shows that row's drop outline (
- T014 [US1] Add Move left / Move right (
GlyphKind.StepLeft/StepRight, disabled at the ends) toRcCardMenuinRackCard.Chains.csfor effect and MIDI cards, callingMoveChainDevice/MoveChainMidi.
Checkpoint: US1 works on its own: quickstart Q1, Q2, and T011 passing.
Phase 4: User Story 2 — Copy, cut, paste, duplicate and delete inside racks (P1)
Goal: rack chain devices can be selected, with Copy / Cut / Paste / Duplicate / Delete in the menu and on ⌘C / ⌘X / ⌘V / ⌘D / Delete.
Independent Test: quickstart Q3 + Q5; the smoke checks below.
Smoke for US2
- T015 [US2] In
RackClipboardTests.cs:- Copy chain 0's Reverb with
RackDevChainDeviceCopy, thenRackDevChainDevicePasteinto chain 1 at −1. Check the params are equal and the copy has no mappings. - Paste at 0 lands first and shifts chain 1's mapping indices. Check with a mapping on chain 1's first device.
- Duplicate lands at idx+1 and leaves the clipboard kind unchanged.
- Each step is one Undo.
- Refusals: −2 for a MIDI effect into an Audio Effect Rack chain, −3 for a rack, −5 for MIDI into Instrument Rack chain 16.
- A MIDI rack: copy and paste an Arp between its chains, comparing params and
MidiEffectGetState-equivalent params.
- Copy chain 0's Reverb with
Implementation for US2
- T016 [US2] In
RackCard.Chains.cs:- A left-click on an effect or MIDI card header selects it through
_ctx.SelectRackDevice(new(rackIndex, c, slot == RcSlot.Midi, idx)), keeping the rack index fromBuildRackCard. - Draw the selected card with the track chain's selected look (
NotaPalette.Accentborder, 1.5 px, asDeviceChainViewdraws_selDeviceIndex). - Clear the rack selection when the chosen chain changes.
- A left-click on an effect or MIDI card header selects it through
- T017 [US2] Add the rack-device commands (Copy, Cut, Paste, Duplicate, Delete) in a new partial
src/managed/Nota.App/DeviceCards/Rack/RackCard.Clipboard.cs(SPDX header).- Work on the selection through
IRackAccess. Each runs insideE.BeginUndoGroup()/EndUndoGroup(), so Cut (copy + remove) is one step. - Paste goes after the selected index in the same chain and section, and goes to the MIDI section when the clipboard kind is 2.
- Map refusal codes to the data-model.md status messages through
_ctx.Status, and add " · sidechain dropped" whenE.DeviceClipboardSidechainwas true before the paste. - Select the pasted or duplicated device, then
DeferRebuild().
- Work on the selection through
- T018 [US2] Extend
RcCardMenuinRackCard.Chains.cswith groups viaMenuKit.AddGroups: Copy / Cut / Paste (enabled whenE.DeviceClipboardKindfits) / Duplicate, then Delete asMenuKit.Danger, withMenuKitkey hints. The existing Remove item becomes Delete. - T019 [US2] Add Paste to the chain row menu (
RcChainMenu) and to the lane "+" target's add menus (ShowAddDeviceMenu/RcAddMidiMenu). It pastes at the end of the matching section and is disabled when the clipboard is empty or doesn't fit. Files:RackCard.Chains.csandsrc/managed/Nota.App/DeviceCards/Rack/RackCardView.cs. - T020 [US2] Route keys in
src/managed/Nota.App/DeviceChainView.Clipboard.csOnKeyDown: when_rackSelis set, ⌘C / ⌘X / ⌘V / ⌘D / Delete / Backspace call the selected rack card's commands, through a delegate the card registers on the context (DeviceCardContext.SetRackCommands). Typing in a TextBox never reaches it (the existing focus guard).
Checkpoint: US1 and US2 both work: quickstart Q1–Q3 and Q5 inside racks.
Phase 5: User Story 3 — Copy between the track chain and rack chains (P2)
Goal: one clipboard both ways, plus Duplicate on the track chain.
Independent Test: quickstart Q4 + Q6; the smoke checks below.
Smoke for US3
- T021 [US3] In
RackClipboardTests.cs:- Track Delay →
TrackCopyDevice(existing) →RackDevChainDevicePasteinto an Instrument Rack chain: the params are equal, and the rendered output of a test tone through both is equal within 1e-4 (SC-002). - Rack chain EQ →
RackDevChainDeviceCopy→TrackPasteDevice: it lands on the track with equal params. - Track Arp → MIDI Effect Rack chain and Instrument Rack chain.
- A keyed Compressor:
DeviceClipboardSidechainis true; the pasted chain copy hasDeviceSidechainSource−1 (read through the chain); the track source keeps its key. - Track
TrackDuplicateDevice/TrackDuplicateMidiEffectare one Undo each.
- Track Delay →
Implementation for US3
- T022 [US3] In
src/managed/Nota.App/DeviceChainView.Clipboard.cs:- Paste is enabled when the engine clipboard has something (
_engine.DeviceClipboardKind != 0), not only when_clipis set, so a rack copy pastes onto the track chain. - Keep
_clip's preset label only when it came from the track. - Selecting a track device clears the rack selection (T010).
- Paste is enabled when the engine clipboard has something (
- T023 [US3] Add Duplicate ⌘D to the track device menu (between Paste and the rack group) and ⌘D to
OnKeyDown, callingDuplicateDevice/DuplicateMidiEffect. ThenExtrasMoved-style bookkeeping for the A/B extras, select the copy, andRebuild(). File:DeviceChainView.Clipboard.cs. - T024 [US3] When the rack selection is set and the clipboard came from the track (or the other way round), paste goes to where the user last clicked (FR / US3-5). Verify in
DeviceChainView.Clipboard.csthat the routing from T020 covers it with no extra state.
Checkpoint: all three stories work: quickstart Q1–Q6.
Phase 6: Polish & Cross-Cutting
- T025 [P] Shortcuts (nota-shortcuts skill): in
src/managed/Nota.App/PreferencesWindow.cs"Devices (after a click on a device)", add⌘ D"Duplicate the device". Mention that the copy / cut / paste rows work in rack chains too. - T026 [P]
CHANGELOG.md[Unreleased]: under Added, moving, copying, cutting, pasting and duplicating devices in rack chains, plus copy between track and rack chains; under Added or Changed, Duplicate ⌘D on the track chain. - T027 [P]
FEATURES.md(nota-features): extend the racks bullet and the device chain bullet. - T028 nota-docs (EN + RU) in the docs repo: the rack pages (instrument-rack, audio-effect-rack, midi-effect-rack) get a "Move and copy devices" paragraph; the device chain page mentions Duplicate ⌘D; regenerate the shortcuts page.
- T029 Theme check: render the rack card with a selected device, a drag in progress (drop bar) and a row drop outline in all four themes with the headless harness; fix any token issue (quickstart Q7, FR-017).
- T030 Run
scripts/build.sh(native, managed, full smoke). Confirm theracks: chain device clipboardsection prints and passes. - T031 Remove the obsolete
RcGripReordercode path and the "drag the grip" wording in comments. Re-check the Nota Compliance list in spec.md.
Dependencies & Execution Order
- Setup (T001–T002) → Foundational (T003–T010) → the stories.
- US1 within a chain (T012, T014) needs only existing engine calls and could start right after Setup. The cross-chain move (T013) needs T004, T005, T007–T009.
- US2 needs T003, T005–T010.
- US3 needs US2's selection and commands (T016–T020), because paste routing is shared.
- Polish comes after the stories are done.
Parallel Opportunities
- T002 runs alongside T001. T008 (interop) can run alongside T003–T007 once the ABI signatures are fixed (contracts/c-abi.md).
- Within US1: T014 alongside T012 (different methods, same file: run them one after the other if one agent edits).
- In Polish: T025, T026 and T027 together.
Implementation Strategy
- MVP: Setup, then T012 + T014 (reorder inside a chain with the existing engine calls). That fixes "can't move" first.
- Foundational engine and interop, then T013 (move to another chain), then US2, then US3.
- Polish: docs, shortcuts, themes, the full build.