diff --git a/.github/workflows/virtual-lab.yml b/.github/workflows/virtual-lab.yml new file mode 100644 index 00000000..6830d4a4 --- /dev/null +++ b/.github/workflows/virtual-lab.yml @@ -0,0 +1,47 @@ +name: Virtual Lab Stage A host tests +on: + push: + branches: + - lab/virtual-lab-stage-a-20261118 + pull_request: + paths: + - 'tools/lab/**' + - 'tests/virtual-lab.test.mjs' + - 'tests/lab/**' + - 'engine/px_gr_meter.h' + - '.github/workflows/virtual-lab.yml' +jobs: + host-profile: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Check compiler for simulated pedal + run: cc --version + - name: Run source-locked WASM DSP and cycle-budget tests + run: node --test tests/virtual-lab.test.mjs + - name: Profile 52 factory presets (synthetic quiet, nominal, hard) + run: node tools/lab/dsp-profile.mjs --preset all --seconds 0.1 --warmup 0 --out build/lab/dsp-profile.json + - name: Compile real C DSP engine and profile raw pre-limiter output + run: | + mkdir -p build/lab + cc -std=c11 -O2 -fno-builtin -ffp-contract=off -Iengine tests/lab/raw-output.c engine/px_dsp.c firmware/px_math.c -lm -o build/lab/raw-output + build/lab/raw-output 25 > build/lab/raw-output.csv + head -n 5 build/lab/raw-output.csv + - name: Verify UI-rate gain reduction conversion and OFF fast path + run: | + cc -std=c11 -O2 -Wall -Wextra -Iengine tests/lab/gr-meter.c -o build/lab/gr-meter + build/lab/gr-meter + if grep -E '\\blog10f[[:space:]]*\\(' engine/px_gr_meter.h; then echo 'Unexpected log10f in GR meter'; exit 1; fi + - name: Retain test evidence + if: always() + uses: actions/upload-artifact@v4 + with: + name: bluesbox-host-profile + path: | + build/lab/dsp-profile.json + build/lab/raw-output.csv + if-no-files-found: warn diff --git a/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.md b/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.md new file mode 100644 index 00000000..26c66fe3 --- /dev/null +++ b/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.md @@ -0,0 +1,266 @@ +# BluesBox / OpenPocket — FX Containers +## User design brief, agreed architecture and implementation record + +**Record date:** 18 November 2026 +**Document role:** Design and implementation handoff, not a firmware build or new methodology revision +**Reference release:** BluesBox **V 04.2.2** / **BlackBox_978** — experimental +**Families:** **DSPL**, **OP**, **OLD** +**Evidence rule:** “Implemented” below means reported implemented and packaged in the Guitar project discussion. The individual V 04.2.2 container ZIP bytes have **not** been freshly re-extracted or rehashed during this documentation pass. The accessible public BluesBox GitHub branch contains an older V52-era code baseline, not necessarily the integrated BlackBox_978 source. + +--- + +## 1. User design brief — preserved intent + +The user proposed a modular architecture in which guitar-effect algorithms are maintained as portable *DSP containers*, rather than buried in one undifferentiated firmware source tree. The higher-order goals are: + +- **Independent development.** Work on a single device algorithm or container without having to rebuild or rewrite unrelated devices; preserve prior successful models, source, measurements and archived results. +- **Parallel comparison.** Several containers can be present in one pedal, allowing different interpretations of the same circuit or effect to coexist, be selected and compared with the same guitar DI and levels. +- **Selective deployment.** Make it possible to build a pedal with only a chosen set of containers, so performance and memory tests are not distorted by unused processors. This is an intended build variant, not a claim that live code hot-swapping exists. +- **Transparent naming.** All newly designed models must have capitalised **DSPL** in the on-device name, e.g. **JC120 DSPL**; stock **OpenPocket** models are marked **OP**; earlier in-house algorithms are marked **OLD**. These are provenance/family markers, not fidelity ratings. +- **Self-contained release handoffs.** Every future consolidated firmware ZIP contains the **firmware with selected effects baked in**, plus the **latest separately versioned DSPL, OP and OLD source-container ZIPs**, including effect processors, adapters and associated dependencies/tests/provenance. An individual newly developed effect may also have its own BB V.04 ZIP. +- **Reliable editor and diagnostics.** The local Edge editor must expose the real catalog names and chain order, allow parameter and model changes, distinguish unsaved auditions from committed presets, and work with the real-device telemetry/install tools. +- **Testing and portability.** The same portable DSP sources should, where feasible, run in host C, WebAssembly, native macOS, and later iOS applications. A target-cycle/firmware emulator should quantify overload even when an unrestricted offline renderer is allowed to keep processing. + +The aim is sonic/behavioural fidelity to named devices. CPU or effect count is never an unmeasured substitute for tone, attack, low-level harmonics, gain staging, sustain and decay. + +**Scope resolution agreed in conversation:** The immediate implementation uses **build-time source containers**. It does **not** create hot-loadable compiled plug-ins, a runtime module loader, an on-device dynamic linker, or a new stable binary plug-in ABI. These remain possible future work, but must not be misrepresented as delivered. + +--- + +## 2. Container families and model identities + +| Family | What it contains | Required label | Primary use | +|---|---|---|---| +| **DSPL** | Newer BluesBox DSP designs and V.04 implementations | Model name plus **DSPL** | Main fidelity-development family | +| **OP** | Stock OpenPocket-origin DSP models | Model name plus **OP** | Baseline, reference and alternatives | +| **OLD** | Previous BluesBox-developed models | Model name plus **OLD**, or a short numbered OLD variant | Comparison and gradual controlled retirement | + +Names are presentation metadata; persisted model type IDs stay fixed regardless of which containers are selected for a build. + +### 2.1 DSPL inventory: twelve reported V.04 integrations + +| Processing role | On-device label | V.04 source identity | +|---|---|---| +| AMP | **5E3 DSPL** | 1960 Fender Tweed Deluxe 5E3 | +| DRIVE | **DUMBLE DSPL** | DumbleDrive | +| Ambience / spatial | **AMB DSPL** | Ambience | +| DRIVE | **LPB1 DSPL** | Electro-Harmonix LPB-1 | +| DRIVE | **TS9 DSPL** | Ibanez TS09 / TS9 | +| DRIVE | **TS808 DSPL** | Ibanez TS808 | +| AMP | **L5C1 DSPL** | L5 Channel 1 | +| COMP | **LA2A DSPL** | LA-2A | +| AMP | **OR35 DSPL** | Orange Crush 35RT | +| AMP | **JC120 DSPL** | Roland JC-120 | +| AMP | **AC15 DSPL** | Vox AC15 | +| DRIVE | **EPB DSPL** | Xotic EP Booster | + +V 04.2.2 reportedly linked all twelve with independently selectable model types, without overwriting the old variants. A compact device label can omit spaces or punctuation if required by screen width, but the editor and container manifest should retain the complete source device identity. + +**Important model-specific contracts:** The JC-120 V.04 DSP has a mono bridge on BlackBox; that is not the same perceptual output as its stereo chorus. The LPB-1 V.04 nonlinear kernel and high-resolution lookup tables were retained, but its original standalone 8× FIR wrapper was replaced by the existing BlackBox 4× processing path: 8× versus 4× aliasing/fidelity is still open. Vox AC15 reportedly retains its internal 8× processing. These are disclosed adaptations, not claims of exact sonic equivalence. + +### 2.2 OP inventory + +The V 04.2.2 integration report described **96 identified OpenPocket stock model labels** updated to carry **OP**. That reported count is not a newly verified model inventory. The definitive list and type IDs must be generated from the *exact current firmware model registry*, not hardcoded from this handoff. + +The OP container collects the OpenPocket DSP/stock-model implementation and needed common-engine/NAM/IR dependencies. Source packaging alone does not imply an OP-only binary can link without other common firmware services. + +### 2.3 OLD inventory + +Nine historical BluesBox custom model labels were reported: + +| Old model label | Historical identity | +|---|---| +| **LA2A OLD** | Earlier LA-2A Plus | +| **OPTO T4 OLD** | Earlier opto T4 | +| **TS808 OLD1** | Earlier Tube Screamer variant 1 | +| **TS808 OLD2** | Earlier Tube Screamer variant 2 | +| **TS9 OLD** | Earlier TS9/output-stage design | +| **DSTYLE OLD** | Earlier D-style drive | +| **808 OLD** | Earlier 808 circuit model | +| **BOOST OLD** | Earlier clean boost | +| **TS808 JP OLD** | Earlier TS808 Japan | + +The user's future intention is to remove OLD algorithms **gradually**, not to delete them now. Saved preset IDs and comparison baselines must remain recoverable. A removal requires an explicit migration decision, reference hash, regression and rollback, and clear handling of presets referring to unavailable IDs. + +--- + +## 3. Reported V 04.2.2 implementation + +### 3.1 Source container and consolidated ZIP checkpoints + +The following artifacts were previously delivered and linked in the Guitar project: + +- **BluesBox_DSPL_Container_V 04.2.2.zip** +- **BluesBox_OP_Container_V 04.2.2.zip** +- **BluesBox_OLD_Container_V 04.2.2.zip** +- **BluesBox_V 04.2.2_BlackBox978_Containers_Telemetry_LAB.zip** +- **BlackBox_978.fwsc** (baked firmware image inside the experimental release) + +The consolidated release was described as containing the three source containers, integrated firmware, Mac Codex-based installer/telemetry, Edge web editor, model-family probe, test evidence and provenance. Individual model ZIPs from the preceding V.04 integrations remain separate historical checkpoints. + +**Reported validation:** native pi32v2 link, firmware-format integrity, simulated 976/977→978 application update/rollback, host execution, browser-editor and telemetry-tool tests. A host matrix reported **1,692 model scenarios**, **20,304 audio blocks**, **zero non-finite / DSP contract failures**, and **157 scenarios with internal above-full-scale output**. These host results do **not** certify physical-device CPU load, sound fidelity or fault-free operation. + +### 3.2 Architectural level actually reached + +The practical system is a **source-level modular build**, where the common firmware registers optional container-specific implementations under fixed type IDs. Multiple families appear in the same model catalog and firmware image. + +That allows a guitarist to choose, for instance, an OP, OLD or DSPL drive in a single DRIVE block while preserving their distinct IDs and parameter contracts. + +The engine generally selects **one implementation per effect block**, rather than running every available amp/drive simultaneously. Multiple family containers being compiled into an image does not mean their processors all run at once. + +**Implemented or reported:** +- Three distinct source-container checkpoint ZIPs. +- Co-resident DSPL/OP/OLD model identities in BlackBox_978. +- On-device origin labels. +- Existing processor/engine integration contracts, editor catalog and saved model selection. +- V 04.2.2 local-editor block-order controls and family-based model telemetry. + +**Not yet verified/implemented:** +- Dynamic on-device binary plug-in loading/unloading. +- A generic binary DSP container ABI or on-device linker. +- Independent OP-only/OLD-only/DSPL-only hardware firmware build profiles. +- Dynamic state-memory overlay and per-container resource unloading. +- Whole-firmware BlackBox emulation or target CPU-load certification. +- Apple universal/macOS/iOS application executing the exact V 04.2.2 source. +- Persistent gain-reduction meter integration in actual BlackBox_978 UI/settings. + +--- + +## 4. Required stable container interface (agreed direction, not all delivered) + +### 4.1 Invariants + +1. **Explicit, unconditional persisted model IDs.** Compile-time feature flags affect *availability*, never the numeric ID embedded in a saved preset. No two containers may claim the same block/type identity. +2. **Stable preset and storage ABI.** Preserve the 52-slot bank, the currently reported **118-byte preset structure**, model selection, 12 DSP blocks and reserved storage layout. Confirm exact ABI definitions against the current source rather than a remembered header. +3. **No silent substitution.** If a saved preset references a model absent from a selected container profile, expose an unavailable-model condition and a recorded fault or safe fallback policy; never reinterpret that numeric ID as a different effect. +4. **Separate the registry from implementations.** A central model-descriptor registry drives firmware, editor, host tests and package manifests. +5. **No unmeasured tone changes.** Replacing 8× with 4× oversampling, downmixing stereo, moving processing out of the audio callback, or changing output trims requires independent audible/fidelity evidence. Keep original source and reference results immutable. +6. **Explicit lifecycle and state.** Init/reset, tail persistence, preset switching, model changes and scratch reuse must not leave stale state or overlap work across cores. +7. **Portability without false certification.** Source-compatible host/firmware modules still require native-target validation and per-platform clock/audio I/O tests. + +### 4.2 Proposed per-model descriptor fields + +Each DSP model/container should eventually publish a machine-readable descriptor and canonical header defining: + +- Family and immutable ID; parent effect block; full descriptive and compact display names. +- Source/design version; SHA-256; capture/model provenance, rights and license. +- Parameter schema, legal ranges, gain law and reported default output alignment. +- Sample-rate / block / mono-stereo contract; oversampling design and exact latency. +- State-memory, workspace, scratch, RAM/ROM requirements and preallocation guarantees. +- Init/reset/control-update/process function entry points and explicit failure policy. +- Model-specific diagnostics: process count, init/process failures, nonfinite/clipped values, peak target cycles where available. +- Exact dependency versions and external NAM/IR/cab assets. +- Host vectors, DI/reference tests, fidelity findings, CPU/stack observations, limitations. + +**Status:** This uniform descriptor/registry contract is an agreed **next engineering step**, not proof that the three V 04.2.2 ZIPs already implement every field or hook. Any future on-device dynamic loader must first have an independently versioned binary ABI and memory-safety/latency contract. + +### 4.3 Proposed build profiles + +| Profile | Containers selected | Intent | Evidence status | +|---|---|---|---| +| **FULL_LAB** | DSPL + OP + OLD | Comparison on one pedal | Reported as BlackBox_978 | +| **DSPL_ONLY** | DSPL + required common engine | Evaluate next-generation models and reclaim resources | Proposed, not separately native/device-tested | +| **OP_ONLY** | OP + required common engine | Stock benchmark | Proposed, not separately device-tested | +| **OLD_ONLY** | OLD + required common engine | Historical regression | Proposed, not separately device-tested | +| **DUAL_COMPARE** | Any chosen pair | Compare while reducing inactive families | Proposed, not separately device-tested | + +The requested “parallel container” design therefore has **two distinct meanings**: (a) several families present **in one linked firmware**, currently reported; (b) independently selectable family combinations **at build time**, an intended extension. Runtime binary hot-loading remains separate future work. + +--- + +## 5. CPU, memory and diagnostics + +Source modularity by itself does not reduce real CPU use. The firmware still must reserve code and DSP state and service real-time callbacks. Real budgets include RAMTEXT, DSP POOL, ordinary RAM, XIP/flash, stacks, NAM/IR streaming, CPU0/CPU1 deadlines and USB/BLE activity. + +**Prior problem:** The host test could prove the model renders finite audio and links, yet the physical pedal could bypass, buzz or freeze when a new model was enabled. + +**Revised testing requirements:** +- Host DSP matrices at quiet, nominal and hard input levels with raw (pre-limiter) and separately audition-matched outputs. +- Gain law, H2/H3, IMD/aliasing, low-level response (including −60 dBFS), attacks, sustain, tail and control transitions. +- Per-model isolated processor test plus worst permitted multi-FX chain. +- Two independent measurements: **host execution time** and **estimated target pi32v2 cycles**, with CPU0 and CPU1 separate. +- Physical-device telemetry to calibrate emulator cycles, identify missed deadlines, safe bypass and failed allocations. +- An offline unrestricted render path that continues computing audio even when a hypothetical target load is >100%, while separately flagging target deadline violations. Do not treat Mac CPU percent as pedal CPU percent. +- Explicit fault counters for init, not-ready, processing, invalid samples, deadline and effect block/model identity. + +**Open real-device regressions, based on the user's observations:** +- **LA2A DSPL:** buzzing / fault when engaged. +- **TS808 DSPL, TS9 DSPL, EPB DSPL:** protective bypass. +- **LPB1 DSPL:** pedal freeze. +- **TS9 OLD:** protective bypass. +- **TS9 DSPL** and other drive recalls: excessive output/gain staging. +- **DUMBLE DSPL:** user audition indicated unexpectedly strong distortion at modest settings, despite comparatively workable execution. +- **AMB DSPL:** history of bypass; coefficient caching was implemented earlier but its physical correction was not proven across load combinations. +- Heavy AMP/CAB/AMB chains and cores: real-time deadlines not fully certified. + +These are **not** closed by prior host PASS or firmware-link PASS. They belong in a persistent regression register and are ideal targets for the new container-specific test matrix. + +--- + +## 6. Web editor, default routing and gain-reduction UI + +The model catalog in the browser editor and on-device UI must be sourced from the same current registry, preserving model IDs, names and family labels. The V 04.2.2 work reportedly added up/down controls for effect order. + +**Agreed default relationship:** compressor **after CAB and before AMB**. A user's saved preset maintains its own stored order until explicitly edited and saved. Catalog selection and changing an effect type must not secretly reorder other blocks. + +The editor should provide level, per-block on/off, model/parameter controls, preset export, model-family filters, and optional per-model telemetry. It must distinguish unsaved audition from persistent flash writes. + +The requested **gain-reduction meter**, using former Bluetooth status display space and Settings on/off control, remains a **separate incomplete source integration**. A portable no-logarithm, UI-rate GR conversion helper and test were added later to an older public-repository LAB branch. That helper has not yet been wired into the actual BlackBox_978 compressor, global settings storage or LCD; no new firmware should be claimed solely on that basis. + +--- + +## 7. ZIP packaging and independent revision control + +The requested **consolidated firmware checkpoint** should contain: + +1. The exact new **flashable firmware image**, native ELF/map and source/build provenance. +2. **Current DSPL, OP, OLD source-container ZIPs**, not just labels or links to missing files. +3. Every processor's adapter/header, test vectors, captured asset or dependency manifest, license, SHA-256 and known-failure status. +4. A current shared model-ID registry, feature/build-profile manifest, preset layout and compatibility tests. +5. Working local Edge editor, Codex-derived Mac firmware installer and telemetry/model scanner. +6. Matching DI/WAV evidence, fidelity metrics and target-device/host/emulator test reports, labelled by evidence class. +7. **Commands first** in both a readable TXT and MD instruction file; subsequent explanation and recovery steps. +8. Original source and firmware versions, exact backups or immutable references and tested application-region rollback. + +An **individual effect checkpoint** may use the user's requested pattern, e.g. **1960 Fender Tweed Deluxe 5E3 BB V.04.zip**, and holds that effect's source and integration evidence. Unless explicitly packaged otherwise, it is *not* a standalone flashable firmware image. + +Maintain **separate version tracks** for methodology, firmware, each container, experimental models, tools, presets and reference captures. The user controls higher-order version changes; discussion/document edits do not silently increment the build number. For new named deliverables follow the project's **ProjectName_V 04.2.2_ArtifactRole.ext** convention, retaining the space after **V**. Preserve historical originals and hashes. + +**Installation preference:** reuse the proven Codex ROM transport. Avoid gratuitous stop-gates; retain exact baseline checks, automatic full-flash backup/verification, bounded application-window writes and reliable restore. Do not silently write boot, user presets, NAM or IR regions. + +--- + +## 8. Current status, next gates and qualification + +| Requested feature / commitment | Status as of this handoff | +|---|---| +| DSPL / OP / OLD family separation | **Reported implemented as three source ZIPs** | +| Family labels visible on model names | **Reported implemented in BlackBox_978** | +| All twelve DSPL V.04 models linked in one firmware | **Reported native-linked and packaged** | +| Old models remain selectable for A/B | **Reported retained; retirement deferred** | +| Three-container firmware packaged | **Reported delivered as V 04.2.2 LAB** | +| Real-time binary plug-in loader on pedal | **Not implemented** | +| Independent single-/dual-family hardware build variants | **Not yet proven** | +| Source/registry ABI consistency under every feature selection | **Required additional verification** | +| Virtual host rendering with all *current* DSPL models | **Not yet reconciled with BlackBox_978 source** | +| Whole BlackBox firmware emulation and accurate target CPU load | **Not implemented; Stage B research/development** | +| Automated target-stem preset fitting | **Deferred, Stage C** | +| Full real-device CPU/fidelity acceptance of new effects | **Open; multiple user-reported failures** | + +**Next implementation gate A:** Reopen and hash the exact delivered V 04.2.2 consolidated firmware plus three container ZIPs; reconcile source, versioned assets and stable model ID registry with the existing public repository. Do not assume the V52 GitHub source replaces the BlackBox_978 source. + +**Next gate B:** Build the integrated DSPL/OP/OLD source in a native/WASM simulator, test uncapped gain and level-dependent fidelity, then establish full target-board emulator support with measured-cycle calibration. The existing Stage A experimental branch adds host profiling and a cycle-budget conversion bridge against the older source; it is **not** yet the BlackBox_978 emulator. + +**Next gate C:** On the actual current firmware source, connect GR metering to pre-makeup attenuation, add persistent toggle, ensure disabled mode executes no meter calculation/log10f, and verify screen compatibility and audio parity before another installation build. + +**Release condition:** A native-link PASS or finite-audio PASS is not a hardware or sonic PASS. Any new firmware must explicitly retain the unresolved overload, freeze, clip and gain-staging issues until evidence closes them. + +--- + +## 9. Authority and limitations + +This file consolidates **the user's design brief, our agreed staged architecture, prior release descriptions and the outstanding issues**. It is a planning/traceability document, not executable firmware and not approval to overwrite the pedal. + +Some V 04.2.2 file inventories and reported test counts derive from the earlier integrated-package handoff. Because those exact ZIP bytes were not independently inspected again for this document, this record must not be used in place of the original archives, manifests, hashes, source-level diff or actual target tests. + +**Document change only: no new firmware version, compilation, device write or model promotion.** diff --git a/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.txt b/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.txt new file mode 100644 index 00000000..26c66fe3 --- /dev/null +++ b/docs/BluesBox_V 04.2.2_FX_Containers_Design_Brief_and_Implementation.txt @@ -0,0 +1,266 @@ +# BluesBox / OpenPocket — FX Containers +## User design brief, agreed architecture and implementation record + +**Record date:** 18 November 2026 +**Document role:** Design and implementation handoff, not a firmware build or new methodology revision +**Reference release:** BluesBox **V 04.2.2** / **BlackBox_978** — experimental +**Families:** **DSPL**, **OP**, **OLD** +**Evidence rule:** “Implemented” below means reported implemented and packaged in the Guitar project discussion. The individual V 04.2.2 container ZIP bytes have **not** been freshly re-extracted or rehashed during this documentation pass. The accessible public BluesBox GitHub branch contains an older V52-era code baseline, not necessarily the integrated BlackBox_978 source. + +--- + +## 1. User design brief — preserved intent + +The user proposed a modular architecture in which guitar-effect algorithms are maintained as portable *DSP containers*, rather than buried in one undifferentiated firmware source tree. The higher-order goals are: + +- **Independent development.** Work on a single device algorithm or container without having to rebuild or rewrite unrelated devices; preserve prior successful models, source, measurements and archived results. +- **Parallel comparison.** Several containers can be present in one pedal, allowing different interpretations of the same circuit or effect to coexist, be selected and compared with the same guitar DI and levels. +- **Selective deployment.** Make it possible to build a pedal with only a chosen set of containers, so performance and memory tests are not distorted by unused processors. This is an intended build variant, not a claim that live code hot-swapping exists. +- **Transparent naming.** All newly designed models must have capitalised **DSPL** in the on-device name, e.g. **JC120 DSPL**; stock **OpenPocket** models are marked **OP**; earlier in-house algorithms are marked **OLD**. These are provenance/family markers, not fidelity ratings. +- **Self-contained release handoffs.** Every future consolidated firmware ZIP contains the **firmware with selected effects baked in**, plus the **latest separately versioned DSPL, OP and OLD source-container ZIPs**, including effect processors, adapters and associated dependencies/tests/provenance. An individual newly developed effect may also have its own BB V.04 ZIP. +- **Reliable editor and diagnostics.** The local Edge editor must expose the real catalog names and chain order, allow parameter and model changes, distinguish unsaved auditions from committed presets, and work with the real-device telemetry/install tools. +- **Testing and portability.** The same portable DSP sources should, where feasible, run in host C, WebAssembly, native macOS, and later iOS applications. A target-cycle/firmware emulator should quantify overload even when an unrestricted offline renderer is allowed to keep processing. + +The aim is sonic/behavioural fidelity to named devices. CPU or effect count is never an unmeasured substitute for tone, attack, low-level harmonics, gain staging, sustain and decay. + +**Scope resolution agreed in conversation:** The immediate implementation uses **build-time source containers**. It does **not** create hot-loadable compiled plug-ins, a runtime module loader, an on-device dynamic linker, or a new stable binary plug-in ABI. These remain possible future work, but must not be misrepresented as delivered. + +--- + +## 2. Container families and model identities + +| Family | What it contains | Required label | Primary use | +|---|---|---|---| +| **DSPL** | Newer BluesBox DSP designs and V.04 implementations | Model name plus **DSPL** | Main fidelity-development family | +| **OP** | Stock OpenPocket-origin DSP models | Model name plus **OP** | Baseline, reference and alternatives | +| **OLD** | Previous BluesBox-developed models | Model name plus **OLD**, or a short numbered OLD variant | Comparison and gradual controlled retirement | + +Names are presentation metadata; persisted model type IDs stay fixed regardless of which containers are selected for a build. + +### 2.1 DSPL inventory: twelve reported V.04 integrations + +| Processing role | On-device label | V.04 source identity | +|---|---|---| +| AMP | **5E3 DSPL** | 1960 Fender Tweed Deluxe 5E3 | +| DRIVE | **DUMBLE DSPL** | DumbleDrive | +| Ambience / spatial | **AMB DSPL** | Ambience | +| DRIVE | **LPB1 DSPL** | Electro-Harmonix LPB-1 | +| DRIVE | **TS9 DSPL** | Ibanez TS09 / TS9 | +| DRIVE | **TS808 DSPL** | Ibanez TS808 | +| AMP | **L5C1 DSPL** | L5 Channel 1 | +| COMP | **LA2A DSPL** | LA-2A | +| AMP | **OR35 DSPL** | Orange Crush 35RT | +| AMP | **JC120 DSPL** | Roland JC-120 | +| AMP | **AC15 DSPL** | Vox AC15 | +| DRIVE | **EPB DSPL** | Xotic EP Booster | + +V 04.2.2 reportedly linked all twelve with independently selectable model types, without overwriting the old variants. A compact device label can omit spaces or punctuation if required by screen width, but the editor and container manifest should retain the complete source device identity. + +**Important model-specific contracts:** The JC-120 V.04 DSP has a mono bridge on BlackBox; that is not the same perceptual output as its stereo chorus. The LPB-1 V.04 nonlinear kernel and high-resolution lookup tables were retained, but its original standalone 8× FIR wrapper was replaced by the existing BlackBox 4× processing path: 8× versus 4× aliasing/fidelity is still open. Vox AC15 reportedly retains its internal 8× processing. These are disclosed adaptations, not claims of exact sonic equivalence. + +### 2.2 OP inventory + +The V 04.2.2 integration report described **96 identified OpenPocket stock model labels** updated to carry **OP**. That reported count is not a newly verified model inventory. The definitive list and type IDs must be generated from the *exact current firmware model registry*, not hardcoded from this handoff. + +The OP container collects the OpenPocket DSP/stock-model implementation and needed common-engine/NAM/IR dependencies. Source packaging alone does not imply an OP-only binary can link without other common firmware services. + +### 2.3 OLD inventory + +Nine historical BluesBox custom model labels were reported: + +| Old model label | Historical identity | +|---|---| +| **LA2A OLD** | Earlier LA-2A Plus | +| **OPTO T4 OLD** | Earlier opto T4 | +| **TS808 OLD1** | Earlier Tube Screamer variant 1 | +| **TS808 OLD2** | Earlier Tube Screamer variant 2 | +| **TS9 OLD** | Earlier TS9/output-stage design | +| **DSTYLE OLD** | Earlier D-style drive | +| **808 OLD** | Earlier 808 circuit model | +| **BOOST OLD** | Earlier clean boost | +| **TS808 JP OLD** | Earlier TS808 Japan | + +The user's future intention is to remove OLD algorithms **gradually**, not to delete them now. Saved preset IDs and comparison baselines must remain recoverable. A removal requires an explicit migration decision, reference hash, regression and rollback, and clear handling of presets referring to unavailable IDs. + +--- + +## 3. Reported V 04.2.2 implementation + +### 3.1 Source container and consolidated ZIP checkpoints + +The following artifacts were previously delivered and linked in the Guitar project: + +- **BluesBox_DSPL_Container_V 04.2.2.zip** +- **BluesBox_OP_Container_V 04.2.2.zip** +- **BluesBox_OLD_Container_V 04.2.2.zip** +- **BluesBox_V 04.2.2_BlackBox978_Containers_Telemetry_LAB.zip** +- **BlackBox_978.fwsc** (baked firmware image inside the experimental release) + +The consolidated release was described as containing the three source containers, integrated firmware, Mac Codex-based installer/telemetry, Edge web editor, model-family probe, test evidence and provenance. Individual model ZIPs from the preceding V.04 integrations remain separate historical checkpoints. + +**Reported validation:** native pi32v2 link, firmware-format integrity, simulated 976/977→978 application update/rollback, host execution, browser-editor and telemetry-tool tests. A host matrix reported **1,692 model scenarios**, **20,304 audio blocks**, **zero non-finite / DSP contract failures**, and **157 scenarios with internal above-full-scale output**. These host results do **not** certify physical-device CPU load, sound fidelity or fault-free operation. + +### 3.2 Architectural level actually reached + +The practical system is a **source-level modular build**, where the common firmware registers optional container-specific implementations under fixed type IDs. Multiple families appear in the same model catalog and firmware image. + +That allows a guitarist to choose, for instance, an OP, OLD or DSPL drive in a single DRIVE block while preserving their distinct IDs and parameter contracts. + +The engine generally selects **one implementation per effect block**, rather than running every available amp/drive simultaneously. Multiple family containers being compiled into an image does not mean their processors all run at once. + +**Implemented or reported:** +- Three distinct source-container checkpoint ZIPs. +- Co-resident DSPL/OP/OLD model identities in BlackBox_978. +- On-device origin labels. +- Existing processor/engine integration contracts, editor catalog and saved model selection. +- V 04.2.2 local-editor block-order controls and family-based model telemetry. + +**Not yet verified/implemented:** +- Dynamic on-device binary plug-in loading/unloading. +- A generic binary DSP container ABI or on-device linker. +- Independent OP-only/OLD-only/DSPL-only hardware firmware build profiles. +- Dynamic state-memory overlay and per-container resource unloading. +- Whole-firmware BlackBox emulation or target CPU-load certification. +- Apple universal/macOS/iOS application executing the exact V 04.2.2 source. +- Persistent gain-reduction meter integration in actual BlackBox_978 UI/settings. + +--- + +## 4. Required stable container interface (agreed direction, not all delivered) + +### 4.1 Invariants + +1. **Explicit, unconditional persisted model IDs.** Compile-time feature flags affect *availability*, never the numeric ID embedded in a saved preset. No two containers may claim the same block/type identity. +2. **Stable preset and storage ABI.** Preserve the 52-slot bank, the currently reported **118-byte preset structure**, model selection, 12 DSP blocks and reserved storage layout. Confirm exact ABI definitions against the current source rather than a remembered header. +3. **No silent substitution.** If a saved preset references a model absent from a selected container profile, expose an unavailable-model condition and a recorded fault or safe fallback policy; never reinterpret that numeric ID as a different effect. +4. **Separate the registry from implementations.** A central model-descriptor registry drives firmware, editor, host tests and package manifests. +5. **No unmeasured tone changes.** Replacing 8× with 4× oversampling, downmixing stereo, moving processing out of the audio callback, or changing output trims requires independent audible/fidelity evidence. Keep original source and reference results immutable. +6. **Explicit lifecycle and state.** Init/reset, tail persistence, preset switching, model changes and scratch reuse must not leave stale state or overlap work across cores. +7. **Portability without false certification.** Source-compatible host/firmware modules still require native-target validation and per-platform clock/audio I/O tests. + +### 4.2 Proposed per-model descriptor fields + +Each DSP model/container should eventually publish a machine-readable descriptor and canonical header defining: + +- Family and immutable ID; parent effect block; full descriptive and compact display names. +- Source/design version; SHA-256; capture/model provenance, rights and license. +- Parameter schema, legal ranges, gain law and reported default output alignment. +- Sample-rate / block / mono-stereo contract; oversampling design and exact latency. +- State-memory, workspace, scratch, RAM/ROM requirements and preallocation guarantees. +- Init/reset/control-update/process function entry points and explicit failure policy. +- Model-specific diagnostics: process count, init/process failures, nonfinite/clipped values, peak target cycles where available. +- Exact dependency versions and external NAM/IR/cab assets. +- Host vectors, DI/reference tests, fidelity findings, CPU/stack observations, limitations. + +**Status:** This uniform descriptor/registry contract is an agreed **next engineering step**, not proof that the three V 04.2.2 ZIPs already implement every field or hook. Any future on-device dynamic loader must first have an independently versioned binary ABI and memory-safety/latency contract. + +### 4.3 Proposed build profiles + +| Profile | Containers selected | Intent | Evidence status | +|---|---|---|---| +| **FULL_LAB** | DSPL + OP + OLD | Comparison on one pedal | Reported as BlackBox_978 | +| **DSPL_ONLY** | DSPL + required common engine | Evaluate next-generation models and reclaim resources | Proposed, not separately native/device-tested | +| **OP_ONLY** | OP + required common engine | Stock benchmark | Proposed, not separately device-tested | +| **OLD_ONLY** | OLD + required common engine | Historical regression | Proposed, not separately device-tested | +| **DUAL_COMPARE** | Any chosen pair | Compare while reducing inactive families | Proposed, not separately device-tested | + +The requested “parallel container” design therefore has **two distinct meanings**: (a) several families present **in one linked firmware**, currently reported; (b) independently selectable family combinations **at build time**, an intended extension. Runtime binary hot-loading remains separate future work. + +--- + +## 5. CPU, memory and diagnostics + +Source modularity by itself does not reduce real CPU use. The firmware still must reserve code and DSP state and service real-time callbacks. Real budgets include RAMTEXT, DSP POOL, ordinary RAM, XIP/flash, stacks, NAM/IR streaming, CPU0/CPU1 deadlines and USB/BLE activity. + +**Prior problem:** The host test could prove the model renders finite audio and links, yet the physical pedal could bypass, buzz or freeze when a new model was enabled. + +**Revised testing requirements:** +- Host DSP matrices at quiet, nominal and hard input levels with raw (pre-limiter) and separately audition-matched outputs. +- Gain law, H2/H3, IMD/aliasing, low-level response (including −60 dBFS), attacks, sustain, tail and control transitions. +- Per-model isolated processor test plus worst permitted multi-FX chain. +- Two independent measurements: **host execution time** and **estimated target pi32v2 cycles**, with CPU0 and CPU1 separate. +- Physical-device telemetry to calibrate emulator cycles, identify missed deadlines, safe bypass and failed allocations. +- An offline unrestricted render path that continues computing audio even when a hypothetical target load is >100%, while separately flagging target deadline violations. Do not treat Mac CPU percent as pedal CPU percent. +- Explicit fault counters for init, not-ready, processing, invalid samples, deadline and effect block/model identity. + +**Open real-device regressions, based on the user's observations:** +- **LA2A DSPL:** buzzing / fault when engaged. +- **TS808 DSPL, TS9 DSPL, EPB DSPL:** protective bypass. +- **LPB1 DSPL:** pedal freeze. +- **TS9 OLD:** protective bypass. +- **TS9 DSPL** and other drive recalls: excessive output/gain staging. +- **DUMBLE DSPL:** user audition indicated unexpectedly strong distortion at modest settings, despite comparatively workable execution. +- **AMB DSPL:** history of bypass; coefficient caching was implemented earlier but its physical correction was not proven across load combinations. +- Heavy AMP/CAB/AMB chains and cores: real-time deadlines not fully certified. + +These are **not** closed by prior host PASS or firmware-link PASS. They belong in a persistent regression register and are ideal targets for the new container-specific test matrix. + +--- + +## 6. Web editor, default routing and gain-reduction UI + +The model catalog in the browser editor and on-device UI must be sourced from the same current registry, preserving model IDs, names and family labels. The V 04.2.2 work reportedly added up/down controls for effect order. + +**Agreed default relationship:** compressor **after CAB and before AMB**. A user's saved preset maintains its own stored order until explicitly edited and saved. Catalog selection and changing an effect type must not secretly reorder other blocks. + +The editor should provide level, per-block on/off, model/parameter controls, preset export, model-family filters, and optional per-model telemetry. It must distinguish unsaved audition from persistent flash writes. + +The requested **gain-reduction meter**, using former Bluetooth status display space and Settings on/off control, remains a **separate incomplete source integration**. A portable no-logarithm, UI-rate GR conversion helper and test were added later to an older public-repository LAB branch. That helper has not yet been wired into the actual BlackBox_978 compressor, global settings storage or LCD; no new firmware should be claimed solely on that basis. + +--- + +## 7. ZIP packaging and independent revision control + +The requested **consolidated firmware checkpoint** should contain: + +1. The exact new **flashable firmware image**, native ELF/map and source/build provenance. +2. **Current DSPL, OP, OLD source-container ZIPs**, not just labels or links to missing files. +3. Every processor's adapter/header, test vectors, captured asset or dependency manifest, license, SHA-256 and known-failure status. +4. A current shared model-ID registry, feature/build-profile manifest, preset layout and compatibility tests. +5. Working local Edge editor, Codex-derived Mac firmware installer and telemetry/model scanner. +6. Matching DI/WAV evidence, fidelity metrics and target-device/host/emulator test reports, labelled by evidence class. +7. **Commands first** in both a readable TXT and MD instruction file; subsequent explanation and recovery steps. +8. Original source and firmware versions, exact backups or immutable references and tested application-region rollback. + +An **individual effect checkpoint** may use the user's requested pattern, e.g. **1960 Fender Tweed Deluxe 5E3 BB V.04.zip**, and holds that effect's source and integration evidence. Unless explicitly packaged otherwise, it is *not* a standalone flashable firmware image. + +Maintain **separate version tracks** for methodology, firmware, each container, experimental models, tools, presets and reference captures. The user controls higher-order version changes; discussion/document edits do not silently increment the build number. For new named deliverables follow the project's **ProjectName_V 04.2.2_ArtifactRole.ext** convention, retaining the space after **V**. Preserve historical originals and hashes. + +**Installation preference:** reuse the proven Codex ROM transport. Avoid gratuitous stop-gates; retain exact baseline checks, automatic full-flash backup/verification, bounded application-window writes and reliable restore. Do not silently write boot, user presets, NAM or IR regions. + +--- + +## 8. Current status, next gates and qualification + +| Requested feature / commitment | Status as of this handoff | +|---|---| +| DSPL / OP / OLD family separation | **Reported implemented as three source ZIPs** | +| Family labels visible on model names | **Reported implemented in BlackBox_978** | +| All twelve DSPL V.04 models linked in one firmware | **Reported native-linked and packaged** | +| Old models remain selectable for A/B | **Reported retained; retirement deferred** | +| Three-container firmware packaged | **Reported delivered as V 04.2.2 LAB** | +| Real-time binary plug-in loader on pedal | **Not implemented** | +| Independent single-/dual-family hardware build variants | **Not yet proven** | +| Source/registry ABI consistency under every feature selection | **Required additional verification** | +| Virtual host rendering with all *current* DSPL models | **Not yet reconciled with BlackBox_978 source** | +| Whole BlackBox firmware emulation and accurate target CPU load | **Not implemented; Stage B research/development** | +| Automated target-stem preset fitting | **Deferred, Stage C** | +| Full real-device CPU/fidelity acceptance of new effects | **Open; multiple user-reported failures** | + +**Next implementation gate A:** Reopen and hash the exact delivered V 04.2.2 consolidated firmware plus three container ZIPs; reconcile source, versioned assets and stable model ID registry with the existing public repository. Do not assume the V52 GitHub source replaces the BlackBox_978 source. + +**Next gate B:** Build the integrated DSPL/OP/OLD source in a native/WASM simulator, test uncapped gain and level-dependent fidelity, then establish full target-board emulator support with measured-cycle calibration. The existing Stage A experimental branch adds host profiling and a cycle-budget conversion bridge against the older source; it is **not** yet the BlackBox_978 emulator. + +**Next gate C:** On the actual current firmware source, connect GR metering to pre-makeup attenuation, add persistent toggle, ensure disabled mode executes no meter calculation/log10f, and verify screen compatibility and audio parity before another installation build. + +**Release condition:** A native-link PASS or finite-audio PASS is not a hardware or sonic PASS. Any new firmware must explicitly retain the unresolved overload, freeze, clip and gain-staging issues until evidence closes them. + +--- + +## 9. Authority and limitations + +This file consolidates **the user's design brief, our agreed staged architecture, prior release descriptions and the outstanding issues**. It is a planning/traceability document, not executable firmware and not approval to overwrite the pedal. + +Some V 04.2.2 file inventories and reported test counts derive from the earlier integrated-package handoff. Because those exact ZIP bytes were not independently inspected again for this document, this record must not be used in place of the original archives, manifests, hashes, source-level diff or actual target tests. + +**Document change only: no new firmware version, compilation, device write or model promotion.** diff --git a/docs/VIRTUAL-LAB-STAGE-A-B.md b/docs/VIRTUAL-LAB-STAGE-A-B.md new file mode 100644 index 00000000..921973a1 --- /dev/null +++ b/docs/VIRTUAL-LAB-STAGE-A-B.md @@ -0,0 +1,102 @@ +# BluesBox Virtual Lab — Stage A / Stage B experimental handoff + +**Evidence scope:** This branch is based on the inspected public \`Testing7B/bluesbox\` repository, +\`experiment/blues-lab\`, which describes the V52/OpenPocket-era architecture. It is NOT an automatic +merge of the separately delivered BlackBox_978 / BluesBox V 04.2.2 source archive. That newer archive +must be reconciled and inspected locally before making firmware changes. + +**Firmware release:** none. No flash image was changed. No device was flashed. + +## Run the working-tree host workload profiler + +On a Mac with Node 18+ and the exact source-locked WASM engine in this branch: + +\`\`\`sh +node --test tests/virtual-lab.test.mjs +node tools/lab/dsp-profile.mjs --preset all --seconds 3 --warmup 0.25 --out build/lab/dsp-profile.json +node tools/lab/dsp-profile.mjs --preset 5 --scenarios quiet,nominal,hard --seconds 10 --out build/lab/slot05.json +\`\`\` + +Use \`--input path/to/44k1-mono-16bit.wav\` to process an original DI file instead of synthetic tones. +The WAV path currently accepts 44.1 kHz mono or multichannel 16-bit PCM and reads channel 1. This is +a *model-processing profile*, not a measurement of the AC791N's CPU utilization. + +The command refuses to use a compiled WebAssembly engine when its tracked source SHA-256 no longer +matches. Rebuild it with \`node tools/op.mjs wasm\` after editing DSP code; that requires the repository's +cross-compile environment. Never compare a stale binary with a revised source tree. + +A profile reports per-preset/scenario block timings (p50, p95, p99, p99.9, maximum), finite output, +output sample peaks and any samples at the wrapper's full-scale output limit. The simulator itself +clamps its output; the counter cannot measure pre-clipping internal DSP headroom. +Do not call these times BlackBox CPU percent. + +## Stage B cycle trace contract + +Once the AC791N emulator can boot the actual BlackBox image, emit: + +\`\`\`json +{ + "schema": "bluesbox.target-cycle-trace.v1", + "source_kind": "fm1-emu strict-cycle estimate", + "model": "BlackBox_978", + "blocks": [ + {"cpu0_cycles": 12000, "cpu1_cycles": 2400, "deadline_missed": false, "bypass": false} + ] +} +\`\`\` + +Then use measured device clock/sample rate/block size, not convenient guesses: + +\`\`\`sh +node tools/lab/cycle-budget.mjs --trace trace.json --clock-hz 240000000 --rate 44100 --frames 64 --out build/lab/target-budget.json +\`\`\` + +The clock/sample-rate/frame counts in this example are illustrative until verified against the +**exact** BlackBox build. CPU0/CPU1 utilization must be reported separately, not blindly added. + +**Not implemented yet:** BlackBox-specific board MMIO and codec/DMA integration into fm1-emu; +booting an unchanged BlackBox_978 binary; strict-target cycle trace generation; runtime target +trace correlation with physical 976–978 telemetry. A native host CPU benchmark and a target +cycle-profile converter do not substitute for a whole-firmware emulator. + +## GR meter / settings source integration + +Requested behavior: on-device gain reduction in the area previously assigned to Bluetooth status, +a persisted Settings on/off switch, and no \`log10f\` conversion or meter refresh when OFF. + +**Implemented portable component:** `engine/px_gr_meter.h` converts pre-makeup linear attenuation into integer 0–30 dB at UI rate without logarithms; when OFF, conversion is skipped. The C test verifies 0/6/20/30 dB and 10,000 disabled UI ticks. The component is not yet wired into BlackBox_978's compressor, PLAY display or persistent Settings. Those edits require inspecting the latest firmware source. + +Do **not** patch the historical V52 \`firmware/ui.h\` or \`px_settings.h\` as if it were +BlackBox_978. The newer source added Ambience and DSPL LA-2A, and its actual UI storage/ABI +must be inspected before assigning a settings bit. Safe acceptance tests: + +1. Disable meter, assert no meter-only conversion work is called during audio callback or UI tick. +2. Enable meter, measure attenuation **before makeup gain**; calculate dB on the UI side from + a small LUT or other inexpensive conversion (not \`log10f\`). +3. Toggle meter repeatedly and require byte-identical compressor audio at identical controls. +4. Check settings persistence, 52 preset storage, and exact 118-byte ABI compatibility. +5. Verify text fits the freed display region, does not mask CPU/bypass alarms, and has a + fallback for compressors without a valid GR signal. +6. Build and run on physical JieLi hardware before promoting. + +This is an explicitly **blocked firmware UI edit**, not a fabricated completed revision. + +## Next gates + +- Reconcile BlackBox_978 source ZIP SHA-256 and exact source with this branch. +- Port the identical complete integrated DSP engine to WASM (all DSPL/OP/OLD models), update + the source lock and parity tests. Avoid substituting old V52 models for new models. +- Add source-level non-clamped peak instrumentation and per-block tracing. +- Port \`fm1-emu\` peripherals/USB/audio for BlackBox and run actual firmware. +- Compare emulated CPU cycles against known-good and failing physical presets. +- Implement GR UI and its global on/off setting on the **correct current firmware source**. + +**Qualification:** source-authored and GitHub Actions host tests configured. A GitHub Actions +runner executed the source-locked WASM benchmark and compiled the raw C audio engine successfully against this historical repository +baseline (four tests passed and 156 slot/scenario records, zero non-finite paths, 37 paths +reaching post-limiter full scale). Raw C profile example: factory preset 01 hard fixture generated +peak 1.17835474 before limiter and 134 above-full-scale samples in 25 blocks; its quiet and nominal +fixtures reported no overrange. These are short V52-era synthetic fixtures, not evidence that +the BlackBox_978 integrated DSPL source or firmware was tested. These are V52-era fixtures, not evidence that +the BlackBox_978 integrated DSPL source or firmware was tested. No native JieLi build or actual +BlackBox firmware emulation was performed. This branch is LAB only, with zero hardware claims. diff --git a/engine/px_gr_meter.h b/engine/px_gr_meter.h new file mode 100644 index 00000000..dec974e8 --- /dev/null +++ b/engine/px_gr_meter.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * UI-rate gain reduction display helper for DSPL compressors. + * No log10f, powf, expf, or audio callback work. Must be called by UI tick only. + * Input: actual pre-makeup *linear gain ratio* from compressor, 1.0 means 0 dB GR. + * This is a reusable component; it is NOT wired to the current BlackBox firmware. + */ +#ifndef PX_GR_METER_H +#define PX_GR_METER_H +#include +typedef struct { + uint8_t enabled; /* 0: no calculations and UI blank */ + uint8_t db; /* integer GR 0..30 dB; 30 is >=30 dB */ + uint32_t conversions; /* validation counter; can be omitted in firmware-specific implementation */ +} px_gr_meter_t; + +static inline void px_gr_meter_enable(px_gr_meter_t *m, int on) +{ + m->enabled = on ? 1u : 0u; + if (!m->enabled) m->db = 0u; +} +static inline void px_gr_meter_ui_tick(px_gr_meter_t *m, float attenuation_linear) +{ + if (!m->enabled) return; /* OFF: no conversion work */ + ++m->conversions; + /* Reject non-finite/nonphysical states without corrupting the display. */ + if (!(attenuation_linear >= 0.0f)) { m->db = 0u; return; } + if (attenuation_linear >= 1.0f) { m->db = 0u; return; } + /* Rounded integer dB: thresholds halfway between whole dB values. + * 10^(-0.5/20) = 0.944060876; 10^(-1/20) = 0.891250938. + * 30 iterations at <=10 Hz UI tick, never per audio sample/block. + */ + float threshold = 0.944060876f; + const float ratio_per_db = 0.891250938f; + unsigned db = 0; + while (db < 30u && attenuation_linear < threshold) { + ++db; + threshold *= ratio_per_db; + } + m->db = (uint8_t)db; +} +#endif diff --git a/tests/lab/gr-meter.c b/tests/lab/gr-meter.c new file mode 100644 index 00000000..50ae3034 --- /dev/null +++ b/tests/lab/gr-meter.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Pure C verification of the UI-rate GR conversion. Does not validate DSP wiring. + */ +#include +#include +#include "px_gr_meter.h" + +#define CHECK(c) do { if (!(c)) { fprintf(stderr,"GR meter test failed line %d: %s\n",__LINE__,#c); return 1; } } while (0) +int main(void) +{ + px_gr_meter_t m = {0}; + for (unsigned i=0;i<10000;i++) px_gr_meter_ui_tick(&m, 0.1f); + CHECK(m.enabled == 0u && m.conversions == 0u && m.db == 0u); + px_gr_meter_enable(&m,1); + px_gr_meter_ui_tick(&m,1.0f); + CHECK(m.db == 0u); + px_gr_meter_ui_tick(&m,0.5011872f); + CHECK(m.db == 6u); + px_gr_meter_ui_tick(&m,0.1f); + CHECK(m.db == 20u); + px_gr_meter_ui_tick(&m,0.001f); + CHECK(m.db == 30u); + px_gr_meter_ui_tick(&m,-1.0f); + CHECK(m.db == 0u); + const uint32_t before = m.conversions; + px_gr_meter_enable(&m,0); + CHECK(m.db == 0u); + for (unsigned i=0;i<10000;i++) px_gr_meter_ui_tick(&m,0.01f); + CHECK(m.conversions == before && m.db == 0u); + puts("GR UI-rate conversion: tested OFF fast-path, 0/6/20/30 dB thresholds and invalid input"); + return 0; +} diff --git a/tests/lab/raw-output.c b/tests/lab/raw-output.c new file mode 100644 index 00000000..6e29c628 --- /dev/null +++ b/tests/lab/raw-output.c @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: GPL-3.0-only + * Stage A pre-limiter DSP profiler, using the firmware's own px_engine_process(). + * Unlike the browser output, engine output here is NOT clipped to [-1, 1]. + * Host timings are NOT measured AC791N cycles. + * + * Build (macOS/Linux): + * cc -std=c11 -O2 -fno-builtin -ffp-contract=off -Iengine \ + * tests/lab/raw-output.c engine/px_dsp.c firmware/px_math.c -lm -o build/raw-output + * Run: + * ./build/raw-output 600 > build/raw-output.csv + */ +#define _POSIX_C_SOURCE 200809L +#include +#include +#include +#include +#include +#include "px_dsp.h" + +static px_engine E; /* a single engine; compiler and test harness use same source code */ +static float in[64], out[64]; +static double now_us(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) return -1.0; + return (double)ts.tv_sec * 1000000.0 + (double)ts.tv_nsec * 0.001; +} +static float signal_at(uint64_t n) +{ + const double t = (double)n / 44100.0; + const double impact = (n % 22050u) < 180u ? 1.0 : 0.45; + return (float)(impact * (0.68 * sin(2.0 * 3.14159265358979323846 * 110.0 * t) + + 0.24 * sin(2.0 * 3.14159265358979323846 * 659.0 * t) + + 0.08 * sin(2.0 * 3.14159265358979323846 * 3101.0 * t))); +} +static int compare_double(const void *aa, const void *bb) +{ + const double a = *(const double *)aa, b = *(const double *)bb; + return (a > b) - (a < b); +} +static double percentile(const double *samples, unsigned n, double fraction) +{ + const double k = (n - 1u) * fraction; + const unsigned lo = (unsigned)k, hi = lo + (lo + 1u < n); + return samples[lo] + (samples[hi] - samples[lo]) * (k - (double)lo); +} +int main(int argc, char **argv) +{ + unsigned blocks = 600; + if (argc > 1) { + char *end = NULL; + const unsigned long n = strtoul(argv[1], &end, 10); + if (!end || *end || n < 2u || n > 200000u) { + fprintf(stderr, "blocks must be an integer in [2, 200000]\n"); + return 2; + } + blocks = (unsigned)n; + } + double *times = malloc(sizeof(double) * blocks); + if (!times) return 2; + printf("preset,scenario,blocks,preclip_peak,preclip_rms,above_fullscale_samples,nonfinite_samples,host_p99_us,host_p999_us,host_max_us\n"); + for (int preset = 0; preset < 52; ++preset) { + for (int scenario = 0; scenario < 3; ++scenario) { + const float level = scenario == 0 ? 0.00015f : scenario == 1 ? 0.15f : 0.8f; + const char *name = scenario == 0 ? "quiet" : scenario == 1 ? "nominal" : "hard"; + px_preset_t p; + px_preset_factory(&p, preset); + px_engine_init(&E, 44100.0f); + px_engine_set(&E, &p); + double sum = 0.0, peak = 0.0; + unsigned long long above = 0, nonfinite = 0; + for (unsigned b = 0; b < blocks + 12u; ++b) { + for (unsigned j = 0; j < 64; ++j) { + const uint64_t pos = ((uint64_t)b * 64u) + j; + in[j] = signal_at(pos) * level; + } + const double begin = now_us(); + px_engine_process(&E, in, out, 64); + const double end = now_us(); + if (begin < 0.0 || end < 0.0) return 3; + if (b < 12u) continue; /* transient warm-up, separate from timed/report windows */ + times[b - 12u] = end - begin; + for (unsigned j = 0; j < 64; ++j) { + const double v = out[j], a = fabs(v); + if (!isfinite(v)) { nonfinite++; continue; } + if (a > peak) peak = a; + sum += v * v; + if (a > 1.0) above++; + } + } + qsort(times, blocks, sizeof(*times), compare_double); + printf("%d,%s,%u,%.9g,%.9g,%llu,%llu,%.4f,%.4f,%.4f\n", + preset + 1, name, blocks, peak, + sqrt(sum / (64.0 * (double)blocks)), above, nonfinite, + percentile(times, blocks, 0.99), + percentile(times, blocks, 0.999), + times[blocks - 1u]); + if (nonfinite) { free(times); return 1; } + } + } + free(times); + return 0; +} diff --git a/tests/virtual-lab.test.mjs b/tests/virtual-lab.test.mjs new file mode 100644 index 00000000..abe4ab51 --- /dev/null +++ b/tests/virtual-lab.test.mjs @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-only +// Run: node --test tests/virtual-lab.test.mjs +import test from "node:test"; +import assert from "node:assert/strict"; +import { evaluateCycles } from "../tools/lab/cycle-budget.mjs"; +import { profile } from "../tools/lab/dsp-profile.mjs"; + +const block = (cpu0_cycles, cpu1_cycles, deadline_missed = false, bypass = false) => + ({ cpu0_cycles, cpu1_cycles, deadline_missed, bypass }); +test("target cycle conversion observes independent cores and deadline", () => { + const trace = {schema:"bluesbox.target-cycle-trace.v1", model:"synthetic only", + blocks:[block(240000,0), block(120000,360000,true,true), block(0,0)]}; + const data = evaluateCycles(trace,{clockHz:240000000,sampleRate:48000,blockFrames:64}); + assert.equal(data.cycles_available_per_core_per_block,320000); + assert.equal(data.cpu0.max_cycles,240000); + assert.equal(data.cpu1.max_cycles,360000); + assert.equal(data.core_cycle_budget_exceedance_blocks,1); + assert.equal(data.reported_deadline_misses,1); + assert.equal(data.reported_bypass_blocks,1); +}); +test("cycle converter rejects missing data and invented defaults", () => { + const good = {schema:"bluesbox.target-cycle-trace.v1",blocks:[block(0,0)]}; + assert.throws(()=>evaluateCycles(good,{clockHz:0,sampleRate:44100,blockFrames:64})); + assert.throws(()=>evaluateCycles({...good,blocks:[{cpu0_cycles:100}]},{clockHz:240000000,sampleRate:44100,blockFrames:64})); + assert.throws(()=>evaluateCycles({...good,schema:"bad"},{clockHz:240000000,sampleRate:44100,blockFrames:64})); +}); +test("host benchmark uses actual simulator binary, source lock, and bounded fixtures", () => { + const x=profile({presets:[1],seconds:0.05,warmup:0,scenarios:["quiet","nominal"]}); + assert.equal(x.schema,"bluesbox.host-dsp-profile.v1"); + assert.equal(x.records.length,2); + assert.equal(x.records[0].target_ac791n_load_percent,null); + assert.equal(x.records[0].target_cpu_cycles,null); + assert.ok(x.engine_source_sha256.length===64); + assert.ok(x.engine_wasm_sha256.length===64); + for(const s of x.records){ + assert.ok(s.host_wall_ms.max>=0); + assert.equal(s.nonfinite_samples,0); + assert.ok(s.frames>0); + } +}); +test("out-of-range preset and invalid scenario are rejected",()=>{ + assert.throws(()=>profile({presets:[53],seconds:.01,warmup:0,scenarios:["quiet"]})); + assert.throws(()=>profile({presets:[1],seconds:.01,warmup:0,scenarios:["unknown"]})); +}); diff --git a/tools/lab/cycle-budget.mjs b/tools/lab/cycle-budget.mjs new file mode 100644 index 00000000..f66ec895 --- /dev/null +++ b/tools/lab/cycle-budget.mjs @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-3.0-only +// Stage B: convert target-emulator cycle traces into deadline estimates. +// Explicitly requires measured/emulated pi32v2 cycles; NEVER treats host wall time as target cycles. +// Trace JSON: { "schema":"bluesbox.target-cycle-trace.v1", "model":"...", "blocks":[ +// {"cpu0_cycles":12000,"cpu1_cycles":2400,"deadline_missed":false,"bypass":false}, ... ] } +// Command: node tools/lab/cycle-budget.mjs --trace TRACE.json --clock-hz 240000000 --rate 44100 --frames 64 --out REPORT.json +import { readFileSync, mkdirSync, writeFileSync } from "node:fs"; +import { resolve, dirname } from "node:path"; +function pct(a, q) { + if (!a.length) return null; + const sorted = [...a].sort((x, y) => x - y); + const k = (sorted.length - 1) * q; + const lo = Math.floor(k), hi = Math.ceil(k); + return sorted[lo] + (sorted[hi] - sorted[lo]) * (k - lo); +} +function checkNum(value, name) { + if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw Error("invalid " + name); +} +export function evaluateCycles(trace, { clockHz, sampleRate, blockFrames, traceOrigin = "not-specified" }) { + if (trace.schema !== "bluesbox.target-cycle-trace.v1") throw Error("unknown trace schema"); + if (!Array.isArray(trace.blocks) || !trace.blocks.length) throw Error("cycle trace needs at least one block"); + checkNum(clockHz, "clockHz"); + checkNum(sampleRate, "sampleRate"); + checkNum(blockFrames, "blockFrames"); + if (!(clockHz > 0 && sampleRate > 0 && blockFrames > 0)) throw Error("clock/rate/frames must be positive"); + const available = clockHz * blockFrames / sampleRate; + const c0 = [], c1 = []; + let bypass = 0, missed = 0, predicted = 0; + for (const [index, b] of trace.blocks.entries()) { + checkNum(b.cpu0_cycles, "cpu0_cycles block " + index); + checkNum(b.cpu1_cycles, "cpu1_cycles block " + index); + if (typeof b.deadline_missed !== "boolean" || typeof b.bypass !== "boolean") + throw Error("missing actual deadline/bypass flags in block " + index); + c0.push(b.cpu0_cycles); + c1.push(b.cpu1_cycles); + if (b.deadline_missed) missed++; + if (b.bypass) bypass++; + if (b.cpu0_cycles > available || b.cpu1_cycles > available) predicted++; + } + const serialize = (values) => ({ + max_cycles: values.reduce((max, value) => value > max ? value : max, 0), + p50_cycles: pct(values, 0.5), + p99_cycles: pct(values, 0.99), + p999_cycles: pct(values, 0.999), + max_percent_of_single_core_deadline: 100 * values.reduce((max, value) => value > max ? value : max, 0) / available, + p999_percent_of_single_core_deadline: 100 * pct(values, 0.999) / available, + }); + return { + schema: "bluesbox.cycle-budget-report.v1", + input_origin: traceOrigin, + target: trace.model ?? "AC791N board unknown", + source_trace_kind: trace.source_kind ?? "unspecified; do not treat as measured hardware", + clock_hz: clockHz, sample_rate_hz: sampleRate, block_frames: blockFrames, + cycles_available_per_core_per_block: available, + blocks: trace.blocks.length, + cpu0: serialize(c0), cpu1: serialize(c1), + reported_deadline_misses: missed, reported_bypass_blocks: bypass, + core_cycle_budget_exceedance_blocks: predicted, + note: "Per-core percentages cannot simply be added: CPU0 and CPU1 may overlap. Memory and peripheral contention and scheduling also affect deadlines. Cycle accuracy must be calibrated with real BlackBox telemetry.", + }; +} +function cli(args) { + const out = {}; + for (let i = 0; i < args.length; i++) { + const k = args[i], v = args[++i]; + if (!k?.startsWith("--") || v === undefined) throw Error("expected --name value"); + if (k === "--trace" || k === "--out") out[k.slice(2)] = v; + else if (k === "--clock-hz" || k === "--rate" || k === "--frames") out[k.slice(2)] = Number(v); + else throw Error("unknown argument " + k); + } + if (!out.trace || !out["clock-hz"] || !out.rate || !out.frames) throw Error("required --trace, --clock-hz, --rate, --frames"); + return out; +} +if (process.argv[1] && process.argv[1].endsWith("cycle-budget.mjs")) { + try { + const args = cli(process.argv.slice(2)); + const filename = resolve(args.trace); + const trace = JSON.parse(readFileSync(filename, "utf8")); + const report = evaluateCycles(trace, { + clockHz: args["clock-hz"], sampleRate: args.rate, blockFrames: args.frames, traceOrigin: filename, + }); + const dest = resolve(args.out ?? "build/lab/cycle-budget.json"); + mkdirSync(dirname(dest), { recursive: true }); + writeFileSync(dest, JSON.stringify(report, null, 2) + "\n"); + console.log(dest); + } catch (error) { + console.error(error.message); + process.exitCode = 1; + } +} diff --git a/tools/lab/dsp-profile.mjs b/tools/lab/dsp-profile.mjs new file mode 100644 index 00000000..3c1c8a09 --- /dev/null +++ b/tools/lab/dsp-profile.mjs @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-3.0-only +// BluesBox Virtual Lab Stage A: reproducible host DSP profiling, NOT AC791N CPU emulation. +// From the existing OpenPocket simulator engine (same DSP C compiled to WebAssembly). +// Usage: node tools/lab/dsp-profile.mjs --preset all --seconds 3 --out build/lab/dsp-profile.json +// node tools/lab/dsp-profile.mjs --preset 5 --input assets/loops/FILE.wav --seconds 10 +import { performance } from "node:perf_hooks"; +import { createHash } from "node:crypto"; +import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { BLOCK, ENGINE_RATE, PxEngine } from "../sim/px-engine.js"; +import { readWav } from "../sim/render.mjs"; + +const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", ".."); +const SRCS = [ + "engine/px_wasm.c", "engine/px_dsp.c", "firmware/px_math.c", "engine/px_dsp.h", + "engine/px_trim.h", "engine/px_nam.c", "engine/px_nam.h", "engine/px_nam_factory.h", +]; +const MODES = { quiet: 0.00015, nominal: 0.15, hard: 0.8 }; +const frameMs = BLOCK * 1000 / ENGINE_RATE; + +function currentSourceHash() { + const hash = createHash("sha256"); + for (const p of SRCS) hash.update(readFileSync(join(ROOT, p))); + return hash.digest("hex"); +} +function engineFile() { + const wasm = join(ROOT, "tools/sim/px_engine.wasm"); + const record = wasm + ".sources"; + if (!existsSync(wasm) || !existsSync(record)) + throw new Error("No simulator WASM/source lock. Build with: node tools/op.mjs wasm"); + const actual = currentSourceHash(); + const expected = readFileSync(record, "utf8").trim(); + if (actual !== expected) throw new Error( + "Simulator WASM is stale relative to engine source; run node tools/op.mjs wasm. " + + "This safeguard prevents profiling an older effect implementation." + ); + return { wasm, sourceHash: actual }; +} +function syntheticSample(n) { + const t = n / ENGINE_RATE; + // Deterministic multitone + sharp periodic attack; no random state. + const attack = (n % (ENGINE_RATE >> 1)) < 180 ? 1.0 : 0.45; + return attack * (0.68 * Math.sin(2 * Math.PI * 110 * t) + + 0.24 * Math.sin(2 * Math.PI * 659 * t) + + 0.08 * Math.sin(2 * Math.PI * 3101 * t)); +} +function percentile(sorted, fraction) { + if (!sorted.length) return 0; + const at = (sorted.length - 1) * fraction, lo = Math.floor(at), hi = Math.ceil(at); + return sorted[lo] + (sorted[hi] - sorted[lo]) * (at - lo); +} +function db(value) { return value > 0 ? 20 * Math.log10(value) : null; } +function selectInput(path) { + if (!path) return { label: "deterministic multitone+attacks", samples: null }; + const wav = readWav(readFileSync(resolve(path))); + if (wav.rate !== ENGINE_RATE) throw new Error("DI must be 44100 Hz; received " + wav.rate); + if (!wav.samples.length) throw new Error("DI file contains no audio"); + return { label: "WAV " + resolve(path), samples: wav.samples }; +} + +export function profile(options = {}) { + const seconds = options.seconds ?? 3; + const warmup = options.warmup ?? 0.25; + const presets = options.presets ?? Array.from({ length: 52 }, (_, i) => i + 1); + const scenarios = options.scenarios ?? Object.keys(MODES); + if (!(seconds > 0 && seconds <= 3600) || !(warmup >= 0 && warmup <= 60)) + throw new Error("seconds must be 0..3600; warmup must be 0..60"); + for (const slot of presets) if (!Number.isInteger(slot) || slot < 1 || slot > 52) + throw new Error("preset slot must be 1..52"); + for (const scenario of scenarios) if (!Object.hasOwn(MODES, scenario)) + throw new Error("scenario must be quiet, nominal, or hard"); + + const { wasm, sourceHash } = engineFile(); + const module = new WebAssembly.Module(readFileSync(wasm)); + const { label, samples } = selectInput(options.input); + const warmBlocks = Math.ceil(warmup * ENGINE_RATE / BLOCK); + const blocks = Math.ceil(seconds * ENGINE_RATE / BLOCK); + const records = []; + for (const slot of presets) for (const scenario of scenarios) { + // A fresh instance per slot/scenario: no stale internal DSP state shared between tests. + const engine = new PxEngine(module); + engine.factory(slot - 1); + engine.volume(100); + const times = []; + const gain = MODES[scenario]; + let nonfinite = 0, limitedSamples = 0, peak = 0, sumsq = 0; + let inPeak = 0, inputSumsq = 0; + for (let b = -warmBlocks; b < blocks; b++) { + const origin = (b + warmBlocks) * BLOCK; + for (let j = 0; j < BLOCK; j++) { + const position = origin + j; + const v = (samples ? samples[position % samples.length] : syntheticSample(position)) * gain; + engine.input[j] = v; + } + const before = performance.now(); + engine.process(); + const elapsed = performance.now() - before; + if (b < 0) continue; + times.push(elapsed); + for (let j = 0; j < BLOCK; j++) { + const y = engine.output[j], x = engine.input[j]; + inPeak = Math.max(inPeak, Math.abs(x)); + inputSumsq += x * x; + if (!Number.isFinite(y)) { nonfinite++; continue; } + peak = Math.max(peak, Math.abs(y)); + sumsq += y * y; + if (Math.abs(y) >= 0.999999) limitedSamples++; + } + } + times.sort((a, b) => a - b); + const count = blocks * BLOCK; + const p999 = percentile(times, 0.999); + records.push({ + slot, scenario, input_gain: gain, + blocks, frames: count, + input_peak_dbfs: db(inPeak), + input_rms_dbfs: db(Math.sqrt(inputSumsq / count)), + output_peak_dbfs: db(peak), + output_rms_dbfs: db(Math.sqrt(sumsq / count)), + nonfinite_samples: nonfinite, + at_or_near_fullscale_samples: limitedSamples, + host_wall_ms: { + p50: percentile(times, 0.50), p95: percentile(times, 0.95), + p99: percentile(times, 0.99), p999, max: times.at(-1), + }, + host_realtime_budget_ms: frameMs, + host_p999_load_percent: p999 * 100 / frameMs, + // NOT the physical AC791N load. A 300% virtual estimate needs a calibrated target-cycle model. + target_ac791n_load_percent: null, + target_cpu_cycles: null, + firmware_emulation: false, + }); + } + return { + schema: "bluesbox.host-dsp-profile.v1", + evidence: "WASM DSP execution on host, no board/firmware emulation", + engine_source_sha256: sourceHash, + engine_wasm_sha256: createHash("sha256").update(readFileSync(wasm)).digest("hex"), + sample_rate_hz: ENGINE_RATE, + block_frames: BLOCK, + input: label, + host: { platform: process.platform, arch: process.arch, node: process.version }, + warning: "Host p999 timings depend on machine/JIT/OS load; they do not predict AC791N deadline use.", + output_limitation: "Audio wrapper clips the output to [-1,1]. At-or-near-fullscale counts are not proof of internal clipping; a pre-limiter engine probe is needed for that.", + records, + }; +} +function argumentsFromCLI(args) { + const o = {}; + for (let i = 0; i < args.length; i++) { + const flag = args[i], value = args[++i]; + if (!flag.startsWith("--") || value === undefined) throw new Error("option requires a value: " + flag); + if (flag === "--preset") o.presets = value === "all" ? undefined : [Number(value)]; + else if (flag === "--seconds") o.seconds = Number(value); + else if (flag === "--warmup") o.warmup = Number(value); + else if (flag === "--input") o.input = value; + else if (flag === "--scenarios") o.scenarios = value.split(",").map(s => s.trim()); + else if (flag === "--out") o.out = value; + else throw new Error("unknown option " + flag); + } + return o; +} +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + try { + const { out, ...options } = argumentsFromCLI(process.argv.slice(2)); + const result = profile(options); + const dest = resolve(out ?? "build/lab/dsp-profile.json"); + mkdirSync(dirname(dest), { recursive: true }); + writeFileSync(dest, JSON.stringify(result, null, 2) + "\n"); + const bad = result.records.filter(r => r.nonfinite_samples); + const clips = result.records.filter(r => r.at_or_near_fullscale_samples); + console.log("Wrote " + dest + " (" + result.records.length + " tested slot/scenario combinations)"); + console.log("Non-finite paths: " + bad.length + "; paths reaching full-scale: " + clips.length); + console.log("These are host timings, NOT measured AC791N CPU load."); + if (bad.length) process.exitCode = 1; + } catch (error) { + console.error("Virtual Lab profile failed: " + error.message); + process.exitCode = 1; + } +} diff --git a/tools/lab/profile.html b/tools/lab/profile.html new file mode 100644 index 00000000..616e4bab --- /dev/null +++ b/tools/lab/profile.html @@ -0,0 +1,51 @@ + +BluesBox Virtual Lab — DSP Host Profiler +

BluesBox Virtual Lab

+

Host DSP workload explorer. Results are computed by the source-locked WebAssembly engine on a desktop. They are not estimated AC791N CPU utilization.

+
+ + +

Select a profile. This page runs entirely offline.

+
+ +
SlotScenarioHost p99.9 msHost p99.9 %Output peak dBFSAt full scaleNon-finite
+

Evidence boundaries

The output is clamped to full scale, so the full-scale counter cannot measure internal pre-clipping headroom. Target cycle budgets require firmware emulation on a BlackBox-compatible board model and calibration against physical pedal telemetry. The reported host percentages must never be used as device-certification evidence.

+ \ No newline at end of file