Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
description: "Task list for live MIDI notes while recording (#56)"
Tasks: Live MIDI notes while recording
Input: Design documents from /specs/017-live-midi-record-notes/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md
Tests: Included. The constitution (IV) and FR-011 require smoke coverage for the engine changes and the new C ABI read. Visual checks use the headless capture recipe in quickstart.md.
Organization: Tasks are grouped by user story so each one can be implemented and tested on its own.
Format: [ID] [P?] [Story] Description
- [P]: Can run in parallel (different files, no dependencies)
- [Story]: Which user story this task belongs to (US1–US4)
Path Conventions
- Engine:
src/native/nota.engine/src/, C ABIsrc/native/nota.engine/include/nota/nota_engine.h - Managed:
src/managed/Nota.Application/,src/managed/Nota.Infrastructure/,src/managed/Nota.App/ - Smoke tests:
tests/Nota.SmokeTest/
Phase 1: Setup
Purpose: Test scaffolding the stories add to
- T001 Create
tests/Nota.SmokeTest/LiveRecordTests.cswith the two-line AGPL SPDX header, astatic class LiveRecordTestsexposingIEnumerable<(bool, string)> Run()and aRender(NotaEngine, int blocks)helper modelled onMpeTests.Recording(tests/Nota.SmokeTest/MpeTests.cs:184). Register it intests/Nota.SmokeTest/Program.csthe same wayMpeTestsis registered
Phase 2: Foundational (Blocking Prerequisites)
Purpose: The held-note snapshot, its C ABI read and the UI plumbing that every story draws from
⚠️ CRITICAL: No user story work can begin until this phase is complete
T002 In
src/native/nota.engine/src/Engine.h:- add the snapshot state:
std::atomic<uint32_t> heldSeq_,std::atomic<int32_t> heldTrack_,heldScene_andheldCount_,std::atomic<double> heldNow_, and 256 slots of relaxed atomics (pitch, source, startBeat, velocity); - add a private
publishHeldSnapshot(double nowBeat)and a publicint32_t recordHeldNotes(NotaRecordHeldNote* out, int32_t maxN, int32_t* trackId, int32_t* scene, double* nowBeat) const.
Rules: "count 0..256", "live (128) + routed (128)", "seq odd while writing; readers retry on odd or changed" (data-model.md § Held-note snapshot).
- add the snapshot state:
T003 Implement
publishHeldSnapshotinsrc/native/nota.engine/src/Engine_Render.cpp:- bump the seq to odd, write the compacted entries from
pendingActive_/pendingStart_/pendingVel_(source 0) andrecRoutedActive_/recRoutedStart_/recRoutedVel_(source 1), then the track id (recordTrackRt_, orrecordSessionTrackId_for slot takes), the scene (recordSessionScene_, else −1), the count andnowBeat, then bump the seq to even; - with no MIDI take, write count 0 and track 0;
- call it once at the end of
processBlock, after capture.
No allocation or locks (AR-6).
- bump the seq to odd, write the compacted entries from
T004 Implement
Engine::recordHeldNotesinsrc/native/nota.engine/src/Engine_Recording.cpp(next toliveHeldNotes,:196):- read with up to 4 retries on an odd or changed seq, else return 0;
out == NULLormaxN <= 0returns the count without copying (contracts/c-abi.md § Guarantees).
T005 Add
NotaRecordHeldNoteandnota_engine_record_held_notestosrc/native/nota.engine/include/nota/nota_engine.hafternota_engine_audio_record_peaks, exactly as in contracts/c-abi.md. Add the shim tosrc/native/nota.engine/src/nota_engine_track.cppnext tonota_engine_live_held_notes(:654)T006 [P] Add the managed mapping:
- the
[StructLayout(LayoutKind.Sequential)] NotaRecordHeldNotestruct (int pitch, int source, double startBeat, float velocity) and the P/InvokeRecordHeldNotesinsrc/managed/Nota.Infrastructure/Interop/NativeMethods.cs; - the wrapper in
src/managed/Nota.Infrastructure/Interop/NotaEngine.cs; int RecordHeldNotes(NotaRecordHeldNote[] buffer, out int trackId, out int sessionScene, out double nowBeat)insrc/managed/Nota.Application/Engine/IAudioEngine.cs, implemented by everyIAudioEngineimplementation and test stub (search forAudioRecordPeaksimplementations).
- the
T007 Create
src/managed/Nota.App/RecordPreview.cs(SPDX header): one instance owned byMainWindow.Update(IAudioEngine)reads the snapshot once into a reused 256-entry buffer and exposesTrackId,SessionScene,NowBeatandReadOnlySpan<NotaRecordHeldNote> Held;Clear()empties it.
No per-tick allocation.
T008 Wire
RecordPreviewinsrc/managed/Nota.App/MainWindow.axaml.cs:318:- call
_recordPreview.Update(Engine)at the start of theRecordingTickhandler, beforeTimeline.Refresh(rebuildHeaders: false); - clear it when recording stops (the first tick where
Engine.IsRecordingis false, fromPlayheadUpdated) and refresh once; - pass the instance to
ArrangementView,SessionViewand the piano-roll creation sites (MainWindow.Detail.cs:430,:615).
- call
T009 Smoke tests in
tests/Nota.SmokeTest/LiveRecordTests.cs, using a 120 BPM, armed built-in instrument track, recording:- after
TrackNoteOn(t, 60, 0.8f)and rendering, the read returns pitch 60, source 0 and the take's track id; start_beatequals the note-on beat;now_beatincreases across renders;out == nullreturns the count;- with no take, the read returns 0 and track 0.
- after
Checkpoint: The engine publishes held notes and the UI receives them every recording tick
Phase 3: User Story 1 — See held notes grow in the arrangement (Priority: P1) 🎯 MVP
Goal: Held notes appear on key-down and grow with the playhead in the arrangement take. On release, the stored note replaces them without a jump. Notes from the count-in and keys held across Record are kept at their real start, and the clip grows left to include them (FR-001–FR-003, FR-007, FR-012, FR-013).
Independent Test: Record in the arrangement, hold a key for several beats, release, and compare with the stored note. Repeat with a pickup on the count-in, and with a take at 1.1 and a key pressed one beat early (quickstart.md §1–2).
Tests for User Story 1
- T010 [P] [US1] Smoke tests in
tests/Nota.SmokeTest/LiveRecordTests.cs:- (a) note-off removes the pitch from the next read, and after
Pollthe clip has the note with the same start, length and pitch (contracts/c-abi.md: never seen twice or missing); - (b)
SetRecording(false)with a key held empties the snapshot and stores nothing for that key.
- (a) note-off removes the pitch from the next read, and after
- T011 [P] [US1] Smoke tests in
tests/Nota.SmokeTest/LiveRecordTests.cs, usingSetCountIn(1)with Record from stop at bar 5 (beat 16):- (a) a note on during the count-in's last beat and off before beat 16 is stored at beat 15, the take's clip starts at 15, and an offline render has energy at beat 15;
- (b) from 1.1, a key pressed 1 beat before 1.1 and held to beat 2 gives clip start 0 and the note's
startBeat ≈ −1, length ≈ 3, and the render sounds the note from 0; - (c) with the transport rolling and a key down at beat 3, Record at beat 4 and release at beat 6 store the note from beat 3.
Implementation for User Story 1
T012 [US1] Add a capture clock in
src/native/nota.engine/src/Engine_Render.cpp/Engine.h.captureBeat(blockStartBeat)returns:- the block start beat while rolling;
takeStartBeat − (countInTotal_ − countInPos_)whilecountInActive_, wheretakeStartBeatis the transport playhead beat (it does not move during the count-in).
Source of truth: research R2 and data-model.md § Capture clock. In
drainLiveMidi(:413), capture whenrec && (playing || countInActive_)instead ofrec && playing(:459), and use the clock fornowBeatwhen no Session slot is active.T013 [US1] Seed held keys at the record edge in
src/native/nota.engine/src/Engine_Render.cpp/Engine.h(research R3):- add audio-thread arrays
liveDown_[128],livePressBeat_[128],livePressVel_[128]andlivePressTrack_[128], updated on every live note-on/off indrainLiveMidi, whether or not recording; - set
livePressBeat_from the capture clock when rolling or in a count-in, else mark it "pressed while stopped"; - on the
rec != prevRecording_rising edge (:417), seedpendingActive_/pendingStart_/pendingVel_from keys still down whose track matches (livePressTrack_ < 0 || == recordTrackRt_); - start beat: the press beat if pressed while rolling; the count-in's first beat (
takeStartBeat − countInTotal_) if pressed while stopped and a count-in starts; else the take start beat; - on the falling edge, clear as today.
- add audio-thread arrays
T014 [US1] Move the clip's left edge in
Engine::pollinsrc/native/nota.engine/src/Engine_Render.cpp(:276–292), arrangement branch (research R4):- before appending each
RecordedNote, ifr.startBeat < clip.startBeat, setnewStart = max(0.0, r.startBeat)anddelta = clip.startBeat − newStart; - shift every existing note's
startBeat += delta, thenclip.lengthBeats += deltaandclip.startBeat = newStart; - then compute
n.startBeat = r.startBeat − clip.startBeat, which may stay negative only whenr.startBeat < 0.
Keep
republishWithTrackRaw, with no new undo step.- before appending each
T015 [US1] Negative-start render rule: a note with
startBeat < 0andstartBeat + lengthBeats > 0sounds from the clip start with lengthstartBeat + lengthBeats. Notes withstartBeat ≥ lengthBeatsstay skipped (data-model.md § Stored early note). Apply it at:src/native/nota.engine/src/Engine_Render.cpp:524(computeBlockMidi);:749and:765(the session/expression paths; read each site and keep its semantics otherwise);src/native/nota.engine/src/Engine_Tracks.cpp:1807.
The expression lookup for such a note starts at beat offset
−startBeat.T016 [US1] Draw held notes in the arrangement take in
src/managed/Nota.App/ArrangementView.LaneControl.cs, after the clip loop and near the audio take block (:1349):- for the row whose track id equals
RecordPreview.TrackIdwithSessionScene < 0, and only if visible, draw each held note fromBeatToX(startBeat)toBeatToX(max(startBeat, NowBeat)), at least 2 px wide; - use the pitch mapping of the take's clip (
DrawClipBody's pitch range), extended to include held pitches, and the track's note colour; - when the earliest held start is before the clip start, draw a faint take extension box from it to the clip start first (contracts/ui-preview.md § Arrangement take).
Allocate no new geometry when
Heldis empty.- for the row whose track id equals
Checkpoint: US1 works: held notes grow, early notes are kept, and the smoke tests pass
Phase 4: User Story 2 — Short appear animation (Priority: P2)
Goal: Each new note fades in from the accent colour once, over 150 ms (FR-008, SC-006)
Independent Test: Record staccato notes and a held note; each animates once and none re-animates on growth or release (quickstart.md §2.3)
T017 [US2] Add the appear tracker to
src/managed/Nota.App/RecordPreview.cs(research R7, data-model.md § Appear-animation entry):- a
Dictionary<(int pitch, long startKey), long firstSeenTicks>keyed by pitch andMath.Round(startBeat * 1e6)(absolute beat for the arrangement, slot-local for Session); Updateadds held notes not yet present, and adds notes newly present in the take's stored notes (compare against the previous tick's key set; the caller passes the take clip's notes in absolute beats) that were never seen held;- drop entries older than 150 ms;
double Progress(int pitch, double startBeat)returns 1 when the note is absent.
Reuse collections; no per-tick allocation in steady state.
- a
T018 [US2] Apply the animation when drawing held and stored take notes in
src/managed/Nota.App/ArrangementView.LaneControl.cs. For notes withProgress < 1:- draw separately from the batched
StreamGeometrywith opacity0.35 + 0.65·e(p); - fill = blend(accent, note colour, e(p)), with ease-out
e(p) = 1 − (1 − p)²; - take the accent from the theme tokens via the
nota-designskill and never hard-code it.
Notes at
Progress == 1stay in the batched geometry.- draw separately from the batched
T019 [US2] Visual check with the headless harness (quickstart.md §2): a stub
IAudioEngine.RecordHeldNotes, the take shot at progress 0, 0.5 and 1 in Studio Dark and Studio Light. Keep the harness in /tmp, not in the repo. If 30 Hz looks stepped in the app, add the animation-only 60 Hz timer insrc/managed/Nota.App/MainWindow.axaml.cs; it runs only while an entry is younger than 150 ms (contracts/ui-preview.md § Repaint rules)
Checkpoint: US1 + US2: notes grow and animate in
Phase 5: User Story 3 — Held notes in the piano roll (Priority: P2)
Goal: The piano roll showing the take's clip draws held notes growing (FR-006)
Independent Test: Open the record clip in the piano roll, record, hold a key; the note grows on the grid. With another clip open, nothing is drawn (spec US3)
- T020 [US3] In
src/managed/Nota.App/PianoRollView.cs, add a held-note overlay:- a
RecordPreviewreference plus the take's clip start beat and a flag "this roll shows the record clip", set fromMainWindow.Detail.cswhen_editorTrackId == RecordPreview.TrackIdand_editorClipIndexis the take clip; - draw on the grid control after the notes: x from
startBeat − clipStarttoNowBeat − clipStart, at the note's pitch row; - it is not hit-testable, not selectable and not part of
SetNotes; - apply the
Progressanimation as in T018; - notes left of beat 0 are clipped at the left edge unless the roll shows negative beats.
- a
- T021 [US3] In
src/managed/Nota.App/MainWindow.Detail.cs(ReloadEditorNotes,:500), find the take clip withEngine.TryGetClipInfo(its start may move left during recording, T014), pass the current clip start to the roll each recording tick, and invalidate the overlay. Clear the flag when recording stops
Checkpoint: The piano roll mirrors the arrangement preview
Phase 6: User Story 4 — Routed MIDI and Session slots (Priority: P3)
Goal: The same preview for "MIDI In" capture and Session slot takes, including loop wrap (FR-004, FR-005)
Independent Test: (a) Record a track fed by routed MIDI and hold a note on the source. (b) Record into a Session slot and hold a note across the loop end (quickstart.md §1 table, §2.6)
Tests for User Story 4
- T022 [P] [US4] Smoke tests in
tests/Nota.SmokeTest/LiveRecordTests.cs:- (a) a destination armed with
midiFromTrackIdset to a source track; a note held on the source shows in the read withsource = 1, and on release is stored once; - (b) Session slot recording (
nota_session_record_slot) with a key held: the read givessession_sceneequal to the scene and a slot-localstart_beat(0 ≤ start < slot length); - (c) N/A: a Session slot take launches without a count-in (
launchSlot), so no pickup can precede it (research R5).
- (a) a destination armed with
Implementation for User Story 4
- T023 [US4] In
src/native/nota.engine/src/Engine_Render.cpp,captureRoutedNotes(:495) and its gate (:682), capture whenplaying || countInActive_, using the capture clock (T012) instead of(blockStart + off) / spbduring the count-in. Routed notes already populaterecRoutedActive_, so they enter the snapshot through T003 - T024 [US4] Draw held notes in the recording Session slot in
src/managed/Nota.App/SessionView.Grid.cs, near the take drawing at:569:- when
RecordPreview.SessionSceneequals the slot's scene andTrackIdits track, draw notes atx = startBeat / slotLen; - draw a note whose
NowBeat < startBeat(wrapped) as two pieces: start → slot end, and 0 →NowBeat; - use the slot's mini-note pitch mapping and the
Progressanimation (contracts/ui-preview.md § Session slot).
- when
Checkpoint: All stories work
Phase 7: Polish & Cross-Cutting Concerns
T025 Performance check (quickstart.md §3):
- stopped and idle, the repaint rate and CPU are unchanged versus
develop; - over a 2-minute continuous MIDI take,
XrunCountstays at 0 and UI CPU is within 10% of an audio take of equal length.
Record the numbers in the PR description.
- stopped and idle, the repaint rate and CPU are unchanged versus
T026 Run quickstart.md §2 end-to-end in the app or the UI verify harness, including the 1.1 head-reveal (move the clip right one bar, extend its left edge, and hear the pickup)
T027 [P]
CHANGELOG.md[Unreleased], Added: held notes show and grow while recording MIDI, with an appear animation. Changed: notes played on the count-in and keys held when recording starts are now recorded at their real position (#56)T028 [P] Update FEATURES.md via the
nota-featuresskill (live MIDI recording preview; count-in pickups recorded)T029 [P] Update the user docs via the
nota-docsskill: the recording page (EN + RU) gets live notes and count-in pickups, with a re-shot screenshot of a take with growing notesT030 Shortcuts via
nota-shortcuts: N/A, no bindings change
Nota closing tasks (PR gates)
- T031 Run
scripts/build.shuntil native, managed and the smoke test (includingLiveRecordTests) are green - T032 AGPL-3.0-only two-line SPDX header on the new files (
tests/Nota.SmokeTest/LiveRecordTests.cs,src/managed/Nota.App/RecordPreview.cs) - T033 New dependency: N/A (none added)
- T034 Engine behaviour change is covered by
tests/Nota.SmokeTest/LiveRecordTests.cs(T009, T010, T011, T022)
Dependencies & Execution Order
Phase Dependencies
- Setup (T001) → Foundational (T002–T009) → user stories → Polish.
- In Foundational, T002 → T003 → T004 → T005 → T006, then T007 → T008. T009 needs T005 and T006.
User Story Dependencies
- US1 (P1): after Foundational. T012 → T013 (the seeding uses the clock); T014 and T015 can follow in either order; T016 needs T007 and T008.
- US2 (P2): needs US1's arrangement drawing (T016) to animate it. T017 → T018 → T019.
- US3 (P2): after Foundational, independent of US1's engine work for live input. T020 → T021. It shares the
ProgressAPI from T017; without US2 it draws unanimated. - US4 (P3): T023 needs T012 (the capture clock). T024 needs T007.
Parallel Opportunities
- T006 (managed interop) runs alongside T007 once T005's signature is fixed.
- The test tasks T010, T011 and T022 can be written together because they are independent sections of one new file. Merge them carefully.
- After Foundational: engine work (T012–T015, T023) and UI work (T016, T020, T024) touch different files and can run in parallel.
- T027, T028 and T029 are independent.
Parallel Example: User Story 1
# Engine and UI halves of US1 side by side:
Task: "T012–T015 capture clock, seeding, clip left move, negative-start render in src/native/nota.engine/src/"
Task: "T016 draw held notes in src/managed/Nota.App/ArrangementView.LaneControl.cs"
# Tests together:
Task: "T010 + T011 in tests/Nota.SmokeTest/LiveRecordTests.cs"
Implementation Strategy
MVP First (User Story 1 Only)
- T001, then T002–T009.
- T010–T016. Then run
scripts/build.shand quickstart §2 steps 1–4 without the animation. - Stop and validate: held notes grow and early notes are kept.
Incremental Delivery
- Add US2 (animation), then US3 (piano roll), then US4 (routed and Session), validating each at its checkpoint.
- Finish with Polish and the closing gates.
Notes
- Keep every audio-thread change allocation-free and lock-free (AR-6). The snapshot writer never waits.
- Don't commit. The user reviews and commits (project memory).
Phase 8: Convergence
- T035 Return no held notes (track 0) from
Engine::recordHeldNotesinsrc/native/nota.engine/src/Engine_Recording.cppwhile an audio take records into a Session slot (recordSessionAudio_), and publish nothing for it inpublishHeldSnapshot— todayrecordTrackId_from an earlier MIDI take is never reset, so live keys played during a Session audio take preview on that stale arrangement track; cover it intests/Nota.SmokeTest/LiveRecordTests.csper FR-007 (contradicts) - T036 Seed routed-MIDI notes still held on the source when recording starts (
recRoutedActive_from the source's held notes, start at their press beat or the take's first moment) insrc/native/nota.engine/src/Engine_Render.cpp, as research R3 plans for routed input, with a smoke check intests/Nota.SmokeTest/LiveRecordTests.csper FR-012 / plan: research R3 (partial) - T037 Review the Session recording cell drawing the slot's already-stored notes in
src/managed/Nota.App/SessionView.Grid.cs(DrawRecordingNotes) — contracts/ui-preview.md only asks for the held notes there; keep it (and note it in the contract) or draw held notes only per FR-006 (unrequested)