Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
description: "Task list for 006 Stereo Pan Law"
Tasks: Stereo Pan Law
Input: Design documents from /specs/006-stereo-pan-law/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md
Tests: Requested — FR-012 requires smoke-test coverage, and the constitution
(IV) requires it for an engine behaviour change. All tests live in one new file,
tests/Nota.SmokeTest/PanLawTests.cs, so test tasks touching it are sequential.
Organization: Grouped by user story (spec.md): US1 stereo image (P1), US2 older projects unchanged (P1), US3 switching the law (P2).
Format: [ID] [P?] [Story] Description
- [P]: Can run in parallel (different files, no dependencies on incomplete tasks)
- [Story]: US1 / US2 / US3
Phase 1: Setup
- T001 Run
scripts/build.shon the untouched tree and note that it is green (baseline for the bit-identical checks); if it is red, stop and report — do not start the feature on a red baseline
Phase 2: Foundational (Blocking Prerequisites)
Purpose: the law exists as graph data, survives every edit, and is reachable from C ABI and C#. No sound change yet.
⚠️ CRITICAL: No user story work can begin until this phase is complete
- T002 In
src/native/nota.engine/src/Graph.haddenum class PanLaw : int32_t { Balance = 0, Stereo = 1 };and the fieldPanLaw panLaw = PanLaw::Balance;onGraph(comment: project pan law, 006; graph-level so undo/redo restore it), and addinline void inheritGraphLevel(Graph& dst, const Graph& src)that copiessceneCount,scenes,masterVolume,masterTrackandpanLaw; rewrite the existing "fresh-graph builds must carry it forward" comment to say "use inheritGraphLevel()" - T003 Replace the hand-copied graph-level lines (
g->sceneCount = authoring_->sceneCount; g->scenes = …; g->masterVolume = …; g->masterTrack = …;) withinheritGraphLevel(*g, *authoring_);at every production fresh-graph site:src/native/nota.engine/src/Engine.cpp(republishWithTrackRaw,line 520 — keep the309),masterTrackoverride forkMasterTrackIdafter the call),src/native/nota.engine/src/Engine_Modulation.cpp(src/native/nota.engine/src/Engine_Session.cpp(113 — keep461, 1382, 1502, 1534, 1564, 1619, 1754, 1896, 2439, 2491, 2686). Leave the self-test graphs ing->sceneCount = newCountafter the call; ~861),src/native/nota.engine/src/Engine_Tracks.cpp(Engine_Automation.cpp(75, 377, 430) and the reset graph in570) as they are. AfterwardsEngine.cpp(grep -n "make_shared<Graph>()" src/native/nota.engine/src/*.cppand confirm every remaining hit is either followed byinheritGraphLevelor is one of the listed exceptions - T004 In
src/native/nota.engine/src/Engine.h/Engine.cppaddbool setPanLaw(PanLaw law, bool checkpoint)(return false for a value outside Balance/Stereo; no-op returning true if equal toauthoring_->panLaw; elseauto g = std::make_shared<Graph>(*authoring_); g->panLaw = law;thenpublish(g)whencheckpoint,publishRaw(g)otherwise) andPanLaw panLaw() const(readsauthoring_, Balance if null). Message thread only - T005 Add to
src/native/nota.engine/include/nota/nota_engine.hthe block from contracts/c-abi-pan-law.md verbatim (NOTA_PAN_LAW_BALANCE 0,NOTA_PAN_LAW_STEREO 1,nota_engine_set_pan_law(engine, law, checkpoint),nota_engine_pan_law(engine)with their comments) and implement both insrc/native/nota.engine/src/nota_engine_core.cpp: unknown law →NOTA_ERR_INVALID_ARG, null engine →NOTA_ERR_INVALID_ARG/NOTA_PAN_LAW_BALANCE - T006 [P] In
src/managed/Nota.Application/Engine/IAudioEngine.csaddpublic enum PanLaw { Balance = 0, Stereo = 1 }(or in a sibling file of the same folder, SPDX header if new) and the membersPanLaw PanLaw { get; }andvoid SetPanLaw(PanLaw law, bool checkpoint = true);with the doc comment "Project pan law (graph-level, undoable). See nota_engine_set_pan_law."; update every otherIAudioEngineimplementation the compiler reports (test fakes intests/Nota.SmokeTest, MCP abstractions) with a trivial implementation - T007 [P] Add the P/Invokes
SetPanLaw(IntPtr engine, int law, int checkpoint)→nota_engine_set_pan_lawandPanLaw(IntPtr engine)→nota_engine_pan_lawinsrc/managed/Nota.Infrastructure/Interop/NativeMethods.cs, and the wrapper members insrc/managed/Nota.Infrastructure/Interop/NotaEngine.cs(ThrowIfDisposed(); Check(...)likeSetTrackPaninNotaEngine.Tracks.cs) - T008 Create
tests/Nota.SmokeTest/PanLawTests.cs(two-line SPDX header; file comment: "Project pan law (specs/006-stereo-pan-law): …; also runnable alone:dotnet run --project tests/Nota.SmokeTest -- --panlaw") withinternal static class PanLawTests { public static IEnumerable<(bool ok, string label)> Run() }and shared helpers:WriteStereoWav(float[] l, float[] r)viaNota.Infrastructure.WavWriter(48 kHz, Float32, temp path),Sine(hz, seconds, amp),Render(NotaEngine eng, double seconds)viaSeek(0); Play(); RenderOffline(...); Stop(),Goertzel(float[] interleaved, int channel, double hz, int from, int to)returning linear amplitude, andDb(x). Wire it intests/Nota.SmokeTest/Program.cs: in the full run next toReturnDeleteTests.Run()(line 14566) and as aline 251)--panlawbranch modelled on--returns( - T009 In
tests/Nota.SmokeTest/PanLawTests.csadd the C ABI checks from contracts/c-abi-pan-law.md § Behaviour guarantees: fresh engine = Balance;Reset()→ Balance; set Stereo (checkpoint) →Undo()→ Balance →Redo()→ Stereo;SetPanLaw(same)adds no undo step (CanUndocount unchanged — compare by undoing once and checking the previous edit is what comes back);checkpoint: falseadds none; invalid value (cast(PanLaw)7) throws/returns error and leaves the law unchanged - T010 In
tests/Nota.SmokeTest/PanLawTests.csadd "law survives every edit kind": set Stereo, then one each of add instrument track, add audio track, add return, remove a track, move a track, group tracks, add scene, remove scene, add a volume automation point, add a CV link (if a modulator kind is available without assets; else skip with a label), add + edit a MIDI clip, duplicate a track, undo, redo — after each asserteng.PanLaw == PanLaw.Stereowith a label naming the edit
Checkpoint: scripts/build.sh green; the law is stored, undoable and survives edits; nothing sounds different yet.
Phase 3: User Story 1 — Panning a stereo track moves its whole image (Priority: P1) 🎯 MVP
Goal: under Stereo, track and return pan fold the far channel in; new projects start with Stereo.
Independent Test: new project, stereo file with different L/R material, sweep pan C → L100: both materials stay, right side goes silent at L100.
Tests for User Story 1
- T011 [US1] In
tests/Nota.SmokeTest/PanLawTests.csadd the render checks (write them before T013 and confirm they fail): audio track with a 2 s WAV, L = 440 Hz sine, R = 1 000 Hz sine, both −12 dBFS. Under Stereo at pan −1: R output both tones < −90 dBFS; L output each tone at half its source amplitude (−6.0 dB ±0.5 re source). Mirror at pan +1. At pan 0: Stereo render equals Balance render sample-for-sample (FR-003). Mono WAV (440 Hz on both channels): for p ∈ {−1, −0.6, −0.25, 0.3, 0.8, 1} the per-channel 440 Hz level under Stereo matches Balance within 0.1 dB (FR-004). Unrelated L/R (the two-tone WAV): total power (L²+R² of both tones) at pan −1 within 3.5 dB of pan 0 (FR-005) - T012 [US1] In
tests/Nota.SmokeTest/PanLawTests.csadd: a return (Utility device, unity) fed by a send from the two-tone track, return panned −1 under Stereo → both tones present on the return's L output, R silent; a group containing the two-tone track, group panned −0.5: render identical under Stereo and Balance (FR-010);ProjectTemplate.ApplyDefault(eng)on a reset engine →eng.PanLaw == StereoandCanUndo == false(FR-007)
Implementation for User Story 1
- T013 [US1] In
src/native/nota.engine/src/Engine_Render.cppaddstruct PanMatrix { float ll, lr, rl, rr; };andstatic inline PanMatrix panMatrix(float pan, float vol, PanLaw law)implementing research.md R1 exactly:θ = (pan + 1)·π/4,c = cos θ,s = sin θ,b = 0.5·|pan|; Balance →{c, 0, 0, s}; Stereo withpan ≤ 0→{c − b, b, 0, s}; Stereo withpan > 0→{c, 0, b, s − b}; every coefficient ×vol. Use the file's existingkTwoPi / 8form for θ so Balance coefficients are bit-identical to today'scos(theta)/sin(theta)(compute in double, cast to float as today) - T014 [US1] In
src/native/nota.engine/src/Engine_Render.cpptrack stage ("3) Channel fader + equal-power pan",line 1264) and return stage (line 1403): replacegl/grwithconst PanMatrix m = panMatrix(pan, vol, g->panLaw)(the live graph pointer already used by the render); ifm.lr == 0 && m.rl == 0keep the existing loop body unchanged (l = in_l * m.ll; r = in_r * m.rr) so Balance renders stay bit-identical; elsel = m.ll*in_l + m.lr*in_r; r = m.rl*in_l + m.rr*in_r. Everything downstream (record tap, route bus, dest, sends, peak/RMS meters) keeps usingl/r. Do NOT touch the group stage (~line 1337) - T015 [US1] In
src/managed/Nota.Infrastructure/Persistence/ProjectTemplate.csApplyDefault: callengine.SetPanLaw(PanLaw.Stereo, checkpoint: false);beforeengine.ClearUndoHistory();, and extend the file comment with one line: new projects use the Stereo pan law (specs/006)
Checkpoint: US1 tests pass; a new project pans stereo tracks as whole images.
Phase 4: User Story 2 — Existing projects sound exactly as before (Priority: P1)
Goal: format v21 stores the law; every older project opens as Balance and is marked legacy.
Independent Test: load a v20 document with a panned stereo track → Balance + legacy, output matches the Balance law; save/reopen keeps both.
Tests for User Story 2
- T016 [US2] In
tests/Nota.SmokeTest/PanLawTests.csadd persistence checks viaProjectStoreinto a temp dir: save with Stereo → load → Stereo,PanLawLegacy == false; save with Balance +PanLawLegacy = truein theTransportState→ load → Balance, legacy true; and the migration: build a v20project.jsonin code (take a freshly captured v21 document's JSON, removemixer, setformatVersion20; one audio track with the two-tone WAV, pan −0.5), load it → law Balance,ProjectLoadResult.Transport.PanLawLegacy == true, and each output tone matches the Balance law (L tone × cos θ on L, R tone × sin θ on R, no cross-feed) within 0.01 dB (FR-006, SC-002);ProjectMigrations.Migrateon a v20 tree yieldsmixer = { panLaw: "balance", panLawLegacy: true }and leaves an existingmixeruntouched
Implementation for User Story 2
- T017 [P] [US2] In
src/managed/Nota.Application/Ports/IProjectStore.csaddbool PanLawLegacy = falseas the last positional parameter ofTransportStateand extend its doc comment: "PanLawLegacy marks a project made before the pan law (specs/006); it only drives the Mixer's OLDER PROJECT badge" - T018 [P] [US2] In
src/managed/Nota.Infrastructure/Persistence/ProjectModel.csaddpublic MixerDto? Mixer { get; set; }toProjectDocumentandpublic sealed class MixerDto { public string PanLaw { get; set; } = "balance"; public bool PanLawLegacy { get; set; } [JsonExtensionData] public Dictionary<string, JsonElement>? Extra { get; set; } }with a comment: absentmixer= a pre-v21 project = Balance + legacy - T019 [US2] In
src/managed/Nota.Infrastructure/Persistence/ProjectService.cssetCurrentFormatVersion = 21, and insrc/managed/Nota.Infrastructure/Persistence/ProjectMigrations.csappendnew Migration(20, root => { if (root["mixer"] is null) root["mixer"] = new JsonObject { ["panLaw"] = "balance", ["panLawLegacy"] = true }; })with the comment from contracts/project-format-v21.md § Migration (check the JSON naming policy used by the serializer — camelCase — and match it) - T020 [US2] In
src/managed/Nota.Infrastructure/Persistence/ProjectService.cscapture:doc.Mixer = new MixerDto { PanLaw = engine.PanLaw == PanLaw.Stereo ? "stereo" : "balance", PanLawLegacy = transport.PanLawLegacy }(threadTransportStateinto capture the same wayTransportis filled,line 61); apply: right afterline 436) callengine.Reset()(engine.SetPanLaw(law, checkpoint: false)wherelaw= Stereo for"stereo", Balance for"balance"or a nullMixer; any other string → Balance plus a load warning "Unknown pan law '…' — using Balance" - T021 [US2] In
src/managed/Nota.Infrastructure/Persistence/ProjectStore.csmapdoc.Mixer?.PanLawLegacy ?? trueintoProjectLoadResult.Transport.PanLawLegacy(~line 25, where the transport is built) - T022 [P] [US2] In
src/managed/Nota.Infrastructure/Persistence/VersionDiff.cslist a change ofmixer.panLawbetween two versions as the sound change "Pan law" (pattern: themaster.devicescomparison ~line 82) - T023 [US2] In
src/managed/Nota.App/MainWindow.Recovery.cs/MainWindow.Files.cs: addprivate bool _panLawLegacy;toMainWindow; set it fromProjectLoadResult.Transport.PanLawLegacywherever a project or autosave is loaded; setfalsewhere a new project is built (MainWindow.Files.cs~line 187 andMainWindow.Recovery.cs~line 97, both afterProjectTemplate.ApplyDefault); pass it as the last argument inTransportSnapshot()
Checkpoint: US2 tests pass; a 0.52.x project opens, sounds the same, and stays marked after save.
Phase 5: User Story 3 — Switching the pan law of a project (Priority: P2)
Goal: the Mixer footer shows and switches the law, click-free, undoable, with the OLDER PROJECT and BAL badges.
Independent Test: open a legacy project, switch to Stereo while playing, hear the change without a click, undo, save/reopen — per quickstart.md § 2.
Tests for User Story 3
- T024 [US3] In
tests/Nota.SmokeTest/PanLawTests.csadd the click test (write before T025, confirm it fails): two-tone WAV track at pan −1, render 1 s under Balance into a buffer in blocks of 256 frames via repeatedRenderOfflinecalls (keep transport playing), callSetPanLaw(Stereo)between two blocks, continue 0.5 s; assert the largest sample-to-sample step on each channel across the switch ≤ 1.5 × the largest step of the same channel in the steady state before it (SC-004); also flip back within 5 ms of the first flip and assert the same bound
Implementation for User Story 3
- T025 [US3] In
src/native/nota.engine/src/Engine.hadd audio-thread-owned membersPanLaw renderedPanLaw_ = PanLaw::Balance; int32_t panLawXfadeLeft_ = 0; int32_t panLawXfadeLen_ = 0; float panLawXfadeFrom_ = 0.f;(comment: law crossfade state, render thread only, 006) and insrc/native/nota.engine/src/Engine_Render.cppimplement the crossfade from data-model.md § Render state: at the start of each block inprocessBlockcomputepanLawXfadeLen_ = max(1, int(0.010 * sampleRate))from the rate this block renders at; ifg->panLaw != renderedPanLaw_and no fade runs, start one; if the law flips back mid-fade, restart from the current mix point (panLawXfadeFrom_). In the track and return stages, while a fade runs buildmOld = panMatrix(pan, vol, renderedPanLaw_)andmNew = panMatrix(pan, vol, g->panLaw)and lerp the four coefficients per sample witht = from + (1 − from) · (done + i) / len; after all stages of the block advance the counter byframesand, at 0, setrenderedPanLaw_ = g->panLaw. No allocation, no lock; the no-fade path is the T014 code unchanged. Also setrenderedPanLaw_directly (no fade) when the graph is replaced bynota_engine_resetor a project load while stopped, so a load never fades - T026 [US3] In
src/managed/Nota.App/MixerView.csFooter(): height 34 → 44; between the Show toggles and the crossfader add a 1 px divider (20 px tall,BorderDefault) and the PAN LAW group per contracts/ui-mixer-footer.md: label "PAN LAW" (10 px, bold, letter-spacing .14em,TextTertiary), the shell segmented control (Border.segmented+ToggleButton.segclasses fromTheme/NotaTheme.axaml) with "Stereo" / "Balance" and the tooltips "Panning moves the whole stereo image; nothing is dropped" / "Panning attenuates the opposite channel (legacy behaviour)", the hintTextBlock(11 px,TextTertiary) "Pan moves the whole image of stereo tracks and returns" / "Pan attenuates the opposite channel, as in earlier versions", and the OLDER PROJECT badge (Mono 9 px, letter-spacing .18em, 18 px tall, 1 pxBorderDefault, radius 3,TextTertiary, tooltip "Projects saved before stereo pan law open with Balance so existing mixes do not change"). Clicking the unselected segment calls_engine.SetPanLaw(law, checkpoint: true); the selected one does nothing - T027 [US3] In
src/managed/Nota.App/MixerView.csPanRow: for group strips (ti.IsGroup) add the BAL badge under the "PAN" label (Mono 7 px, letter-spacing .12em, 11 px tall, 1 pxBorderDefault, radius 3,TextTertiary, tooltip "Groups keep a unity-centre balance so grouping stays level-transparent"), collected in aList<Control> _balBadgescleared inRefresh() - T028 [US3] In
src/managed/Nota.App/MixerView.csaddpublic Func<bool>? IsOlderProject { get; set; }andSyncPanLaw()that reads_engine.PanLawand sets the selected segment, the hint text, OLDER PROJECT visibility (IsOlderProject?.Invoke() == true && law == Balance) and every_balBadgesvisibility (law == Stereo), touching controls only when the law or the legacy flag changed since the last call; call it at the end ofRefresh()and inUpdateMeters(). Insrc/managed/Nota.App/MainWindow.axaml.cs(where_mixeris constructed) set_mixer.IsOlderProject = () => _panLawLegacy;
Checkpoint: US3 tests pass; the footer works per quickstart § 2.
Phase 6: Polish & Cross-Cutting Concerns
- T029 UI verification per quickstart.md § 2 with the headless/in-app harness (isolate with
NOTA_DATA_DIR): new project → Stereo + BAL on a group; a 0.52.x project → Balance + OLDER PROJECT; switch during playback, ⌘Z from the main window and from the Mixer, save/reopen; screenshots of the footer in Ember Graphite and Ember Paper compared withnota-design/Nota Mixer v2.html - T030 [P] Performance sanity: time
RenderOfflineof the smoke-test project with 32 stereo tracks panned −0.5 under Balance vs Stereo; Stereo within +5 % (plan § Performance Goals). Record the numbers in the PR description, not in code
Nota closing tasks
- T031 Run
scripts/build.shuntil native + managed + smoke test are green (andscripts/build-linux.sh/scripts/build-win.ps1if available on this machine; otherwise note CI covers them) - T032 AGPL-3.0-only SPDX two-line header on every new source file —
tests/Nota.SmokeTest/PanLawTests.cs(and thePanLawenum file if T006 created one) - T033 New dependency: N/A
- T034
CHANGELOG.md[Unreleased]: Added — "Stereo pan law: panning a stereo track or return moves its whole image instead of dropping a channel. New projects use it; the Mixer footer shows and switches the project's pan law." Changed — "Existing projects keep the Balance pan law and sound exactly as before (marked Older project in the Mixer)." Follow the repo's entry style - T035 FEATURES.md via the
nota-featuresskill (Tracks and mixer: pan law); user docs EN + RU via thenota-docsskill (Mixer page: a "Pan law" section — the two laws, why older projects keep Balance, the BAL badge on groups — with the footer screenshot in both themes); shortcuts: N/A - T036 Engine behaviour change → smoke test extended: done in T008–T012, T016, T024 — confirm all
PanLawTestslabels appear and pass in the full run and with--panlaw
Dependencies & Execution Order
Phase Dependencies
- Setup (T001) → Foundational (T002–T010) → user stories → Polish (T029–T036)
- US1 (T011–T015) and US2 (T016–T023) both depend only on Foundational
- US3 (T024–T028) depends on Foundational and on T014 (the crossfade wraps the
matrix pan stage); its UI (T026–T028) uses
_panLawLegacyfrom T023
Within the phases
- T002 → T003 → T004 → T005 → T007; T006 ∥ T007 after T005
- T008 → T009 → T010 (same file)
- Tests in one file are sequential: T011 → T012 → T016 → T024
- T013 → T014; T015 after T006
- T017 ∥ T018 ∥ T022; T019 → T020 → T021; T023 after T017 + T021
- T025 after T014; T026 → T027 → T028 (same file)
Parallel Opportunities
- T006 and T007 (Application vs Infrastructure)
- After Foundational: engine work for US1 (T013–T014) alongside managed persistence for US2 (T017–T022)
- T017, T018, T022 touch different files
- T030 alongside T029
Parallel Example: after Foundational
Task: "T013–T014 Stereo pan matrix in src/native/nota.engine/src/Engine_Render.cpp"
Task: "T017 TransportState.PanLawLegacy in src/managed/Nota.Application/Ports/IProjectStore.cs"
Task: "T018 MixerDto in src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs"
Task: "T022 Pan law in src/managed/Nota.Infrastructure/Persistence/VersionDiff.cs"
Implementation Strategy
MVP
US1 alone changes how every new project sounds, but without US2 an old project would also open with the engine default — which is Balance, so old projects are already safe after Foundational + US1. US2 adds the explicit format and the legacy mark; US3 adds the switch. Ship all three together (one PR, constitution V): US1 without US3 would leave users unable to see or change the law.
Incremental order
- T001–T010 → build green, nothing audible changed
- US1 → new projects pan in stereo
- US2 → format v21, older-project mark
- US3 → crossfade + Mixer footer
- Polish → UI verification, docs, final build
Notes
- Do not commit or push — the user reviews and commits.
.specify/feature.jsonpoints atspecs/007-midi-note-editing(another session); run any spec-kit script for this feature withSPECIFY_FEATURE_DIRECTORY=specs/006-stereo-pan-law SPECIFY_FEATURE_NO_PERSIST=1.
Phase 7: Convergence
- T037 Reconcile the undo label in FR-009 ("one undo step (labelled "pan law")"): Nota's engine undo has no step labels (
nota_engine_undo, research R7), so either drop the label from the spec via/speckit-clarifyor record it as out of scope — no code change unless a labelled-undo system is specified separately per FR-009 (partial) - T038 Make a project load /
nota_engine_resettake the new pan law without the 10 ms crossfade (insrc/native/nota.engine/src/Engine_Render.cpp/Engine.cpp: when the graph is replaced by reset or load, setpanLawFrom_ = panLawTo_ = lawandpanLawPos_ = 1on the audio side), or record inspecs/006-stereo-pan-law/research.mdR4 why the fade on load is kept per T025 / data-model § Render state (partial) - T039 Add a sample-exact null test to
tests/Nota.SmokeTest/PanLawTests.cs: render the v20 fixture project and compare it per sample with the Balance law computed from the source WAV (cos θ·L,sin θ·R× track volume), asserting the residual is below −120 dBFS per SC-002 (partial)