Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
description: "Tasks: plug-in card shows a preview of the plug-in's interface"
Tasks: Plug-in card shows a preview of the plug-in's interface
Input: Design documents from specs/046-plugin-card-preview/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md
Tests: The constitution requires smoke-test coverage for new C ABI surface, so the smoke test is included (T020).
Format: [ID] [P?] [Story] Description
- [P]: Can run in parallel (different files, no dependencies)
- [Story]: US1 (preview on the card), US2 (survives save/reopen), US3 (plain card when none). US4 (offscreen capture on add) is deferred (research R7).
Phase 1: Setup
- T001 Add
pluginhost/hosting/EditorSnapshot.cpptonota_pluginhostand to theLANGUAGE OBJCXXlist on Apple insrc/native/nota.engine/CMakeLists.txt
Phase 2: Foundational (engine storage + C ABI)
- T002 [P] Create
src/native/nota.engine/src/devices/EditorPreview.h: structEditorPreview { std::shared_ptr<const std::vector<uint8_t>> jpeg; uint32_t serial = 0; bool empty() const; static EditorPreview make(std::vector<uint8_t> bytes); }wheremakeassigns a process-wide atomic serial starting at 1 ("0 = none"); SPDX header - T003 Add
editorPreview()/setEditorPreview(EditorPreview)(private member, comment: view data, message thread only, never read by the audio thread, follows moves/ copies/undo) tosrc/native/nota.engine/src/devices/Device.h, and a publicEditorPreview editorPreview;next tofoldedinsrc/native/nota.engine/src/devices/Instrument.h - T004 Copy the preview in
Engine::cloneDevice(next tosetFolded) and in the hosted-plug-in branch ofEngine::cloneInstrumentFrominsrc/native/nota.engine/src/engine/Engine_Devices.cpp - T005 Add
Engine::trackEditorPreview(trackId, di) constandEngine::setTrackEditorPreview(trackId, di, EditorPreview)(lookup as intrackEditorOpen; -1 = instrument) tosrc/native/nota.engine/src/engine/Engine.handEngine_Devices.cpp - T006 Declare
nota_plugin_preview_get/_set/_serialinsrc/native/nota.engine/include/nota/nota_engine.hand implement them insrc/native/nota.engine/src/abi/nota_engine_device.cppper contracts/c-abi.md ("size< 0 or > 4 MB, ordataNULL with size > 0 →NOTA_ERR_INVALID_ARG"; size 0 clears; unknown track/index: get/serial return 0, set returnsNOTA_ERR_INVALID_ARG) - T007 [P] Add the three P/Invokes to
src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs, the membersGetPluginPreview/SetPluginPreview/PluginPreviewSerialtosrc/managed/Nota.Application/Engine/IAudioEngine.csand their implementation tosrc/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs
Checkpoint: the preview can be stored, read and cloned through the ABI.
Phase 3: User Story 1 — the card shows the plug-in's look (P1) 🎯 MVP
Goal: closing a plug-in window puts a darkened, undistorted picture of it behind the card.
Independent test: quickstart steps 3–7.
- T008 [P] [US1] Create
src/native/nota.engine/pluginhost/hosting/EditorSnapshot.h:std::vector<uint8_t> snapshotEditor(juce::DocumentWindow&)returning JPEG bytes or empty - T009 [US1] Implement
EditorSnapshot.cpp: macOSCGWindowListCreateImageviadlsymon the window's ownwindowNumber, crop the title bar, draw into a CG bitmap backed by ajuce::Imageat the target size withkCGInterpolationHigh; WindowsPrintWindow(PW_CLIENTONLY | PW_RENDERFULLCONTENT) +HALFTONEStretchBlt; Linux returns {}. Shared: target size "shorter side ≤ 520 px, longer ≤ 1040 px, never upscale"; blank check "16 × 16 samples, luma range < 6/255 → reject"; JPEG quality 0.8 viajuce::JPEGImageFormat(research R1, R2, R4, R5) - T010 [US1] In
src/native/nota.engine/pluginhost/hosting/PluginEditorWindow.h/.cpp: addstd::function<void()> onHidecalled bycloseButtonPressed()beforesetVisible(false);EditorHostgainsstd::function<void(std::vector<uint8_t>)> onPreview, wiresonHideat window creation, and snapshots inclose()while the window is still visible; empty snapshots are dropped - T011 [P] [US1] Wire
editor_.onPreviewtosetEditorPreview(EditorPreview::make(...))insrc/native/nota.engine/pluginhost/hosting/PluginEffect.cpp - T012 [P] [US1] Wire
editor_.onPreviewtoeditorPreview = EditorPreview::make(...)insrc/native/nota.engine/pluginhost/hosting/PluginInstrument.cpp - T013 [P] [US1] Create
src/managed/Nota.App/Controls/PluginPreviewBackdrop.cs: a control holdingBitmap? Image, drawing it cover-fit (uniform scale, top-anchored, centred horizontally, clipped) and over it a vertical gradient inNotaPalette.SurfaceCard(alpha 0.80 top, 0.62 middle, 0.90 bottom); redraws onNotaPalette.Changedwhile attached; a static decode cache keyed by serial (last 32) viaPluginPreviewBackdrop.For(engine, track, di) - T014 [US1] In
src/managed/Nota.App/DeviceChainView.Plugin.cs: on S put the card body on a backdrop (backdrop under the padded body in aPanel); insrc/managed/Nota.App/DeviceCards/PluginCard.cson L put the info column's section on a backdrop; both pollPluginPreviewSerialin a device refresher and swap the image when it changes; also refresh right after the card's Close-editor click - T015 [US1] Check the S/L cards in Studio Dark and Studio Light with the headless
harness (memory
nota-ui-verify): text legible, no stretching
Phase 4: User Story 2 — survives save and reopen (P1)
Goal: previews are saved in the project and restored on open.
Independent test: quickstart step 8; smoke test T020.
- T016 [US2] Add
Preview(string?) toDeviceDtoandInstrumentDtoinsrc/managed/Nota.Infrastructure/Persistence/ProjectModel.cs - T017 [US2] In
src/managed/Nota.Infrastructure/Persistence/ProjectService.cssave:Preview = RegisterBlob(doc, engine.GetPluginPreview(...))for the instrument and for each device inCaptureDevices, only when non-empty - T018 [US2] In
ProjectService.csload (ApplyDevicesand the instrument path): after the device/state is applied,SetPluginPreview(track, di, ReadBlob(...))whenPreviewis set; a missing blob is skipped silently
Phase 5: User Story 3 — plain card without a preview (P2)
Goal: no capture → today's card; a failed capture never replaces a good one.
- T019 [US3] Confirm
PluginPreviewBackdropdraws nothing (no gradient either) whenImageis null, so a card without a preview is pixel-identical to today; and thatEditorHostnever callsonPreviewwith an empty/blank snapshot (FR-009, FR-010)
Phase 6: Polish & cross-cutting
- T020 Create
tests/Nota.SmokeTest/PluginPreviewTests.cs(model:DeviceFoldTests.cs) and register it: set/get/serial round trip on an effect and the instrument; serial changes on set; size 0 clears (serial 0); invalid args; duplicate (⌘D path) and copy/paste carry it; project save/load keeps it; a project saved without previews loads with none - T021 Run the quickstart by hand on macOS with a real plug-in (Supercharger / Massive) — done with a harness on the real engine: real Supercharger VST3 window captured (53.8 KB, title bar cropped), recapture changes the serial, close ≈ 60 ms; cards rendered S/L in Studio Dark, Studio Light, Ember Paper and with no preview. Not covered: the live app's undo/save UI flow, Windows capture (compiled only in CI)
Nota closing tasks
- T022 Run
scripts/build.shuntil native + managed + smoke test are green - T023 AGPL-3.0-only SPDX two-line header on every new source file
- T024 New dependency: N/A (JUCE
JPEGImageFormat, CoreGraphics and Win32 are already linked) - T025
CHANGELOG.md[Unreleased]entry - T026 FEATURES.md updated (plug-in card entry); nota-docs page — left for a follow-up; shortcuts N/A
- T027 Engine behaviour change covered by T020
Dependencies & Execution Order
- Phase 1 → Phase 2 → (US1, US2 in parallel) → US3 → Polish.
- T002 before T003–T006; T006 before T007's implementation compiles against the ABI.
- T008 before T009/T010; T010 before T011/T012. T013 before T014.
- US2 (T016–T018) depends only on Phase 2.
Parallel opportunities
- T002 ∥ T007 (header vs managed interop once the ABI shape is fixed by contracts/c-abi.md).
- T011 ∥ T012 ∥ T013.
- US2 ∥ US1 native capture work.
Implementation Strategy
MVP = Phases 1–3 (capture + card). US2 makes it persistent and ships in the same PR. US4 (offscreen capture on add) is a follow-up issue.