Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
description: "Tasks: sidechain from individual pads, voices and chains"
Tasks: Sidechain from individual pads, voices and chains
Input: spec.md, plan.md, research.md, data-model.md, contracts/c-abi.md, contracts/mcp.md, quickstart.md
Tests: requested by the spec (FR-016) — smoke tests in tests/Nota.SmokeTest/SidechainPartTests.cs,
run by scripts/build.sh and alone with --sidechain-parts.
Path shorthands: E/ = src/native/nota.engine/src/, H = src/native/nota.engine/include/nota/nota_engine.h,
M/ = src/managed/, T/ = tests/Nota.SmokeTest/.
Format: [ID] [P?] [Story] Description
- [P]: can run in parallel (different files, no dependency on an unfinished task)
- [Story]: US1…US5 from spec.md
Phase 1: Setup
- T001 Add the test file
T/SidechainPartTests.cs(SPDX header,public static IEnumerable<(bool, string)> Run(), empty for now) and register it inT/Program.csboth as the--sidechain-partsflag (pattern of--preset-state,L473) and in the full run (L15203) - T002 [P] Add a deterministic drum fixture for the tests: reuse an existing short WAV in
T/Fixtures/or add a ≤ 50 ms kick-like and hat-like clip there (licence: generated in-repo); note its use in a comment at the top ofT/SidechainPartTests.cs— done without a fixture: the tests generate their sine-burst WAVs at run time (asDeviceCopyTestsdoes)
Phase 2: Foundational (blocks every story)
Purpose: part identity, part-aware route slots and the per-block tap hand-off — no instrument fills taps yet.
- T003 [P]
E/devices/Device.handE/devices/Instrument.h: non-virtualstd::atomic<uint64_t> scPart_{0}withuint64_t sidechainPart() const/void setSidechainPart(uint64_t)on both base classes (0 = whole track; comment: "part id, see specs/050") - T004 [P]
E/devices/Instrument.h:struct PartTap { uint64_t part; float* pre; float* post; };and virtualsint32_t partCount() const {return 0;},uint64_t partId(int32_t) const {return 0;},int32_t partIndex(uint64_t) const {return -1;},std::string partName(int32_t) const {return {};},void setPartTaps(const PartTap*, int32_t) {}(audio thread; pointers valid for the coming render only; add, never overwrite) - T005
E/engine/Engine.h+E/engine/Engine.cpp:kMaxRoutes8 → 16; addstd::atomic<uint64_t> routeSlotPart_[kMaxRoutes](init 0); replacerouteSlotForTrack(id)withrouteSlotFor(int32_t track, uint64_t part)(keeprouteSlotForTrack(id)asrouteSlotFor(id, 0)); readers load track then part with acquire - T006
E/engine/Engine_Devices.cpprecomputeRouting(): claim per distinct(track, part)from every consumer (sidechainSourceTrackId()+sidechainPart(), incl. rack children and the monitoring-audio claim with part 0); a part key claims only when the source track's instrumentpartIndex(part) >= 0; writerouteSlotPart_beforerouteSlotTrackId_(release) - T007
E/engine/Engine_Render.cpp:feedDeviceKey,feedRackChildKeysand the instrument React path look uprouteSlotFor(src, consumer.sidechainPart())(React keepsrouteBus_= post); thekeyingflag (~L2168) is true when the track owns any slot (whole or part) - T008
E/engine/Engine_Render.cpprenderLeafDry(LeafPath::Instrument, ~L1927): beforerenderInstrumentRaw, build a stackPartTap taps[kMaxRoutes]from the slots with this track id and part ≠ 0 (pre →routeBusPreNext_[s], post →routeBusNext_[s]) and callt.instrument->setPartTaps(taps, n); callsetPartTaps(nullptr, 0)after; nothing else whenn == 0 - T009
E/engine/Engine_Devices.cpp+E/engine/Engine_Rack.cpp: every place that copies or clears a key copies / clears the part with the track id — device clone (L698), move-to-track self-key clear (L893, ~L1093), clipboard (deviceClipboardSidechainstays track-based), rack grouping (Engine_Rack.cpp~L215), rack child clone;setDeviceSidechainSource/setInstrumentSidechainSource(whole-track setters) reset the part to 0 - T010
E/engine/Engine.h+E/engine/Engine_Devices.cpp: engine methodssetDeviceSidechainKey(track, dev, src, partIndex) → int(0 ok, -1 bad, -2 no free route: a new distinct(src, part)when no slot is free leaves the key unchanged),deviceSidechainKey(track, dev, &src, &partIndex)(-1 whole, -2 missing), instrument variants,sidechainRoutesFree(),sidechainRouteInUse(src, partIndex),trackPartCount(track),trackPartName(track, i)— converting index ↔ id through the source track's instrument - T011
H+E/abi/nota_engine_device.cpp(+E/abi/nota_engine_track.cppfor the track part calls): the specs/050 block exactly as in contracts/c-abi.md except the rack-child pair (T030) - T012 [P]
M/Nota.Application/Engine/IAudioEngine.cs,M/Nota.Infrastructure/Interop/NativeMethods.Devices.cs,M/Nota.Infrastructure/Interop/NotaEngine.Devices.cs: managed members per data-model.md (TrackPartCount,TrackPartName,SetDeviceSidechainKey → int,DeviceSidechainKey → (int Source, int Part), instrument variants,SidechainRoutesFree,SidechainRouteInUse); stubs in every otherIAudioEngineimplementation (RackEngineProxies.cs,RackCardView.csproxy switch: no parts, -1) - T013 Smoke (in
T/SidechainPartTests.cs): with no part keys, whole-track keys still duck as before (regression guard; copy the existing Compressor sidechain check shape) andnota_sidechain_route_capacity= 16
Checkpoint: builds; existing smoke tests pass; nothing user-visible yet.
Phase 3: User Story 1 — Duck the bass from just the kick pad (P1) 🎯 MVP
Goal: a Compressor keys off one Drum Rack pad, Pre or Post, and the card shows "Drums · Kick pre".
Independent test: quickstart.md automated 1–3; manual 1–4.
Tests
- T014 [P] [US1]
T/SidechainPartTests.csKickPadOnly(): Drum Rack (kick + hat Sampler pads from the T002 fixture, kick steps 1/3, hat 2/4), bass track with a sustained deterministic clip + Compressor keyed(drums, kickIndex); offline render; per blockDeviceGainReduction≥ 3 dB in kick blocks, < 0.1 dB in hat blocks — once Post, once Pre (FR-016, SC-001) - T015 [P] [US1]
T/SidechainPartTests.csPreVsPost(): Utility −20 dB on the kick pad → Pre GR within 0.5 dB of before, Post GR lower (FR-005/006) - T016 [P] [US1]
T/SidechainPartTests.csGhostKick(): mute the kick pad → drums track peak in kick blocks drops (no kick in the mix) while bass GR stays ≥ 3 dB; solo the hat → same (FR-007a, SC-005a)
Implementation
- T017 [US1]
E/devices/racks/RackCore.{h,cpp}: implementpartCount(chains with an instrument rack kinds only; 0 for Audio Effect / MIDI racks),partId(i)=chains[i].uid,partIndex(uid)via the live snapshot,partName(i)= chain name or its instrument's display name — implemented onRackInstrument(the Instrument-facing class over RackCore), so Audio Effect / MIDI racks have no parts by construction - T018 [US1]
E/devices/racks/RackInstrument.h: store the per-block taps (const PartTap* taps_ = nullptr; int32_t nTaps_ = 0;+setPartTapsoverride) and a helperconst PartTap* tapFor(uint64_t uid) const(linear scan, nullptr whennTaps_ == 0) - T019 [US1]
E/devices/racks/DrumRack.cpprender: per padtap = tapFor(c.uid); when muted / solo-gated andtap == nullptrkeep today'scontinue; otherwise render (tapped-but-silent pads keepmeterat 0 and skip the add intoout). Afterinstrument->renderaddscratch_intotap->pre; in the sum loop addl*env*gL,r*env*gRwith pad gain/pan without rack volumervintotap->post - T020 [US1]
M/Nota.App/DeviceCards/SidechainSourcePicker.cs(new, SPDX header): builder returning a ComboBox +Func<string> SourceName+ sync action for a consumer given get/set delegates; items "Internal" then per track a row (whole track) and indented part rows fromTrackPartCount/Name; rebuild onDropDownOpened; follow external changes (MCP) while closed; name format "Track · Part"; a-2set result shows the "No free routes" tooltip; styling per DESIGN.md (reuse the existing combo's sizes / palette) - T021 [US1]
M/Nota.App/DeviceCards/Bodies/CompressorDeviceBody.cs: replace thesrcIds/srcNamescombo (L353–L392) with the picker;L564) show "Drums · Kick pre/post"; picking any source still turns External onSourceName()and the Listen readout (
Checkpoint: US1 works end to end in the app and in the smoke test.
Phase 4: User Story 2 — The key stays on the same pad (P1)
Goal: reorder / add / delete-other / rename / delete+undo / save+reopen keep the key on its pad.
Independent test: quickstart.md automated 4, 5, 9; manual 4–5.
Tests
- T022 [P] [US2]
T/SidechainPartTests.csStableIdentity(): key the kick, then move the kick pad to index 0, add a pad, delete the hat, rename the kick — after each,DeviceSidechainKeypart = the kick's new index and the GR pattern of T014 holds (FR-003, SC-003) - T023 [P] [US2]
T/SidechainPartTests.csDormantKey(): delete the kick pad → part -2 and GR < 0.1 dB everywhere;nota_engine_undo→ part = original index and GR back; replace the Drum Rack with a Sampler → part -2 (FR-004) - T024 [P] [US2]
T/SidechainPartTests.csSaveReopen(): save a project with a pad key (Pre) and a whole-track key, reopen → both keys with the same part / tap; open a v27 project (andT/Fixtures/racks-v8) → keys whole-track, render unchanged (FR-012/013, SC-004)
Implementation
- T025 [US2]
M/Nota.Infrastructure/Persistence/ProjectModel.cs:DeviceDto.SidechainPart,InstrumentDto.SidechainPart,NestedSidechainDto.Part—int, default-1("part index at save time on the source track's instrument; -1 whole track (specs/050, v28)") - T026 [US2]
M/Nota.Infrastructure/Persistence/ProjectService.cs:CurrentFormatVersion27 → 28; save writes part fromDeviceSidechainKey/InstrumentSidechainKey(a-2key saves asSidechainSource = -1); load keeps the deferred wiring (~L913–L930) and callsSetDeviceSidechainKey/SetInstrumentSidechainKeywith the part; count-2results for T048 - T027 [US2]
M/Nota.Infrastructure/Persistence/ProjectMigrations.cs: v27 → v28 no-op step with a comment (absentSidechainPart= -1) - T028 [US2]
M/Nota.App/DeviceCards/SidechainSourcePicker.cs: a part key reading -2 shows "Track · (missing)" in the combo and readouts - T029 [US2] Verify
E/devices/racks/RackCore.cppchain reorder / duplicate / remove keepuidon survivors and thatduplicateChaingives the copy a fresh uid (the key stays on the original); fix if not — verified: survivors keepuid;duplicateChainrebuilds the copy from the blob, so it gets a fresh one (covered byStableKey) - T030 [US2]
H+E/abi/nota_engine_rack.cpp+E/engine/Engine_Rack.cpp:nota_rack_chain_sidechain_part/nota_rack_chain_set_sidechain_partper contracts; managedRackChainSidechainPart/RackChainSetSidechainPartinM/Nota.Application/Engine/IAudioEngine.cs,M/Nota.Infrastructure/Interop/NativeMethods.RackDev.cs,NotaEngine.RackDev.cs;ProjectService.NestedLinkssavesNestedSidechainDto.Partand load restores it (keyed devices grouped into a rack keep their pad key)
Checkpoint: US1 + US2 = the reported use case, shippable.
Phase 5: User Story 3 — Key off a Nota Rhythm voice (P2)
Independent test: quickstart.md automated 6 (Rhythm half).
- T031 [P] [US3]
T/SidechainPartTests.csRhythmVoice(): Rhythm with voice 1 (kick) on 1/3 and voice 5 (hat) on 2/4 → Compressor keyed(rhythm, 0)ducks on voice-1 steps only, Pre and Post; voice FX (Utility −20 dB) on voice 1 changes Post only;TrackPartCount= 8, names "1 Kick"… - T032 [US3]
E/devices/instruments/RhythmMachine.{h,cpp}: part surface (partCount8,partId(v)= v+1,partIndex(id)= id−1 when 1..8,partName(v)= "{v+1} {voice name}"),setPartTapsstoring the taps; inrenderper chunk write the panned voice output totap->pre[(base+j)*2…]andvbuf_[v]after FX (or the same voice output when the voice has no FX) totap->post; untapped voices unchanged
Phase 6: User Story 4 — Key off an Instrument Rack chain (P2)
Independent test: quickstart.md automated 6 (rack half).
- T033 [P] [US4]
T/SidechainPartTests.csInstrumentRackChain(): Instrument Rack with two Sampler chains on disjoint key zones playing alternate beats → key on chain 0 ducks on its beats only; reorder chains → still chain 0's sound; mute chain 0 → still ducks (ghost) - T034 [US4]
E/devices/racks/RackInstrument.cpprender: same tap / ghost logic as T019 (no decay VCA; post = after inserts × chain gain/pan, withoutrv); a muted MIDI chain that is tapped renders its events instead of only delivering them
Phase 7: User Story 5 — Every sidechain consumer gets sub-sources (P2)
Independent test: quickstart.md automated 7–8, manual 6; each consumer keyed off a pad reacts to it only.
Tests
- T035 [P] [US5]
T/SidechainPartTests.csFluxReact(): Flux React keyed(drums, kick)viaSetInstrumentSidechainKey→ its React reading moves on kick blocks only - T036 [P] [US5]
T/SidechainPartTests.csRoutePool(): 16 distinct sources set → the 17th returns -2 and leaves the key unchanged,SidechainRoutesFree= 0; a second consumer of an in-use(track, part)returns 0; whole-trackSetDeviceSidechainSourceafter a part key → part -1 - T037 [P] [US5]
T/SidechainPartTests.csEveryConsumer(): for kinds Auto Filter, Auto Gain, Ceiling, Dynamic EQ, Prism, Shutter, Vocoder — key off the kick pad and check the key arrives (device scope / reading non-zero in kick blocks, zero in hat blocks)
Implementation
- T038 [P] [US5] Switch to
SidechainSourcePicker:M/Nota.App/DeviceCards/Bodies/AutoFilterDeviceBody.cs,AutoGainDeviceBody.cs,AutoShiftDeviceBody.cs,CeilingDeviceBody.cs,DynamicEqDeviceBody.cs,PrismDeviceBody.cs,ShutterDeviceBody.cs(incl. its "External sidechain" switch's first-other-track pick, ~L314),VocoderDeviceBody.cs— cards keep their own menus: they take rows fromSidechainSourcePicker.Entries/MenuRows(parts read "Drums · Kick"); Auto Shift is left on whole tracks — its key is the source's MIDI notes, which a pad doesn't have - T039 [P] [US5]
M/Nota.App/DeviceCards/DeviceParamControls.csSidechainSelector(plug-ins, generic cards) andM/Nota.App/DeviceCards/PluginCard.csuse the picker - T040 [P] [US5]
M/Nota.App/DeviceCards/Instruments/FluxInstrumentCard.cs: React source via the picker withSetInstrumentSidechainKey/InstrumentSidechainKey; no Pre/Post control (always Post) - T041 [US5]
M/Nota.App/DeviceCards/SidechainSourcePicker.cs: disable rows whenSidechainRoutesFree() == 0 && !SidechainRouteInUse(track, part)with tooltip "No free routes"; disable a frozen track's part rows (tooltip: "Frozen — parts don't render") — the dropdown greys such rows; the menu-style cards leave them out - T042 [US5]
M/Nota.Mcp/Tools/DeviceTools.cs:get_device_sidechain+sourcePart,sourceName;set_device_sidechain+ optionalsourcePart(error text on -2); newlist_sidechain_sources,get_instrument_sidechain,set_instrument_sidechainper contracts/mcp.md; descriptions name the kick-pad recipe
Phase 8: Polish & cross-cutting
- T043 [P]
CHANGELOG.md[Unreleased]→ Added: sidechain keys from a single Drum Rack pad, Instrument Rack chain or Nota Rhythm voice, Pre/Post, ghost parts; Changed: 16 sidechain routes - T044 [P]
FEATURES.mdvia thenota-featuresskill - T045 [P] User manual EN + RU (
../nota-docs) via thenota-docsskill: sidechain picker, ghost kick recipe; re-shoot the Compressor Sidechain tab — Devices (Sidechain), Compressor, Drum Rack, Flux pages EN + RU in ../nota-docs (uncommitted); the Compressor shot is visually unchanged, not retaken - T046 Engine perf gate (specs/034) with no part keys and with 4 pad keys — record numbers in the PR (FR-011, SC-005) — the Callgrind gate needs Linux + valgrind (runs in CI on the PR); locally
scripts/bench-engine.shbefore/after on an M4 Max: no change beyond run-order noise (the 16-synth export swing follows whichever build runs second). A third run caught late blocks at 192 tracks · 64-sample buffers that didn't flip with the order: the route-slot scans are now bounded by the used count (research R6), after which the PR is no worse than develop (build/pr-050/issue-190) - T047 Re-check the Nota Compliance Checklist in spec.md: SPDX headers on
SidechainPartTests.csandSidechainSourcePicker.cs; no audio-thread allocation in T008/T019/T032/T034 - T048 Project load: when T026 counted
-2keys, show one notice ("Some sidechain keys were cleared: no free routes") through the existing load-warnings path inM/Nota.Infrastructure/Persistence/ProjectService.cs - T049
scripts/build.shgreen (smoke incl.--sidechain-parts); macOS manual pass of quickstart.md "Manual" with before/after screenshots for the PR (nota-prskill) — build.sh green (SMOKE TEST PASSED, SCAN SCALE PASSED); the picker checked in a headless render (Compressor Sidechain tab + source list, dark / light; build/pr-050), which led to the closed box naming the track ("Drums · Kick"). Not driven in the live app - T050
/speckit-converge→ Converged
Dependencies
Setup (T001–T002) → Foundational (T003–T013) → US1 (T014–T021)
US1 → US2 (needs pad keys) US1 → US4 (shares RackCore / tap helper T017–T018)
Foundational → US3 (Rhythm is independent of racks)
US1 (picker T020) → US5 (T038–T041); T010/T011 → T035–T036, T042
US2 T026 → T048; all stories → Polish
Inside Foundational: T003, T004 ∥ → T005 → T006 → T007, T008 → T009 → T010 → T011 → T012 → T013.
Parallel examples
- Foundational: T003 ∥ T004; T012 ∥ T013 once T011 is in.
- US1: tests T014 ∥ T015 ∥ T016 (same file, distinct methods — merge-friendly if written by one hand; otherwise sequence), engine T017 → T018 → T019 ∥ UI T020 → T021.
- US3 (T031–T032) can run alongside US1 once Foundational is done.
- US5: T038 ∥ T039 ∥ T040 (different files), then T041; T042 any time after T011.
- Polish: T043 ∥ T044 ∥ T045.
Implementation strategy
- MVP = Foundational + US1 + US2 — the reported "duck the bass from the kick pad" with stable keys and saved projects.
- Then US3 and US4 (small: one render loop each, reusing the foundation).
- Then US5 (UI sweep + MCP) and Polish.
- Commit per phase in the repo's style; the user makes the commits and the PR.
Phase 9: Convergence
- T051 Show full-pool sources as disabled rows with the "No free routes" hint in the menu-style pickers (Auto Gain, Ceiling, Dynamic EQ, Prism, Shutter, Vocoder, Flux React) instead of leaving them out —
SidechainSourcePicker.MenuRowsand the cards' menu builders insrc/managed/Nota.App/DeviceCards/per FR-007c (partial) - T052 Cover the remaining edge cases in
tests/Nota.SmokeTest/SidechainPartTests.cs: a frozen source track's part key is silent while its whole-track key still works; duplicating the consuming track and copy / paste of the keyed device keep the part key per spec Edge Cases (Frozen source track, Clipboard / duplicate) (partial)