From ab5411fcee82d26cd8eeee1d2761f717d315269d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:09:30 +0700 Subject: [PATCH 01/23] docs: establish ArSonEQ PRD, ARD, migration audit and staged roadmap --- README.md | 30 ++++++++++++++++++ docs/ARD.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++ docs/MIGRATION.md | 29 +++++++++++++++++ docs/PRD.md | 73 ++++++++++++++++++++++++++++++++++++++++++ docs/ROADMAP.md | 22 +++++++++++++ 5 files changed, 235 insertions(+) create mode 100644 README.md create mode 100644 docs/ARD.md create mode 100644 docs/MIGRATION.md create mode 100644 docs/PRD.md create mode 100644 docs/ROADMAP.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..60e8c89 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# ArSonEQ + +ArSonEQ is an original, open-source, professional parametric equalizer plug-in project. The goal is a fast, transparent, refined workflow comparable in capability to leading commercial EQs, **not** a clone of another product's source code, branding, or artwork. + +**Status: M0 foundation, under active development. Not yet a release-quality replacement for Pro-Q 3.** + +## Source and architecture + +The initial reference is [MaSonKuPik](https://github.com/masarray/masonkupik), another project owned by the maintainer. Its Web Audio/TypeScript EQ interaction model and Butterworth filter settings inform ArSonEQ, but the browser graph is **not** a native VST engine. Native DSP is independently implemented in portable C++17, and JUCE 9 supplies the plug-in wrapper and UI. No compressor, limiter, exciter, or web runtime is bundled into the EQ. + +- [Product requirements](docs/PRD.md) +- [Architecture and real-time design](docs/ARD.md) +- [Migration audit and provenance](docs/MIGRATION.md) +- [Implementation milestones and acceptance gates](docs/ROADMAP.md) + +## Build direction + +- Initial target: Windows x64 VST3; macOS VST3/AU subsequently. +- CMake 3.24+, C++17, JUCE **9.0.4 pinned** (no floating HEAD). An installed local JUCE checkout can be selected with `JUCE_SOURCE_DIR`. +- Headless C++ DSP tests build without downloading JUCE. +- Configure: `cmake -S . -B build -DARSONEQ_BUILD_PLUGIN=OFF -DARSONEQ_BUILD_TESTS=ON` +- Test: `cmake --build build --config Release && ctest --test-dir build --output-on-failure -C Release` +- Plug-in: `cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=ON`; then `cmake --build build-vst --config Release`. +- If no local JUCE source is supplied, the plug-in configuration fetches pinned JUCE from GitHub. A connection is necessary only at configure time, not when running the plug-in. + +## License and dependencies + +This repository already uses **AGPL-3.0** (see LICENSE). JUCE 9 modules are offered under AGPLv3 or separate commercial terms. This project uses the AGPL path for the open-source edition. **A commercial JUCE licence may be required** for a future proprietary/closed-source edition. Steinberg VST 3 SDK 3.8+ is MIT-licensed; trademark requirements are separate. Verify all third-party dependencies and source provenance before redistribution. + +FabFilter and Pro-Q are trademarks of their respective owner, which is not affiliated with ArSonEQ. There is no FabFilter intellectual property or GUI artwork in this repository. diff --git a/docs/ARD.md b/docs/ARD.md new file mode 100644 index 0000000..976f9e4 --- /dev/null +++ b/docs/ARD.md @@ -0,0 +1,81 @@ +# ARD — ArSonEQ Architecture & Design Rules + +Version 0.1 · 2026-10-29 · Status: approved direction, implementation evolving + +## Design decisions + +**A1 — Native engine, not Web Audio:** Reimplement an independent C++17 DSP core with deterministic biquad coefficients. MaSonKuPik is a functional/UX reference, not a source tree to copy indiscriminately. + +**A2 — JUCE 9.0.4 for VST3 and native editor:** Use JUCE only for plug-in host integration, parameters, state and rendering. DSP owns no JUCE types. Pin external dependency version. The repo and the JUCE AGPL distribution path are compatible; commercial distribution requires a separate licence decision. + +**A3 — 24 fixed band slots, no dynamic audio allocations:** Each slot has type, frequency, gain, Q, cut slope, channel mode and enabled state. Keep parameter IDs stable even after a slot is removed in UI. Fixed max 4 stages for P0 cut filters. + +**A4 — Hard isolation of audio and UI:** Audio callback does no malloc/free, locks, network IO, console IO, GPU interaction, or file access. Parameter snapshots are read as atomics, and coefficients update only on changed values. UI can cache graph responses and throttle analyzer repainting independently. + +**A5 — Stereo M/S routing:** For each band transform L/R to M=(L+R)/2, S=(L-R)/2 only if that band's placement needs M/S; apply independent filter state to the selected route; reconstruct L=M+S, R=M-S. Never apply per-band M/S as a global widening effect. Mono input uses mono processing and disables meaningless Left/Right/Side routes as necessary. + +**A6 — Separate transfer functions from UI graphs:** Expose analytical magnitude response from the exact DSP coefficient generator. UI graph must use actual sample rate and its current processing mode, not a fabricated 48kHz Web Audio offline context. + +**A7 — Explicit progression of phase modes:** P0 direct causal minimum-phase biquad, zero algorithmic delay. P2 separate measured natural-phase alternative and latency-accounted linear-phase FIR. Do not claim a direct analog-copy of FabFilter algorithms. + +## Architecture + +```text +DAW host + ├── VST3 wrapper (JUCE): buses, latency, automation, state, host lifetime + ├── ParameterAdapter: stable IDs, normalized ranges, bounded snapshots + ├── AudioProcessor (real-time): input → 24 fixed-band EQ → output + │ ├── biquad coefficient generator (RBJ topology + Butterworth stages) + │ ├── per-band L/R/M/S state, sanitized numerical limits + │ └── smoothing / topology transition policy + └── Editor (message thread): graph, nodes, inspector, cached response + └── optional RT-safe metering/FFT telemetry queue (future) +``` + +Portable DSP must be independently tested with a simple C++ test harness. It must not include Web Audio, JUCE, UI, JSON, or licensing code. + +## Signal flow / control + +1. Host writes normalized parameter values into APVTS atomics. On each block, processor reads a coherent-enough bounded snapshot per slot; each changed slot updates its target coefficients. A later revision may use immutable whole-bank snapshots for simultaneous multi-parameter changes. +2. Each sample flows through enabled slots in stable numerical order, with independent state for L/R or M/S. All stereo transforms are per slot; no summing of nonidentical latency paths. +3. Gain in dB converts to amplitude; cut filters are Butterworth cascades using the MaSonKuPik Q-stage array: 12 [0.70710678], 24 [0.5411961,1.30656296], 36 [0.51763809,0.70710678,1.93185165], 48 [0.50979558,0.60134489,0.89997622,2.56291545]. +4. For bell/shelf/notch calculate normalized biquad from RBJ Audio EQ Cookbook. Frequency/Q are bounded; every intermediate is finite; target coefficients computed at configuration changes, **never per sample**. +5. Retune uses interpolation or a fully verified dual-pipeline crossfade to avoid zippering and instability. Shape/slope change needs separate discontinuity tests. A simple block-step rebuild is **not** a release-quality solution. +6. Bypass is unity and preserves host state; transitions require crossfade/ramps, and full bypass must neither alter latency nor create clicks. +7. On sample-rate changes, update all coefficients and reset/transition filter state predictably; on silence avoid denormal stalls. + +## Parameter contract + +For slot N, IDs are immutable `bNN_enabled`, `bNN_type`, `bNN_freq`, `bNN_gain`, `bNN_q`, `bNN_slope`, `bNN_route`. Type order: Bell, LowShelf, HighShelf, LowCut, HighCut, Notch. Route: Stereo, Left, Right, Mid, Side. Slope: 12,24,36,48. Safe defaults: disabled, bell, 1000 Hz, 0 dB, Q=1, slope=12, Stereo. Numbering and enum order are persistence APIs; do not reorder. + +Band ranges: 20 Hz–20 kHz (clamp to 45% SR), -24 to +24 dB, Q 0.1–24; visual options may expose more restricted zoom. Actual cutoff and response are sample-rate limited. + +Schema migration: a versioned host state tree will preserve current slot identity when changing GUI, FFT or dynamic features. Any later incompatible addition must be additive or migratable, never rename existing host parameter IDs. + +## Lifecycle and threading + +- Construction: allocate fixed states once. Prepare: set sample rate, initialize states. Process: no allocation and no throwing. +- UI: repaints only on observed change; optional analyzer target 20–30 FPS. No unbounded `repaint()` loop or heavyweight effects; when editor closes, analysis stops. +- For P1 FFT, use preallocated SPSC sample/tap queue and worker/UI drain; drop visual frames rather than block the audio callback. Ensure lock-free queue semantics and ownership with tests. +- Offline render and host-initiated parameter automation must use the same DSP equations; no dependence on frame rate or wall clock. + +## Precision and verification + +For reference response test: compare analytical `H(e^{jw})` with measured sine sweep at 44.1/48/96/192 kHz and check normalized Biquad stability; verify 24 stages × two channels with random input finite. Test M/S symmetry, mono, disabled-band unity, impulse tail, repeatability, gain at band center, coefficient edge cases, and rapid-automation stress. Track max absolute error by mode. + +Before shipping: run Steinberg validator, JUCE pluginval, REAPER, and a second DAW; run Windows Defender scan on artifacts. Include licenses in binary distribution. + +## Design risk register + +| Risk | Mitigation | +|---|---| +| Browser DSP copy is not VST-ready | Port feature contract and verified math only | +| Automation zipper/crackle | Per-sample coefficient smoothing and topology-specific crossfade QA | +| GUI hover/FFT slowing real-time audio | Cached CPU draw, no GPU dependency for sound, throttled analyzer | +| JUCE AGPL/commercial licensing | Publish source under AGPL, review commercial edition separately | +| Nonzero-phase behavior misrepresented | Name only implemented modes, measure before enabling | +| Parallel thread drift | PRD/ARD and CHANGELOG are canonical; small PRs with tests, no speculative rewrites | + +## Stage gates + +M0: repo structure, standalone DSP, unit tests, CMake; M1: VST3 adapter, host params, graph interaction and save state; M2: audited transitions, spectrum analyzer, host validation; M3: dynamic EQ; M4: phase variants/surround/other formats. Consult [ROADMAP.md](ROADMAP.md) for binary acceptance. Avoid costly CI on unneeded toolchains until the host wrapper exists. diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md new file mode 100644 index 0000000..8dc7493 --- /dev/null +++ b/docs/MIGRATION.md @@ -0,0 +1,29 @@ +# MaSonKuPik → ArSonEQ: evidence-based migration audit + +Date: 2026-10-29. Source: private `masarray/masonkupik` main, reviewed through connected GitHub; destination: public `masarray/arson-eq`. + +| Source file | Evidence / usable logic | Port policy | +|---|---|---| +| `src/audio/presets.ts` | `EqBand`: id, type, frequency, gain, q, slope, enabled. Six filter types; Butterworth Q arrays 12–48 dB/oct. | Re-express model as stable native parameters; numeric Q values may be retained. | +| `src/audio/engine.ts` | `MasterChain` creates Web Audio `BiquadFilterNode` groups; also compressor, color, limiter, width and meters. | **Do not port full engine**. Implement native biquads, reuse validated EQ behavior only. | +| `src/components/plugins/EQEditor.tsx` | Double-click add/remove, drag freq/gain, wheel Q/cut slope, frequency response from `OfflineAudioContext`. | Recreate interactions in native JUCE; replace offline Web Audio response with exact C++ transfer function. | +| `src/components/plugins/_shell/spectrumCanvas.ts` | Log-frequency spectrum display, peak hold, smoothing, ~26 FPS FFT reads. | Port visual principles, not Web Audio `AnalyserNode` or React component. | +| `src/state/app.ts` | Zustand interactions, change grouping and undo operations. | Use APVTS for host automation/state, native undo manager for UI actions. | +| `tools/audio-quality-audit.ts` | Offline response, signal/polarity and format checks on browser engine. | Recreate deterministic C++ tests; host validation is separately required. | + +**Audit conclusion:** MaSonKuPik is a browser mastering application with EQ, not an existing C++ VST or a separable low-level C++ EQ library. An indiscriminate code copy makes ArSonEQ heavier and less interoperable. Since source is private and destination public, do not expose its unrelated assets/presets/secrets without reviewing provenance. Owner-requested porting of relevant behavior does not imply third-party asset permissions. + +### Verified reference behavior vs extensions + +Source currently supports Bell, Low Shelf, High Shelf, Low Cut, High Cut, Notch; 12/24/36/48 cut slopes; live spectrum; curve response; draggable bands. It does not establish VST3 host compliance, phase modes, per-band dynamic EQ or sidechain: these are **new work**, not port-complete features. + +### Provenance and ownership + +MaSonKuPik source repository had no project-level LICENSE file visible in the audited tree. Destination already has AGPL-3.0. Before copying any substantial source expression into this public repo, document ownership, dependencies and permissions. The initial C++ implementation is a fresh portable engine, with openly documented standard RBJ filter equations. + +Reference links: +- https://github.com/masarray/masonkupik +- https://www.w3.org/TR/webaudio/ +- https://www.fabfilter.com/news/1543478400/fabfilter-releases-fabfilter-pro-q-3-equalizer-plug-in-with-dynamic-eq +- https://github.com/juce-framework/JUCE +- https://www.steinberg.net/developers/vstsdk/ diff --git a/docs/PRD.md b/docs/PRD.md new file mode 100644 index 0000000..ee2c8c1 --- /dev/null +++ b/docs/PRD.md @@ -0,0 +1,73 @@ +# PRD — ArSonEQ Professional Parametric EQ + +Version: 0.1 | Updated: 2026-10-29 | Status: implementation baseline +Owner: masarray/arson-eq | Source of truth for parallel threads + +## 1. Product outcome + +Build a polished, low-CPU parametric EQ for musicians, audio engineers, mastering, live sound, and integration into ArSonMix. Fast workflows, audible transparency, host automation, deterministic DSP, compatibility, and small interface overhead matter more than feature-count marketing. Reference products establish user expectations; the product architecture and visual identity remain original. + +## 2. User journeys and success criteria + +1. Add a band with a double-click; drag frequency/gain; mouse wheel changes Q/slope; switch shape and stereo placement; bypass one band instantly without clicks. +2. Use 2–8 typical bands at a live buffer size of 32/64/128 samples without stutter. +3. Tackle harshness with per-band dynamic processing (later milestone), safely audible in real time. +4. Observe a smooth pre/post analyzer without UI rendering affecting the audio callback. +5. Save/reopen DAW sessions and presets with identical sound and values; automate parameters without surprises. +6. Embed the DSP core in another product without depending on JUCE, rendering, or host code. + +## 3. Feature requirements + +| ID | Requirement | Priority | Gate | +|---|---|---|---| +| EQ-01 | Up to 24 individually enabled bands, persistent stable slots | P0 | Unit and host tests | +| EQ-02 | Bell, low/high shelf, low/high cut, notch; Q, gain, frequency | P0 | Response comparison and finite output | +| EQ-03 | 12/24/36/48 dB/oct Butterworth cuts (existing MaSonKuPik values) | P0 | Measured frequency response | +| EQ-04 | Stereo, L, R, Mid, Side processing per band; mono downmix | P0 | Matrix + M/S null tests | +| EQ-05 | Zero-latency minimum-phase mode; no unnecessary lookahead | P0 | Reported latency 0, bypass/null | +| EQ-06 | Native VST3 x64, host automation, state restore, bypass | P0 | REAPER + VST3 validator | +| EQ-07 | Interactive log-frequency graph, compact inspector, resize, sensible contrast | P0 | Visual QA at 100–200% DPI | +| EQ-08 | No allocations/locks/logging/IO in processBlock | P0 | RT audit + profiling | +| EQ-09 | Smooth changes incl. cross-type/slope without crackle | P0 release gate | Automation stress + listening | +| EQ-10 | Pre/post FFT, freeze, adjustable tilt/range, spectrum grab | P1 | Performance/accuracy profiling | +| EQ-11 | Dynamic EQ per band, compression/expansion, manual/auto threshold | P1 | Envelope + gain reduction tests | +| EQ-12 | External sidechain with proper bus negotiation/fallback | P1 | Host interoperability | +| EQ-13 | A/B, undo/redo, band solo, gain scale, keyboard and numeric input | P1 | Interaction acceptance | +| EQ-14 | Natural Phase-like low-phase-distortion mode (original method) | P2 | Phase/impulse/latency measurements | +| EQ-15 | Linear Phase with quality/latency choices | P2 | FIR, delay reporting, pre-ringing analysis | +| EQ-16 | 6–96 dB/oct cut slopes, spectral collision/EQ match, surround | P2 | Separate validated engines | +| EQ-17 | CLAP/AU, multi-instance awareness | P3 | Dedicated platform compatibility | + +P0 means foundation and v1 release blockers as applicable; work may be staged under M0/M1. A table entry alone is not an assertion that the feature has shipped. + +## 4. UX and visual language + +Premium but restrained: graphite/near-black canvas, subtle calibrated frequency/dB grid, fine EQ curve, tiny unobtrusive frequency nodes, legible typography, soft highlight only on selected band, no giant cards, shadows, or gratuitous hover animations. No perpetual animation when stopped or hidden. No embedded browser runtime in audio processing. UI remains functional with FFT disabled. + +Primary graph takes most of the window; bottom compact toolbar contains phase mode, spectrum modes, output, bypass and A/B; a single unobtrusive context inspector appears only for the selected band. Double-click add; right-click context; drag adjusts; Shift offers fine changes; scroll adjusts Q; Ctrl/Cmd+Z undo; numeric input for precision. Frequency axis 20 Hz–20 kHz, capped safely to Nyquist. Make at least 100%, 125%, 150%, 200% scale pass. + +## 5. Compatibility and state + +- Windows 10/11 x64 VST3 first, sample rates 44.1/48/88.2/96/192 kHz, blocks 16–2048 and variable lengths; mono and stereo. +- Main stereo bus: mono/stereo input matching output; sidechain later and optional. +- Serialized schema version, stable non-recycled host parameter IDs, deterministic saved presets. +- Disabled band slots keep IDs; host automation still addresses the same slot after deletions. +- No network/cloud telemetry, installer or registration required for local use. + +## 6. Quantifiable performance targets (not yet measured) + +On reference desktop Windows x64 48 kHz 64-sample buffer and native release build: +- Zero-latency mode: reported latency 0 samples; no heap allocation in processBlock. +- Typical 8 bell bands stereo: target <0.5% of one modern performance core at 48 kHz (to be benchmarked, not promised). +- 24 bands: target <2.0% of one modern performance core under the same reference conditions; report exact CPU and machine. +- Editor closed: no analyzer/visual work; editor open: FFT reading capped ~30 Hz and no impact on callback deadlines. +- No NaN/Inf, hangs, clicks on automation, silence self-noise, unexpected gain in flat mode. +- Startup without unnecessary heavy initialization or network operations. + +## 7. Non-goals + +Do not copy FabFilter branding, logos, code, proprietary filter algorithms, exact visual assets, or UI textures. Do not transplant the entire MaSonKuPik mastering chain or introduce compressor/limiter to this EQ. Do not present unimplemented phase modes or advanced dynamics as working controls. Do not require a development/"Lab" mode for users. + +## 8. Release acceptance + +VST3 validator, host projects, automation/snapshot recall, phase/frequency/impulse tests, soak stress, CPU/memory benchmark and at least two real audio listening scenarios must pass before declaring production. Release artifacts must be traceable to a pinned commit and have an actual reproducible build. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 0000000..601ad57 --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,22 @@ +# Roadmap and handoff checklist + +All contributors and parallel ChatGPT threads must read PRD + ARD + this file **and inspect GitHub HEAD/open PRs** before editing. Avoid overlapping implementations, reversed decisions, expensive CI, or claiming test success without logs. + +| Gate | Work | Exit criteria | +|---|---|---| +| M0 — foundation | Native C++17 parametric EQ; 24 fixed slots; core tests; pinned plugin dependency; docs | C++ compile and tests on Linux + Windows | +| M1 — usable VST3 | JUCE VST3, mono/stereo, 24-band host parameters, persistent state, interactive native graph | Windows .vst3 artifact, REAPER smoke, pluginval | +| M1.5 — audio hardening | RT parameter smoothing, bypass/type change transition, Q/frequency edge-case stability, host automation tests | Zero clicks in prescribed stress suite; ASan/UBSan offline; no heap activity on callback | +| M2 — UX | Pre/post real FFT, Q controls, detailed band inspector, undo/redo, A/B, theme polish, resize | 30 FPS max FFT on UI, graph parity with DSP, user workflow tests | +| M3 — Dynamic EQ | Threshold/range, automatic envelope, attack/release, compressed/expanded bands, sidechain | Golden tests, audio listening, CPU budget maintained | +| M4 — phase engine | Measured lower-phase-distortion option, FIR linear phase with correct delay and optional quality | Verified impulse/phase response, delay compensation, musical listening | +| M5 — expansion | Extended slope/surround/macOS/CLAP/EQ match | Platform-specific compatibility suite | + +### Non-negotiables + +1. Publish no artifact called release-ready until actual tests passed and DAW run evidence is linked. +2. Keep DSP independent from plugin framework; never put allocations, network, locking, heavy logs or render work in the audio callback. +3. Use fixed host IDs; add but never reuse/reorder parameter IDs after public release. +4. Do not copy third-party proprietary GUI artwork, trademarks, presets or algorithms. +5. CI budget: fast headless DSP checks on each PR, heavy platform/plugin builds only on meaningful PR/controlled dispatch; cache dependencies where viable. +6. Make precise claims: **Designed**, **Implemented**, **Compiled**, **Validated in DAW** are different statuses. From 35f94ca9a6cb13ac1e3b1627dfb3e90e057af18f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:12:08 +0700 Subject: [PATCH 02/23] feat(dsp): introduce portable 24-band C++ EQ core and headless test harness --- CMakeLists.txt | 62 ++++++++++ Source/DSP/ParametricEQ.h | 252 ++++++++++++++++++++++++++++++++++++++ tests/eq_core_tests.cpp | 75 ++++++++++++ 3 files changed, 389 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Source/DSP/ParametricEQ.h create mode 100644 tests/eq_core_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..74250d0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.24) +project(ArSonEQ VERSION 0.1.0 LANGUAGES CXX) + +option(ARSONEQ_BUILD_PLUGIN "Build VST3 plugin using JUCE" OFF) +option(ARSONEQ_BUILD_TESTS "Build standalone DSP unit tests" ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +add_library(arson_eq_dsp INTERFACE) +target_include_directories(arson_eq_dsp INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/Source") +target_compile_features(arson_eq_dsp INTERFACE cxx_std_17) + +if(ARSONEQ_BUILD_TESTS) + enable_testing() + add_executable(arson_eq_core_tests tests/eq_core_tests.cpp) + target_link_libraries(arson_eq_core_tests PRIVATE arson_eq_dsp) + if(MSVC) + target_compile_options(arson_eq_core_tests PRIVATE /W4) + else() + target_compile_options(arson_eq_core_tests PRIVATE -Wall -Wextra -Wpedantic) + endif() + add_test(NAME arson_eq_core COMMAND arson_eq_core_tests) +endif() + +if(ARSONEQ_BUILD_PLUGIN) + # Local JUCE checkout for offline builds; otherwise fetch a pinned release. + if(DEFINED JUCE_SOURCE_DIR AND EXISTS "${JUCE_SOURCE_DIR}/CMakeLists.txt") + add_subdirectory("${JUCE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/juce") + else() + include(FetchContent) + FetchContent_Declare(juce + GIT_REPOSITORY https://github.com/juce-framework/JUCE.git + GIT_TAG 9.0.4 + GIT_SHALLOW TRUE) + FetchContent_MakeAvailable(juce) + endif() + + juce_add_plugin(ArSonEQ + COMPANY_NAME "ArSon Audio" + BUNDLE_ID "com.arsonaudio.arsoneq" + PLUGIN_MANUFACTURER_CODE ArsN + PLUGIN_CODE ArEQ + FORMATS VST3 + VST3_CATEGORIES Fx EQ + IS_SYNTH FALSE + NEEDS_MIDI_INPUT FALSE + NEEDS_MIDI_OUTPUT FALSE + IS_MIDI_EFFECT FALSE + COPY_PLUGIN_AFTER_BUILD FALSE + PRODUCT_NAME "ArSonEQ") + target_sources(ArSonEQ PRIVATE + Source/PluginProcessor.cpp + Source/PluginEditor.cpp) + target_link_libraries(ArSonEQ PRIVATE arson_eq_dsp + juce::juce_audio_utils juce::juce_dsp + juce::juce_recommended_config_flags + juce::juce_recommended_warning_flags + juce::juce_recommended_lto_flags) + target_compile_definitions(ArSonEQ PRIVATE + JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0) +endif() diff --git a/Source/DSP/ParametricEQ.h b/Source/DSP/ParametricEQ.h new file mode 100644 index 0000000..94710b5 --- /dev/null +++ b/Source/DSP/ParametricEQ.h @@ -0,0 +1,252 @@ +// ArSonEQ native DSP core: C++17, no JUCE, allocations, or locks on the audio path. +// New implementation informed by standard RBJ Audio EQ Cookbook biquads and +// MaSonKuPik's 12-48 dB/oct Butterworth Q-stage selections. +#pragma once +#include +#include +#include +#include +#include +#include + +namespace arson::eq { +constexpr int kMaxBands = 24; +constexpr int kMaxStages = 4; +constexpr double kPi = 3.1415926535897932384626433832795; + +enum class Type : int { Bell, LowShelf, HighShelf, LowCut, HighCut, Notch }; +enum class Route : int { Stereo, Left, Right, Mid, Side }; + +struct Band { + bool enabled = false; + Type type = Type::Bell; + Route route = Route::Stereo; + double frequency = 1000.0; + double gainDb = 0.0; + double q = 1.0; + int slope = 12; +}; +inline bool same(const Band& a, const Band& b) noexcept { + return a.enabled == b.enabled && a.type == b.type && a.route == b.route + && a.frequency == b.frequency && a.gainDb == b.gainDb + && a.q == b.q && a.slope == b.slope; +} +inline double finiteClamp(double x, double fallback, double low, double high) noexcept { + return std::clamp(std::isfinite(x) ? x : fallback, low, high); +} +struct Coeff { + double b0=1.0, b1=0.0, b2=0.0, a1=0.0, a2=0.0; +}; +inline Coeff identity() noexcept { return {}; } +inline Coeff coefficients(Type type, double freq, double gainDb, double q, double sr) noexcept { + freq = finiteClamp(freq, 1000.0, 20.0, 0.45 * sr); + gainDb = finiteClamp(gainDb, 0.0, -24.0, 24.0); + q = finiteClamp(q, 1.0, 0.1, 24.0); + const auto w = 2.0 * kPi * freq / sr; + const auto s = std::sin(w), c = std::cos(w); + const auto A = std::pow(10.0, gainDb / 40.0); + const auto alpha = s / (2.0 * q); + // RBJ shelving slope S is bounded independently of bell Q to avoid + // unstable/extremely resonant shelves. + const auto S = std::clamp(q, 0.25, 1.0); + const auto shelfAlpha = 0.5 * s * std::sqrt((A + 1.0 / A) * (1.0 / S - 1.0) + 2.0); + const auto root = 2.0 * std::sqrt(A) * shelfAlpha; + double b0=1,b1=0,b2=0,a0=1,a1=0,a2=0; + switch (type) { + case Type::Bell: + b0=1+alpha*A; b1=-2*c; b2=1-alpha*A; + a0=1+alpha/A; a1=-2*c; a2=1-alpha/A; break; + case Type::Notch: + b0=1; b1=-2*c; b2=1; + a0=1+alpha; a1=-2*c; a2=1-alpha; break; + case Type::LowCut: + b0=(1+c)/2; b1=-(1+c); b2=(1+c)/2; + a0=1+alpha; a1=-2*c; a2=1-alpha; break; + case Type::HighCut: + b0=(1-c)/2; b1=1-c; b2=(1-c)/2; + a0=1+alpha; a1=-2*c; a2=1-alpha; break; + case Type::LowShelf: + b0=A*((A+1)-(A-1)*c+root); + b1=2*A*((A-1)-(A+1)*c); + b2=A*((A+1)-(A-1)*c-root); + a0=(A+1)+(A-1)*c+root; + a1=-2*((A-1)+(A+1)*c); + a2=(A+1)+(A-1)*c-root; break; + case Type::HighShelf: + b0=A*((A+1)+(A-1)*c+root); + b1=-2*A*((A-1)+(A+1)*c); + b2=A*((A+1)+(A-1)*c-root); + a0=(A+1)-(A-1)*c+root; + a1=2*((A-1)-(A+1)*c); + a2=(A+1)-(A-1)*c-root; break; + } + if (!std::isfinite(a0) || std::abs(a0) < 1e-15) return identity(); + const double inv = 1.0 / a0; + Coeff result{b0*inv,b1*inv,b2*inv,a1*inv,a2*inv}; + if (!std::isfinite(result.b0) || !std::isfinite(result.a1) + || !std::isfinite(result.a2)) return identity(); + return result; +} +inline int stageCount(int slope) noexcept { + return slope >= 48 ? 4 : slope >= 36 ? 3 : slope >= 24 ? 2 : 1; +} +inline double butterworthQ(int stages, int index) noexcept { + constexpr double qs[4][4] = { + {0.7071067811865476, 0, 0, 0}, + {0.541196100146197, 1.306562964876377, 0, 0}, + {0.517638090205041, 0.707106781186548, 1.931851652578137, 0}, + {0.509795579104159, 0.601344886935045, 0.899976223136416, 2.562915447741506} + }; + return qs[std::clamp(stages,1,4)-1][std::clamp(index,0,3)]; +} +inline std::array makeStages(Band band, double sr) noexcept { + std::array result{}; + if (!band.enabled) return result; + const bool cut = band.type == Type::LowCut || band.type == Type::HighCut; + const int count = cut ? stageCount(band.slope) : 1; + for (int i=0;i(i)] = coefficients(band.type,band.frequency,band.gainDb,q,sr); + } + return result; +} +inline double magnitudeDb(const Coeff& c, double freq, double sr) noexcept { + const auto theta = 2.0*kPi*freq/sr; + const auto z = std::polar(1.0,-theta), z2=z*z; + const auto num = c.b0 + c.b1*z + c.b2*z2; + const auto den = 1.0 + c.a1*z + c.a2*z2; + return 20.0*std::log10(std::max(std::abs(num)/std::max(std::abs(den),1e-20),1e-20)); +} + +class Engine { +public: + void prepare(double rate) noexcept { + sampleRate_ = finiteClamp(rate,48000.0,8000.0,384000.0); + for (int i=0;i(i)]; + slot.state={}; + slot.current=slot.target=makeStages(slot.band,sampleRate_); + slot.remaining=0; + slot.active=slot.band.enabled; + } + } + double sampleRate() const noexcept { return sampleRate_; } + Band band(int index) const noexcept { return valid(index) ? slots_[static_cast(index)].band : Band{}; } + bool setBand(int index, Band value) noexcept { + if (!valid(index)) return false; + value.frequency=finiteClamp(value.frequency,1000.0,20.0,0.45*sampleRate_); + value.gainDb=finiteClamp(value.gainDb,0.0,-24.0,24.0); + value.q=finiteClamp(value.q,1.0,0.1,24.0); + value.slope=stageCount(value.slope)*12; + if (static_cast(value.type)<0 || static_cast(value.type)>5) value.type=Type::Bell; + if (static_cast(value.route)<0 || static_cast(value.route)>4) value.route=Route::Stereo; + auto& slot=slots_[static_cast(index)]; + if (same(slot.band,value)) return false; + slot.band=value; + slot.target=makeStages(value,sampleRate_); + slot.remaining=std::max(1,static_cast(std::ceil(sampleRate_*0.008))); + slot.active=true; // keep processing during smooth disable transition + return true; + } + void reset() noexcept { + for (auto& slot:slots_) { + slot.state={}; + slot.current=slot.target=makeStages(slot.band,sampleRate_); + slot.remaining=0;slot.active=slot.band.enabled; + } + } + // Called once per stereo sample: no allocations, no transcendental math. + void process(double& left, double& right) noexcept { + for (auto& slot:slots_) { + if (!slot.active) continue; + advance(slot); + switch (slot.band.route) { + case Route::Stereo: left=filter(slot,left,0);right=filter(slot,right,1);break; + case Route::Left: left=filter(slot,left,0);break; + case Route::Right: right=filter(slot,right,1);break; + case Route::Mid: { + const auto mid=0.5*(left+right); + const auto d=filter(slot,mid,0)-mid; + left+=d;right+=d;break; + } + case Route::Side: { + const auto side=0.5*(left-right); + const auto d=filter(slot,side,0)-side; + left+=d;right-=d;break; + } + } + } + } + void processMono(double& sample) noexcept { + for (auto& slot:slots_) { + if (!slot.active) continue; + advance(slot); + if (slot.band.route==Route::Right || slot.band.route==Route::Side) continue; + sample=filter(slot,sample,0); + } + } + // Exact steady-state transfer for a single selected band (not temporal smoothing). + double bandResponseDb(int index, double frequency) const noexcept { + if (!valid(index) || !slots_[static_cast(index)].band.enabled) return 0.0; + const auto& s=slots_[static_cast(index)]; + const auto coeff=makeStages(s.band,sampleRate_); + double db=0; + for (const auto& c:coeff) db+=magnitudeDb(c,frequency,sampleRate_); + return db; + } + // Useful for a stereo EQ curve. Mid/Side/one-channel responses are exposed + // separately through bandResponseDb and must not be misrepresented as a + // single universal L/R curve. + double stereoResponseDb(double frequency) const noexcept { + double db=0; + for (int i=0;i(i)].band.enabled + && slots_[static_cast(i)].band.route==Route::Stereo) + db+=bandResponseDb(i,frequency); + return db; + } +private: + struct State { double z1=0,z2=0; }; + struct Slot { + Band band{}; + std::array current{},target{}; + std::array,2> state{}; + int remaining=0; + bool active=false; + }; + static bool valid(int index) noexcept { return index>=0 && index(s.remaining); + for (int i=0;i(i)]; + const auto& t=s.target[static_cast(i)]; + c.b0+=(t.b0-c.b0)/r; c.b1+=(t.b1-c.b1)/r; + c.b2+=(t.b2-c.b2)/r; c.a1+=(t.a1-c.a1)/r; c.a2+=(t.a2-c.a2)/r; + } + --s.remaining; + if (s.remaining==0 && !s.band.enabled) { s.active=false;s.state={}; } + } + static double filter(Slot& s, double input, int lane) noexcept { + auto value=input; + for (int i=0;i(i)]; + auto& z=s.state[static_cast(lane)][static_cast(i)]; + const auto out=c.b0*value+z.z1; + const auto next1=c.b1*value-c.a1*out+z.z2; + const auto next2=c.b2*value-c.a2*out; + if (!std::isfinite(out) || !std::isfinite(next1) || !std::isfinite(next2)) { + z={};value=0.0; + } else { + // Prevent long-lived denormals on silence without extra allocation. + z.z1=std::abs(next1)<1e-24 ? 0.0 : next1; + z.z2=std::abs(next2)<1e-24 ? 0.0 : next2; + value=out; + } + } + return value; + } + double sampleRate_=48000.0; + std::array slots_{}; +}; +} // namespace arson::eq diff --git a/tests/eq_core_tests.cpp b/tests/eq_core_tests.cpp new file mode 100644 index 0000000..902df60 --- /dev/null +++ b/tests/eq_core_tests.cpp @@ -0,0 +1,75 @@ +#include "../Source/DSP/ParametricEQ.h" +#include +#include +#include +#include +#include +using namespace arson::eq; +static void require(bool ok,const char* msg) { + if (!ok) { std::fprintf(stderr,"FAILED: %s\n",msg); std::exit(1); } +} +static double responseFor(Band b,double f) { + Engine e;e.prepare(48000);e.setBand(0,b); + return e.bandResponseDb(0,f); +} +int main() { + Engine eq; + eq.prepare(48000); + double l=0.14,r=-0.27;eq.process(l,r); + require(l==0.14&&r==-0.27,"empty processor is bit-transparent"); + Band b; b.enabled=true;b.type=Type::Bell;b.frequency=1000;b.gainDb=6;b.q=1; + require(std::abs(responseFor(b,1000)-6.0)<0.02,"bell center gain"); + b.gainDb=-12; + require(std::abs(responseFor(b,1000)+12.0)<0.02,"bell center cut"); + b.gainDb=0; + require(std::abs(responseFor(b,1000))<1e-8,"flat bell"); + b.type=Type::LowCut;b.frequency=1000;b.slope=24; + require(responseFor(b,100)<-70,"24 dB/oct deep low cut"); + require(std::abs(responseFor(b,1000)+3.0103)<0.12,"Butterworth cut crossover"); + b.type=Type::HighCut; + require(responseFor(b,10000)<-65,"24 dB/oct high cut"); + b.type=Type::LowShelf;b.gainDb=6; + require(responseFor(b,60)>5.5 && std::abs(responseFor(b,12000))<0.1,"low shelf"); + b.type=Type::HighShelf; + require(responseFor(b,12000)>5.5 && std::abs(responseFor(b,60))<0.1,"high shelf"); + b.type=Type::Notch;b.frequency=1200; + require(responseFor(b,1200)<-80,"notch center"); + eq.prepare(48000); + b.type=Type::Bell;b.gainDb=12;b.frequency=1000;b.route=Route::Mid; + eq.setBand(0,b); + // Allow the 8ms smoothing transition to settle. + for(int i=0;i<2000;++i){double x=0,y=0;eq.process(x,y);} + l=0.1;r=-0.1;eq.process(l,r); + require(std::abs(l-0.1)<1e-8 && std::abs(r+0.1)<1e-8,"mid band leaves pure side untouched"); + b.route=Route::Side;eq.setBand(0,b); + for(int i=0;i<2000;++i){double x=0,y=0;eq.process(x,y);} + l=0.1;r=0.1;eq.process(l,r); + require(std::abs(l-0.1)<1e-8 && std::abs(r-0.1)<1e-8,"side band leaves pure mid untouched"); + for(int sr:{44100,48000,96000,192000}) { + eq.prepare(sr); + std::mt19937 rng(42);std::uniform_real_distribution dist(-1.0,1.0); + for(int i=0;i(i%6); + c.route=static_cast(i%5); + c.frequency=20+((i*977)%19000);c.gainDb=static_cast(i%21)-10; + c.q=0.1+(i%12)*0.95;c.slope=12+12*(i%4); + eq.setBand(i,c); + } + for(int i=0;i::quiet_NaN(); + b.q=std::numeric_limits::infinity(); + b.gainDb=-std::numeric_limits::infinity(); + eq.setBand(0,b); + require(std::isfinite(eq.band(0).frequency)&&std::isfinite(eq.band(0).q) + &&std::isfinite(eq.band(0).gainDb),"invalid controls sanitized"); + std::puts("ArSonEQ DSP tests passed"); +} From 5c3c50fbcf1e0a0e702c52a217060a7a5d1281d4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:15:25 +0700 Subject: [PATCH 03/23] feat(vst3): add JUCE 9 host adapter, automation/state and compact native EQ editor --- .github/workflows/dsp.yml | 25 ++++ Source/PluginEditor.cpp | 248 +++++++++++++++++++++++++++++++++++++ Source/PluginEditor.h | 37 ++++++ Source/PluginProcessor.cpp | 113 +++++++++++++++++ Source/PluginProcessor.h | 54 ++++++++ 5 files changed, 477 insertions(+) create mode 100644 .github/workflows/dsp.yml create mode 100644 Source/PluginEditor.cpp create mode 100644 Source/PluginEditor.h create mode 100644 Source/PluginProcessor.cpp create mode 100644 Source/PluginProcessor.h diff --git a/.github/workflows/dsp.yml b/.github/workflows/dsp.yml new file mode 100644 index 0000000..7a3a317 --- /dev/null +++ b/.github/workflows/dsp.yml @@ -0,0 +1,25 @@ +name: Fast DSP checks +on: + pull_request: + paths: + - "Source/DSP/**" + - "tests/**" + - "CMakeLists.txt" + - ".github/workflows/dsp.yml" + workflow_dispatch: +permissions: + contents: read +jobs: + dsp: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Configure standalone core + run: cmake -S . -B build -DARSONEQ_BUILD_PLUGIN=OFF -DARSONEQ_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release + - name: Build + run: cmake --build build --config Release --parallel 2 + - name: Test + run: ctest --test-dir build --config Release --output-on-failure diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp new file mode 100644 index 0000000..353a864 --- /dev/null +++ b/Source/PluginEditor.cpp @@ -0,0 +1,248 @@ +#include "PluginEditor.h" +#include +#include + +namespace { +const juce::Colour bg(0xff11151c), grid(0xff252d37), ink(0xffc9d3e0); +const juce::Colour accent(0xff52c9df), selectedColor(0xfff2bf79); +constexpr double minHz=20.0,maxHz=20000.0,dbRange=18.0; +constexpr const char* typeNames[]{"Bell","Low Sh","High Sh","Low Cut","High Cut","Notch"}; +constexpr const char* routeNames[]{"Stereo","L","R","Mid","Side"}; +} +ArSonEQEditor::ArSonEQEditor(ArSonEQAudioProcessor& owner) + : juce::AudioProcessorEditor(owner),processor_(owner) { + setResizable(true,true); + setResizeLimits(680,420,1440,900); + setSize(930,570); + setWantsKeyboardFocus(true); + graphEngine_.prepare(processor_.configuredSampleRate()); + // Repaints only on parameter changes; never animates idle hover or FFT. + startTimerHz(20); + timerCallback(); +} +juce::Rectangle ArSonEQEditor::graph() const { + return juce::Rectangle(48.f,73.f, + static_cast(getWidth())-76.f,static_cast(getHeight())-215.f); +} +float ArSonEQEditor::xForHz(double freq) const { + const auto r=graph(); + return r.getX()+static_cast(std::log(std::clamp(freq,minHz,maxHz)/minHz) + /std::log(maxHz/minHz))*r.getWidth(); +} +float ArSonEQEditor::yForDb(double db) const { + const auto r=graph(); + return r.getCentreY()-static_cast(std::clamp(db,-dbRange,dbRange)/dbRange) + *r.getHeight()*0.5f; +} +double ArSonEQEditor::hzForX(float x) const { + const auto r=graph(); + return minHz*std::pow(maxHz/minHz,std::clamp( + static_cast((x-r.getX())/r.getWidth()),0.0,1.0)); +} +double ArSonEQEditor::dbForY(float y) const { + const auto r=graph(); + return std::clamp(static_cast((r.getCentreY()-y)*2/r.getHeight())*dbRange, + -dbRange,dbRange); +} +void ArSonEQEditor::timerCallback() { + bool changed=false; + const auto sr=processor_.configuredSampleRate(); + if (graphEngine_.sampleRate()!=sr) { graphEngine_.prepare(sr);changed=true; } + for(int i=0;i(i)],b)) { + cached_[static_cast(i)]=b; + graphEngine_.setBand(i,b); + changed=true; + } + } + if(changed) repaint(); +} +void ArSonEQEditor::paint(juce::Graphics& g) { + g.fillAll(bg); + g.setColour(ink); + g.setFont(juce::Font(juce::FontOptions(17.0f).withStyle("Plain"))); + g.drawText("ARSON EQ",juce::Rectangle(23,15,190,32),juce::Justification::centredLeft); + g.setColour(juce::Colour(0xff748391));g.setFont(11.f); + g.drawText("PARAMETRIC / ZERO LATENCY",juce::Rectangle(205,20,280,22), + juce::Justification::centredLeft); + const auto r=graph(); + g.setColour(juce::Colour(0xff161c24)); + g.fillRoundedRectangle(r,6.f); + const double ticks[]{20,50,100,200,500,1000,2000,5000,10000,20000}; + for(const auto f:ticks) { + const auto x=xForHz(f); + g.setColour(grid);g.drawVerticalLine(juce::roundToInt(x),r.getY(),r.getBottom()); + g.setColour(juce::Colour(0xff8b98a8));g.setFont(10.f); + g.drawText(f>=1000?juce::String(f/1000.0, f==2000||f==5000||f==10000||f==20000?0:1)+"k" + :juce::String(static_cast(f)), + juce::Rectangle(x-19,r.getBottom()+4,38,15),juce::Justification::centred); + } + for(int db=-18;db<=18;db+=6) { + const auto y=yForDb(db); + g.setColour(db==0?juce::Colour(0xff596879):grid); + g.drawHorizontalLine(juce::roundToInt(y),r.getX(),r.getRight()); + g.setColour(juce::Colour(0xff8b98a8));g.setFont(10.f); + g.drawText((db>0?"+":"")+juce::String(db), + juce::Rectangle(7,y-7,32,15),juce::Justification::centredRight); + } + juce::Path curve; + const int points=std::min(400,std::max(120,static_cast(r.getWidth()/2))); + for(int i=0;i<=points;++i) { + const auto x=r.getX()+r.getWidth()*static_cast(i)/points; + const auto y=yForDb(graphEngine_.stereoResponseDb(hzForX(x))); + if(i==0) curve.startNewSubPath(x,y);else curve.lineTo(x,y); + } + g.setColour(accent.withAlpha(0.9f)); + g.strokePath(curve,juce::PathStrokeType(2.f)); + for(int i=0;i(i)]; + if(!b.enabled) continue; + const auto x=xForHz(b.frequency); + const auto y=yForDb(b.type==arson::eq::Type::LowCut + ||b.type==arson::eq::Type::HighCut?0.0:b.gainDb); + g.setColour(i==selected_?selectedColor:accent.withAlpha(0.78f)); + g.fillEllipse(x-5,y-5,10,10); + if(i==selected_) { g.setColour(ink);g.drawEllipse(x-8,y-8,16,16,1.f); } + } + g.setColour(juce::Colour(0xff7e91a0));g.setFont(11.f); + g.drawText("Double-click: add / bypass · Drag: frequency + gain · Wheel: Q", + juce::Rectangle(48,getHeight()-116,getWidth()-96,22), + juce::Justification::centredLeft); + drawModeButtons(g); +} +void ArSonEQEditor::drawModeButtons(juce::Graphics& g) { + const int y=getHeight()-81; + g.setColour(juce::Colour(0xff7e91a0));g.setFont(11.f); + if(selected_<0) { + g.drawText("Select an EQ node to edit its shape and channel.", + juce::Rectangle(48,y,getWidth()-60,48),juce::Justification::centredLeft); + return; + } + const auto& b=cached_[static_cast(selected_)]; + g.drawText("B"+juce::String(selected_+1)+" "+juce::String(b.frequency,1)+" Hz " + +juce::String(b.gainDb,1)+" dB Q "+juce::String(b.q,2), + juce::Rectangle(48,y-30,getWidth()-60,25),juce::Justification::centredLeft); + for(int i=0;i<6;++i) { + const juce::Rectangle box(48.f+i*84.f,static_cast(y),80.f,27.f); + const bool active=static_cast(b.type)==i; + g.setColour(active?juce::Colour(0xff255060):juce::Colour(0xff202832)); + g.fillRoundedRectangle(box,4.f); + g.setColour(active?accent:ink);g.setFont(11.f); + g.drawText(typeNames[i],box,juce::Justification::centred); + } + for(int i=0;i<5;++i) { + const juce::Rectangle box(48.f+i*67.f,static_cast(y+32),63.f,25.f); + const bool active=static_cast(b.route)==i; + g.setColour(active?juce::Colour(0xff255060):juce::Colour(0xff202832)); + g.fillRoundedRectangle(box,4.f); + g.setColour(active?accent:ink);g.setFont(11.f); + g.drawText(routeNames[i],box,juce::Justification::centred); + } + g.setColour(juce::Colour(0xff738799));g.setFont(10.f); + g.drawText("Cut slope: wheel on node",juce::Rectangle( + 410,y+33,getWidth()-450,22),juce::Justification::centredRight); +} +bool ArSonEQEditor::modeClick(juce::Point pos) { + if(selected_<0) return false; + const int y=getHeight()-81; + for(int i=0;i<6;++i) + if(juce::Rectangle(48.f+i*84.f,static_cast(y),80.f,27.f).contains(pos)) { + setField(selected_,"type",static_cast(i));return true; + } + for(int i=0;i<5;++i) + if(juce::Rectangle(48.f+i*67.f,static_cast(y+32),63.f,25.f).contains(pos)) { + setField(selected_,"route",static_cast(i));return true; + } + return false; +} +int ArSonEQEditor::hitBand(juce::Point pos) const { + for(int i=arson::eq::kMaxBands-1;i>=0;--i) { + const auto& b=cached_[static_cast(i)]; + if(!b.enabled) continue; + const auto x=xForHz(b.frequency), y=yForDb( + b.type==arson::eq::Type::LowCut||b.type==arson::eq::Type::HighCut?0:b.gainDb); + if(std::hypot(pos.x-x,pos.y-y)<13.f) return i; + } + return -1; +} +void ArSonEQEditor::setField(int slot,const char* field,float value,bool gesture) { + if(slot<0) return; + if(auto* p=processor_.parameters.getParameter(ArSonEQAudioProcessor::parameterId(slot,field))) { + if(gesture) p->beginChangeGesture(); + p->setValueNotifyingHost(p->convertTo0to1(value)); + if(gesture) p->endChangeGesture(); + } + timerCallback(); +} +void ArSonEQEditor::beginDrag() { + if(dragging_<0||gestureOpen_) return; + for(const char* field:{"freq","gain"}) + if(auto* p=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(dragging_,field))) p->beginChangeGesture(); + gestureOpen_=true; +} +void ArSonEQEditor::endDrag() { + if(!gestureOpen_) return; + for(const char* field:{"freq","gain"}) + if(auto* p=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(dragging_,field))) p->endChangeGesture(); + gestureOpen_=false; +} +void ArSonEQEditor::mouseDown(const juce::MouseEvent& e) { + const auto pos=e.position; + if(modeClick(pos)) return; + selected_=hitBand(pos);dragging_=selected_; + if(dragging_>=0) beginDrag(); + repaint(); +} +void ArSonEQEditor::mouseDrag(const juce::MouseEvent& e) { + if(dragging_<0 || !gestureOpen_) return; + setField(dragging_,"freq",static_cast(hzForX(e.position.x)),false); + const auto t=cached_[static_cast(dragging_)].type; + if(t!=arson::eq::Type::LowCut&&t!=arson::eq::Type::HighCut) + setField(dragging_,"gain",static_cast(dbForY(e.position.y)),false); +} +void ArSonEQEditor::mouseUp(const juce::MouseEvent&) { + endDrag(); dragging_=-1; +} +void ArSonEQEditor::mouseDoubleClick(const juce::MouseEvent& e) { + if(!graph().contains(e.position)) return; + const auto hit=hitBand(e.position); + if(hit>=0) { + setField(hit,"enabled",0.f);if(selected_==hit) selected_=-1; + } else { + for(int i=0;i(i)].enabled) continue; + setField(i,"type",0.f); + setField(i,"freq",static_cast(hzForX(e.position.x))); + setField(i,"gain",static_cast(dbForY(e.position.y))); + setField(i,"q",1.f); + setField(i,"route",0.f); + setField(i,"enabled",1.f); + selected_=i;break; + } + } + repaint(); +} +bool ArSonEQEditor::keyPressed(const juce::KeyPress& k) { + if(selected_<0) return false; + if(k==juce::KeyPress::deleteKey||k==juce::KeyPress::backspaceKey) { + setField(selected_,"enabled",0.f);selected_=-1;return true; + } + return false; +} +void ArSonEQEditor::mouseWheelMove(const juce::MouseEvent& e, + const juce::MouseWheelDetails& wheel) { + const auto hit=hitBand(e.position); + const int slot=hit>=0?hit:selected_; + if(slot<0) return; + const auto& b=cached_[static_cast(slot)]; + if(b.type==arson::eq::Type::LowCut||b.type==arson::eq::Type::HighCut) { + const int slope=std::clamp((b.slope/12-1)+(wheel.deltaY>0?1:-1),0,3); + setField(slot,"slope",static_cast(slope)); + } else { + setField(slot,"q",static_cast( + std::clamp(b.q*(wheel.deltaY>0?1.15:1/1.15),0.1,24.0))); + } +} diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h new file mode 100644 index 0000000..3b4d39d --- /dev/null +++ b/Source/PluginEditor.h @@ -0,0 +1,37 @@ +#pragma once +#include +#include +#include "PluginProcessor.h" + +class ArSonEQEditor final : public juce::AudioProcessorEditor, private juce::Timer { +public: + explicit ArSonEQEditor(ArSonEQAudioProcessor&); + ~ArSonEQEditor() override = default; + void paint(juce::Graphics&) override; + void resized() override {} + void mouseDown(const juce::MouseEvent&) override; + void mouseDrag(const juce::MouseEvent&) override; + void mouseUp(const juce::MouseEvent&) override; + void mouseDoubleClick(const juce::MouseEvent&) override; + bool keyPressed(const juce::KeyPress&) override; + void mouseWheelMove(const juce::MouseEvent&,const juce::MouseWheelDetails&) override; +private: + void timerCallback() override; + juce::Rectangle graph() const; + int hitBand(juce::Point) const; + float xForHz(double) const; + float yForDb(double) const; + double hzForX(float) const; + double dbForY(float) const; + void setField(int slot,const char* field,float value,bool withGesture=true); + void beginDrag(); + void endDrag(); + void drawModeButtons(juce::Graphics&); + bool modeClick(juce::Point); + ArSonEQAudioProcessor& processor_; + arson::eq::Engine graphEngine_; + std::array cached_{}; + int selected_=-1,dragging_=-1; + bool gestureOpen_=false; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQEditor) +}; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp new file mode 100644 index 0000000..93ce65f --- /dev/null +++ b/Source/PluginProcessor.cpp @@ -0,0 +1,113 @@ +#include "PluginProcessor.h" +#include "PluginEditor.h" +#include + +juce::String ArSonEQAudioProcessor::parameterId(int band, const char* field) { + return "b" + juce::String(band).paddedLeft('0', 2) + "_" + field; +} + +juce::AudioProcessorValueTreeState::ParameterLayout ArSonEQAudioProcessor::makeLayout() { + juce::AudioProcessorValueTreeState::ParameterLayout layout; + const juce::StringArray types{"Bell","Low Shelf","High Shelf","Low Cut","High Cut","Notch"}; + const juce::StringArray routes{"Stereo","Left","Right","Mid","Side"}; + const juce::StringArray slopes{"12 dB/oct","24 dB/oct","36 dB/oct","48 dB/oct"}; + juce::NormalisableRange freq(20.0f, 20000.0f); + freq.setSkewForCentre(1000.0f); + for (int i=0; i(id("enabled"),name+"Enabled",false)); + layout.add(std::make_unique(id("type"),name+"Type",types,0)); + layout.add(std::make_unique(id("route"),name+"Route",routes,0)); + layout.add(std::make_unique(id("freq"),name+"Frequency",freq,1000.0f)); + layout.add(std::make_unique(id("gain"),name+"Gain", + juce::NormalisableRange(-24.0f,24.0f,0.01f),0.0f)); + layout.add(std::make_unique(id("q"),name+"Q", + juce::NormalisableRange(0.1f,24.0f,0.0f,0.35f),1.0f)); + layout.add(std::make_unique(id("slope"),name+"Cut Slope",slopes,0)); + } + return layout; +} + +ArSonEQAudioProcessor::ArSonEQAudioProcessor() +: AudioProcessor(BusesProperties() + .withInput("Input",juce::AudioChannelSet::stereo(),true) + .withOutput("Output",juce::AudioChannelSet::stereo(),true)), + parameters(*this,nullptr,"PARAMETERS",makeLayout()) { + for (int i=0;i(i)]; + p.enabled=parameters.getRawParameterValue(parameterId(i,"enabled")); + p.type=parameters.getRawParameterValue(parameterId(i,"type")); + p.route=parameters.getRawParameterValue(parameterId(i,"route")); + p.freq=parameters.getRawParameterValue(parameterId(i,"freq")); + p.gain=parameters.getRawParameterValue(parameterId(i,"gain")); + p.q=parameters.getRawParameterValue(parameterId(i,"q")); + p.slope=parameters.getRawParameterValue(parameterId(i,"slope")); + jassert(p.enabled && p.type && p.route && p.freq && p.gain && p.q && p.slope); + } + engine_.prepare(48000.0); +} +bool ArSonEQAudioProcessor::isBusesLayoutSupported(const BusesLayout& layout) const { + const auto in=layout.getMainInputChannelSet(); + return (in==juce::AudioChannelSet::mono() || in==juce::AudioChannelSet::stereo()) + && layout.getMainOutputChannelSet()==in; +} +void ArSonEQAudioProcessor::prepareToPlay(double rate,int) { + preparedRate_.store(rate,std::memory_order_relaxed); + engine_.prepare(rate); + syncBands(); + engine_.reset(); // initial state takes effect without fade-in +} +arson::eq::Band ArSonEQAudioProcessor::readBand(int i) const noexcept { + arson::eq::Band b; + if (i<0 || i>=arson::eq::kMaxBands) return b; + const auto& p=raw_[static_cast(i)]; + b.enabled=p.enabled->load(std::memory_order_relaxed)>0.5f; + b.type=static_cast(static_cast(std::lround(p.type->load(std::memory_order_relaxed)))); + b.route=static_cast(static_cast(std::lround(p.route->load(std::memory_order_relaxed)))); + b.frequency=p.freq->load(std::memory_order_relaxed); + b.gainDb=p.gain->load(std::memory_order_relaxed); + b.q=p.q->load(std::memory_order_relaxed); + b.slope=12*(1+static_cast(std::lround(p.slope->load(std::memory_order_relaxed)))); + return b; +} +void ArSonEQAudioProcessor::syncBands() noexcept { + for (int i=0;i +void ArSonEQAudioProcessor::processAudio(juce::AudioBuffer& audio) { + juce::ScopedNoDenormals noDenormals; + syncBands(); + const int channels=audio.getNumChannels(),frames=audio.getNumSamples(); + if (channels<1) return; + auto* left=audio.getWritePointer(0); + if (channels==1) { + for (int s=0;s(x); + } + } else { + auto* right=audio.getWritePointer(1); + for (int s=0;s(l);right[s]=static_cast(r); + } + for (int ch=2;ch& b,juce::MidiBuffer&) { processAudio(b); } +void ArSonEQAudioProcessor::processBlock(juce::AudioBuffer& b,juce::MidiBuffer&) { processAudio(b); } +void ArSonEQAudioProcessor::getStateInformation(juce::MemoryBlock& destination) { + auto state=parameters.copyState(); + state.setProperty("arsoneq_schema",1,nullptr); + if (auto xml=state.createXml()) copyXmlToBinary(*xml,destination); +} +void ArSonEQAudioProcessor::setStateInformation(const void* data,int size) { + if (auto xml=getXmlFromBinary(data,size)) { + if (xml->hasTagName(parameters.state.getType())) + parameters.replaceState(juce::ValueTree::fromXml(*xml)); + } +} +juce::AudioProcessorEditor* ArSonEQAudioProcessor::createEditor() { + return new ArSonEQEditor(*this); +} +juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new ArSonEQAudioProcessor(); } diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h new file mode 100644 index 0000000..c981631 --- /dev/null +++ b/Source/PluginProcessor.h @@ -0,0 +1,54 @@ +#pragma once +#include +#include +#include +#include "DSP/ParametricEQ.h" + +class ArSonEQAudioProcessor final : public juce::AudioProcessor { +public: + ArSonEQAudioProcessor(); + ~ArSonEQAudioProcessor() override = default; + const juce::String getName() const override { return "ArSonEQ"; } + void prepareToPlay(double sampleRate, int samplesPerBlock) override; + void releaseResources() override {} + void processBlock(juce::AudioBuffer&, juce::MidiBuffer&) override; + void processBlock(juce::AudioBuffer&, juce::MidiBuffer&) override; + bool supportsDoublePrecisionProcessing() const override { return true; } + bool isBusesLayoutSupported(const BusesLayout& layouts) const override; + juce::AudioProcessorEditor* createEditor() override; + bool hasEditor() const override { return true; } + double getTailLengthSeconds() const override { return 0; } + bool acceptsMidi() const override { return false; } + bool producesMidi() const override { return false; } + bool isMidiEffect() const override { return false; } + int getNumPrograms() override { return 1; } + int getCurrentProgram() override { return 0; } + void setCurrentProgram(int) override {} + const juce::String getProgramName(int) override { return {}; } + void changeProgramName(int, const juce::String&) override {} + void getStateInformation(juce::MemoryBlock&) override; + void setStateInformation(const void*, int) override; + + static juce::String parameterId(int band, const char* field); + arson::eq::Band readBand(int index) const noexcept; + double configuredSampleRate() const noexcept { return preparedRate_.load(std::memory_order_relaxed); } + juce::AudioProcessorValueTreeState parameters; + +private: + struct ParamRefs { + std::atomic* enabled = nullptr; + std::atomic* type = nullptr; + std::atomic* route = nullptr; + std::atomic* freq = nullptr; + std::atomic* gain = nullptr; + std::atomic* q = nullptr; + std::atomic* slope = nullptr; + }; + static juce::AudioProcessorValueTreeState::ParameterLayout makeLayout(); + void syncBands() noexcept; + template void processAudio(juce::AudioBuffer&); + std::array raw_{}; + arson::eq::Engine engine_; + std::atomic preparedRate_{48000.0}; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQAudioProcessor) +}; From f612d19a67bc322955b1fa7139275299068de7ff Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:17:20 +0700 Subject: [PATCH 04/23] fix(ci,dsp): use CTest -C and skip inactive biquad stages at runtime --- .github/workflows/dsp.yml | 2 +- Source/DSP/ParametricEQ.h | 21 ++++++++++++++++++--- Source/PluginProcessor.cpp | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dsp.yml b/.github/workflows/dsp.yml index 7a3a317..466ee0f 100644 --- a/.github/workflows/dsp.yml +++ b/.github/workflows/dsp.yml @@ -22,4 +22,4 @@ jobs: - name: Build run: cmake --build build --config Release --parallel 2 - name: Test - run: ctest --test-dir build --config Release --output-on-failure + run: ctest --test-dir build -C Release --output-on-failure diff --git a/Source/DSP/ParametricEQ.h b/Source/DSP/ParametricEQ.h index 94710b5..19d9d48 100644 --- a/Source/DSP/ParametricEQ.h +++ b/Source/DSP/ParametricEQ.h @@ -128,6 +128,7 @@ class Engine { slot.current=slot.target=makeStages(slot.band,sampleRate_); slot.remaining=0; slot.active=slot.band.enabled; + slot.stages=configuredStages(slot.band); } } double sampleRate() const noexcept { return sampleRate_; } @@ -143,6 +144,7 @@ class Engine { auto& slot=slots_[static_cast(index)]; if (same(slot.band,value)) return false; slot.band=value; + slot.stages=std::max(slot.stages,configuredStages(value)); slot.target=makeStages(value,sampleRate_); slot.remaining=std::max(1,static_cast(std::ceil(sampleRate_*0.008))); slot.active=true; // keep processing during smooth disable transition @@ -153,6 +155,7 @@ class Engine { slot.state={}; slot.current=slot.target=makeStages(slot.band,sampleRate_); slot.remaining=0;slot.active=slot.band.enabled; + slot.stages=configuredStages(slot.band); } } // Called once per stereo sample: no allocations, no transcendental math. @@ -212,24 +215,36 @@ class Engine { std::array current{},target{}; std::array,2> state{}; int remaining=0; + int stages=0; bool active=false; }; + static int configuredStages(const Band& b) noexcept { + if (!b.enabled) return 0; + return b.type==Type::LowCut || b.type==Type::HighCut ? stageCount(b.slope) : 1; + } static bool valid(int index) noexcept { return index>=0 && index(s.remaining); - for (int i=0;i(i)]; const auto& t=s.target[static_cast(i)]; c.b0+=(t.b0-c.b0)/r; c.b1+=(t.b1-c.b1)/r; c.b2+=(t.b2-c.b2)/r; c.a1+=(t.a1-c.a1)/r; c.a2+=(t.a2-c.a2)/r; } --s.remaining; - if (s.remaining==0 && !s.band.enabled) { s.active=false;s.state={}; } + if (s.remaining==0) { + const int next=configuredStages(s.band); + for (int lane=0;lane<2;++lane) + for(int i=next;i(lane)][static_cast(i)]={}; + s.stages=next; + if (!s.band.enabled) { s.active=false;s.state={}; } + } } static double filter(Slot& s, double input, int lane) noexcept { auto value=input; - for (int i=0;i(i)]; auto& z=s.state[static_cast(lane)][static_cast(i)]; const auto out=c.b0*value+z.z1; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 93ce65f..5710f43 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -103,7 +103,7 @@ void ArSonEQAudioProcessor::getStateInformation(juce::MemoryBlock& destination) } void ArSonEQAudioProcessor::setStateInformation(const void* data,int size) { if (auto xml=getXmlFromBinary(data,size)) { - if (xml->hasTagName(parameters.state.getType())) + if (xml->hasTagName(parameters.state.getType().toString())) parameters.replaceState(juce::ValueTree::fromXml(*xml)); } } From 4d87fb78c78ad92ecf1bb098b272156e5add2b8b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:18:18 +0700 Subject: [PATCH 05/23] ci: one targeted Windows Release VST3 compile and test-only artifact --- .github/workflows/vst3-windows.yml | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/vst3-windows.yml diff --git a/.github/workflows/vst3-windows.yml b/.github/workflows/vst3-windows.yml new file mode 100644 index 0000000..2761595 --- /dev/null +++ b/.github/workflows/vst3-windows.yml @@ -0,0 +1,31 @@ +name: Windows VST3 build +on: + pull_request: + paths: + - "Source/Plugin**" + - "Source/DSP/**" + - "CMakeLists.txt" + - ".github/workflows/vst3-windows.yml" + workflow_dispatch: +permissions: + contents: read +concurrency: + group: vst3-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + vst3: + runs-on: windows-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Configure pinned JUCE 9.0.4 VST3 + run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=OFF + - name: Compile Release VST3 + run: cmake --build build-vst --config Release --target ArSonEQ_VST3 --parallel 2 + - name: Publish test-only plugin artifact + uses: actions/upload-artifact@v4 + with: + name: ArSonEQ-Windows-x64-VST3-UNVALIDATED + path: build-vst/ArSonEQ_artefacts/Release/VST3/ + if-no-files-found: error + retention-days: 7 From 2226397c4241adbc8a3c83410318ea6ea5c33cd0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:19:32 +0700 Subject: [PATCH 06/23] fix(build): enable C language required by JUCE 9 configuration --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74250d0..fd395bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.24) -project(ArSonEQ VERSION 0.1.0 LANGUAGES CXX) +project(ArSonEQ VERSION 0.1.0 LANGUAGES C CXX) option(ARSONEQ_BUILD_PLUGIN "Build VST3 plugin using JUCE" OFF) option(ARSONEQ_BUILD_TESTS "Build standalone DSP unit tests" ON) From 71693ae35896990168432068a19679ff29a147d8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 18:59:23 +0700 Subject: [PATCH 07/23] feat(M1.5): real-time safe topology fades and cached stereo FFT analyzer --- .github/workflows/dsp.yml | 19 +- .github/workflows/vst3-windows.yml | 20 +- CMakeLists.txt | 7 + README.md | 7 + Source/DSP/AnalyzerQueue.h | 42 ++++ Source/DSP/ParametricEQ.h | 318 +++++++++++++++++++---------- Source/PluginEditor.cpp | 126 ++++++++++-- Source/PluginEditor.h | 18 +- Source/PluginProcessor.cpp | 11 +- Source/PluginProcessor.h | 3 + docs/ARD.md | 15 ++ docs/ROADMAP.md | 10 + tests/eq_analyzer_tests.cpp | 50 +++++ tests/eq_rt_tests.cpp | 161 +++++++++++++++ 14 files changed, 662 insertions(+), 145 deletions(-) create mode 100644 Source/DSP/AnalyzerQueue.h create mode 100644 tests/eq_analyzer_tests.cpp create mode 100644 tests/eq_rt_tests.cpp diff --git a/.github/workflows/dsp.yml b/.github/workflows/dsp.yml index 466ee0f..e6b9246 100644 --- a/.github/workflows/dsp.yml +++ b/.github/workflows/dsp.yml @@ -1,4 +1,4 @@ -name: Fast DSP checks +name: Fast headless DSP checks on: pull_request: paths: @@ -9,17 +9,18 @@ on: workflow_dispatch: permissions: contents: read +concurrency: + group: dsp-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: - dsp: - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} + dsp-linux: + runs-on: ubuntu-latest + timeout-minutes: 8 steps: - uses: actions/checkout@v4 - - name: Configure standalone core + - name: Configure native core (no JUCE download) run: cmake -S . -B build -DARSONEQ_BUILD_PLUGIN=OFF -DARSONEQ_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release - - name: Build + - name: Compile native tests run: cmake --build build --config Release --parallel 2 - - name: Test + - name: Test DSP, transitions, analyzer queue run: ctest --test-dir build -C Release --output-on-failure diff --git a/.github/workflows/vst3-windows.yml b/.github/workflows/vst3-windows.yml index 2761595..79f4807 100644 --- a/.github/workflows/vst3-windows.yml +++ b/.github/workflows/vst3-windows.yml @@ -1,9 +1,9 @@ -name: Windows VST3 build +name: Windows VST3 build + native tests on: pull_request: paths: - - "Source/Plugin**" - - "Source/DSP/**" + - "Source/**" + - "tests/**" - "CMakeLists.txt" - ".github/workflows/vst3-windows.yml" workflow_dispatch: @@ -18,14 +18,16 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - name: Configure pinned JUCE 9.0.4 VST3 - run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=OFF - - name: Compile Release VST3 - run: cmake --build build-vst --config Release --target ArSonEQ_VST3 --parallel 2 - - name: Publish test-only plugin artifact + - name: Configure pinned JUCE and headless tests + run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=ON + - name: Compile Release VST3 and tests + run: cmake --build build-vst --config Release --target ArSonEQ_VST3 arson_eq_core_tests arson_eq_rt_tests arson_eq_analyzer_tests --parallel 2 + - name: Verify native tests on Windows + run: ctest --test-dir build-vst -C Release --output-on-failure + - name: Publish test-only VST3 uses: actions/upload-artifact@v4 with: - name: ArSonEQ-Windows-x64-VST3-UNVALIDATED + name: ArSonEQ-M1-5-Windows-x64-VST3-TEST path: build-vst/ArSonEQ_artefacts/Release/VST3/ if-no-files-found: error retention-days: 7 diff --git a/CMakeLists.txt b/CMakeLists.txt index fd395bc..bcdbdc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,13 @@ if(ARSONEQ_BUILD_TESTS) target_compile_options(arson_eq_core_tests PRIVATE -Wall -Wextra -Wpedantic) endif() add_test(NAME arson_eq_core COMMAND arson_eq_core_tests) + add_executable(arson_eq_rt_tests tests/eq_rt_tests.cpp) + target_link_libraries(arson_eq_rt_tests PRIVATE arson_eq_dsp) + add_test(NAME arson_eq_rt COMMAND arson_eq_rt_tests) + find_package(Threads REQUIRED) + add_executable(arson_eq_analyzer_tests tests/eq_analyzer_tests.cpp) + target_link_libraries(arson_eq_analyzer_tests PRIVATE arson_eq_dsp Threads::Threads) + add_test(NAME arson_eq_analyzer COMMAND arson_eq_analyzer_tests) endif() if(ARSONEQ_BUILD_PLUGIN) diff --git a/README.md b/README.md index 60e8c89..12b49f9 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,10 @@ The initial reference is [MaSonKuPik](https://github.com/masarray/masonkupik), a This repository already uses **AGPL-3.0** (see LICENSE). JUCE 9 modules are offered under AGPLv3 or separate commercial terms. This project uses the AGPL path for the open-source edition. **A commercial JUCE licence may be required** for a future proprietary/closed-source edition. Steinberg VST 3 SDK 3.8+ is MIT-licensed; trademark requirements are separate. Verify all third-party dependencies and source provenance before redistribution. FabFilter and Pro-Q are trademarks of their respective owner, which is not affiliated with ArSonEQ. There is no FabFilter intellectual property or GUI artwork in this repository. + + +## Native DSP / analyzer milestone + +The M1.5 upgrade uses preallocated dual-path crossfades for discrete filter topology, route and enabled changes. Continuous gain/frequency/Q movements use coefficient smoothing. A zero-latency minimum-phase DSP path remains the only implemented phase mode. A single-producer/single-consumer telemetry queue feeds two 4,096-point FFTs (input and output) on the editor thread, without FFT execution in the audio callback. UI transfer curves reflect L/R/M/S routing via a matrix calculation and are cached until parameters or geometry change. + +New headless checks include dynamic transitions, algebraic-vs-measured response, heap-allocation checks in DSP processing, and SPSC thread safety. This is **not** certification of click-free behavior on every host or of low-CPU targets: host testing, CPU profiles, pluginval and independent DAW testing remain necessary before release. diff --git a/Source/DSP/AnalyzerQueue.h b/Source/DSP/AnalyzerQueue.h new file mode 100644 index 0000000..95d2b7f --- /dev/null +++ b/Source/DSP/AnalyzerQueue.h @@ -0,0 +1,42 @@ +// Single-producer audio-thread / single-consumer editor-thread telemetry. +// Never blocks or allocates on the real-time thread. Old frames are dropped +// when the editor falls behind; audio processing is never delayed. +#pragma once +#include +#include +#include + +namespace arson::eq { +struct MeterFrame { float before=0.0f, after=0.0f; }; +class AnalyzerQueue { +public: + static constexpr uint32_t capacity=16384; + void setEnabled(bool value) noexcept { + enabled_.store(value,std::memory_order_release); + } + bool isEnabled() const noexcept { + return enabled_.load(std::memory_order_acquire); + } + bool push(float before,float after) noexcept { + const auto write=write_.load(std::memory_order_relaxed); + if(write-read_.load(std::memory_order_acquire)>=capacity) + return false; + frames_[write & (capacity-1)]={before,after}; + write_.store(write+1,std::memory_order_release); + return true; + } + bool pop(MeterFrame& sample) noexcept { + const auto read=read_.load(std::memory_order_relaxed); + if(read==write_.load(std::memory_order_acquire)) return false; + sample=frames_[read & (capacity-1)]; + read_.store(read+1,std::memory_order_release); + return true; + } +private: + static_assert((capacity & (capacity-1))==0,"power-of-two ring"); + std::array frames_{}; + std::atomic write_{0}; + std::atomic read_{0}; + std::atomic enabled_{false}; +}; +} // namespace arson::eq diff --git a/Source/DSP/ParametricEQ.h b/Source/DSP/ParametricEQ.h index 19d9d48..e389557 100644 --- a/Source/DSP/ParametricEQ.h +++ b/Source/DSP/ParametricEQ.h @@ -118,148 +118,250 @@ inline double magnitudeDb(const Coeff& c, double freq, double sr) noexcept { return 20.0*std::log10(std::max(std::abs(num)/std::max(std::abs(den),1e-20),1e-20)); } + +struct StereoMatrix { + std::complex ll{1.0,0.0}, lr{0.0,0.0}; + std::complex rl{0.0,0.0}, rr{1.0,0.0}; +}; + class Engine { public: void prepare(double rate) noexcept { - sampleRate_ = finiteClamp(rate,48000.0,8000.0,384000.0); - for (int i=0;i(i)]; - slot.state={}; - slot.current=slot.target=makeStages(slot.band,sampleRate_); - slot.remaining=0; - slot.active=slot.band.enabled; - slot.stages=configuredStages(slot.band); + sampleRate_ = finiteClamp(rate, 48000.0, 8000.0, 384000.0); + for (auto& s : slots_) { + s.primary = makePath(s.requested); + s.secondary = {}; + s.fadeRemaining = 0; + s.fadeLength = 0; } } double sampleRate() const noexcept { return sampleRate_; } - Band band(int index) const noexcept { return valid(index) ? slots_[static_cast(index)].band : Band{}; } + Band band(int index) const noexcept { + return valid(index) ? slots_[static_cast(index)].requested : Band{}; + } bool setBand(int index, Band value) noexcept { if (!valid(index)) return false; - value.frequency=finiteClamp(value.frequency,1000.0,20.0,0.45*sampleRate_); - value.gainDb=finiteClamp(value.gainDb,0.0,-24.0,24.0); - value.q=finiteClamp(value.q,1.0,0.1,24.0); - value.slope=stageCount(value.slope)*12; - if (static_cast(value.type)<0 || static_cast(value.type)>5) value.type=Type::Bell; - if (static_cast(value.route)<0 || static_cast(value.route)>4) value.route=Route::Stereo; - auto& slot=slots_[static_cast(index)]; - if (same(slot.band,value)) return false; - slot.band=value; - slot.stages=std::max(slot.stages,configuredStages(value)); - slot.target=makeStages(value,sampleRate_); - slot.remaining=std::max(1,static_cast(std::ceil(sampleRate_*0.008))); - slot.active=true; // keep processing during smooth disable transition + value.frequency = finiteClamp(value.frequency, 1000.0, 20.0, 0.45 * sampleRate_); + value.gainDb = finiteClamp(value.gainDb, 0.0, -24.0, 24.0); + value.q = finiteClamp(value.q, 1.0, 0.1, 24.0); + value.slope = stageCount(value.slope) * 12; + if (static_cast(value.type) < 0 || static_cast(value.type) > 5) + value.type = Type::Bell; + if (static_cast(value.route) < 0 || static_cast(value.route) > 4) + value.route = Route::Stereo; + auto& s = slots_[static_cast(index)]; + if (same(s.requested, value)) return false; + s.requested = value; + // During a topology crossfade, keep BOTH live branches untouched. + // Only the latest request is queued; the next change starts after fade. + // Restarting fades midway creates sharp discontinuities on automation. + if (s.fadeRemaining == 0) apply(s, value); return true; } - void reset() noexcept { - for (auto& slot:slots_) { - slot.state={}; - slot.current=slot.target=makeStages(slot.band,sampleRate_); - slot.remaining=0;slot.active=slot.band.enabled; - slot.stages=configuredStages(slot.band); - } - } - // Called once per stereo sample: no allocations, no transcendental math. + void reset() noexcept { prepare(sampleRate_); } void process(double& left, double& right) noexcept { - for (auto& slot:slots_) { - if (!slot.active) continue; - advance(slot); - switch (slot.band.route) { - case Route::Stereo: left=filter(slot,left,0);right=filter(slot,right,1);break; - case Route::Left: left=filter(slot,left,0);break; - case Route::Right: right=filter(slot,right,1);break; - case Route::Mid: { - const auto mid=0.5*(left+right); - const auto d=filter(slot,mid,0)-mid; - left+=d;right+=d;break; - } - case Route::Side: { - const auto side=0.5*(left-right); - const auto d=filter(slot,side,0)-side; - left+=d;right-=d;break; - } + for (auto& s : slots_) { + if (s.fadeRemaining == 0) { + if (!s.primary.band.enabled) continue; + processStereoPath(s.primary, left, right); + } else { + const double inL=left,inR=right; + double oldL=inL,oldR=inR,newL=inL,newR=inR; + if (s.primary.band.enabled) processStereoPath(s.primary,oldL,oldR); + if (s.secondary.band.enabled) processStereoPath(s.secondary,newL,newR); + const double t=1.0-static_cast(s.fadeRemaining-1)/s.fadeLength; + const double smooth=t*t*(3.0-2.0*t); + left=oldL+(newL-oldL)*smooth; + right=oldR+(newR-oldR)*smooth; + finishFade(s); } } } void processMono(double& sample) noexcept { - for (auto& slot:slots_) { - if (!slot.active) continue; - advance(slot); - if (slot.band.route==Route::Right || slot.band.route==Route::Side) continue; - sample=filter(slot,sample,0); + for (auto& s : slots_) { + if (s.fadeRemaining == 0) { + if (s.primary.band.enabled) processMonoPath(s.primary,sample); + } else { + double oldValue=sample,newValue=sample; + if (s.primary.band.enabled) processMonoPath(s.primary,oldValue); + if (s.secondary.band.enabled) processMonoPath(s.secondary,newValue); + const double t=1.0-static_cast(s.fadeRemaining-1)/s.fadeLength; + const double smooth=t*t*(3.0-2.0*t); + sample=oldValue+(newValue-oldValue)*smooth; + finishFade(s); + } } } - // Exact steady-state transfer for a single selected band (not temporal smoothing). double bandResponseDb(int index, double frequency) const noexcept { - if (!valid(index) || !slots_[static_cast(index)].band.enabled) return 0.0; - const auto& s=slots_[static_cast(index)]; - const auto coeff=makeStages(s.band,sampleRate_); - double db=0; - for (const auto& c:coeff) db+=magnitudeDb(c,frequency,sampleRate_); + if (!valid(index)) return 0.0; + const Band b=slots_[static_cast(index)].requested; + if (!b.enabled) return 0.0; + const auto coeff=makeStages(b,sampleRate_); + const auto count=stageCountFor(b); + double db=0.0; + for (int i=0;i(i)],frequency,sampleRate_); return db; } - // Useful for a stereo EQ curve. Mid/Side/one-channel responses are exposed - // separately through bandResponseDb and must not be misrepresented as a - // single universal L/R curve. + // The actual steady-state 2x2 matrix includes crossfeed from M/S. + // A graph showing only stereo-routed bands would conceal active filters. + StereoMatrix matrixResponse(double frequency) const noexcept { + StereoMatrix total; + if (!std::isfinite(frequency) || frequency<=0.0 || frequency>=sampleRate_*0.5) + return total; + for (const auto& slot : slots_) { + const Band b=slot.requested; + if (!b.enabled) continue; + std::complex h{1.0,0.0}; + const auto stages=makeStages(b,sampleRate_); + const auto z=std::polar(1.0,-2.0*kPi*frequency/sampleRate_); + const auto z2=z*z; + for(int k=0;k(k)]; + const auto numerator=c.b0+c.b1*z+c.b2*z2; + const auto denominator=1.0+c.a1*z+c.a2*z2; + h*=numerator/denominator; + } + StereoMatrix f; + const auto one=std::complex(1.0,0.0); + switch (b.route) { + case Route::Stereo: f.ll=h; f.rr=h; break; + case Route::Left: f.ll=h; break; + case Route::Right: f.rr=h; break; + case Route::Mid: + f.ll=(h+one)*0.5;f.rr=f.ll; + f.lr=(h-one)*0.5;f.rl=f.lr;break; + case Route::Side: + f.ll=(h+one)*0.5;f.rr=f.ll; + f.lr=(one-h)*0.5;f.rl=f.lr;break; + } + StereoMatrix next; + next.ll=f.ll*total.ll+f.lr*total.rl; + next.lr=f.ll*total.lr+f.lr*total.rr; + next.rl=f.rl*total.ll+f.rr*total.rl; + next.rr=f.rl*total.lr+f.rr*total.rr; + total=next; + } + return total; + } + // Graph target: diagonal feed responses L->L and R->R. + // Nonzero lr/rl should be visualised separately as stereo crossfeed. + std::array channelResponseDb(double frequency) const noexcept { + const auto m=matrixResponse(frequency); + const auto toDb=[](const std::complex& z) noexcept { + return 20.0*std::log10(std::max(std::abs(z),1e-20)); + }; + return {toDb(m.ll),toDb(m.rr)}; + } double stereoResponseDb(double frequency) const noexcept { - double db=0; - for (int i=0;i(i)].band.enabled - && slots_[static_cast(i)].band.route==Route::Stereo) - db+=bandResponseDb(i,frequency); - return db; + const auto r=channelResponseDb(frequency); + return (r[0]+r[1])*0.5; } private: - struct State { double z1=0,z2=0; }; - struct Slot { + struct State { double z1=0.0,z2=0.0; }; + struct Path { Band band{}; - std::array current{},target{}; + std::array coefficients{}; + std::array target{}; std::array,2> state{}; - int remaining=0; int stages=0; - bool active=false; + int morphRemaining=0; + }; + struct Slot { + Band requested{}; + Path primary{},secondary{}; + int fadeRemaining=0,fadeLength=0; }; - static int configuredStages(const Band& b) noexcept { - if (!b.enabled) return 0; - return b.type==Type::LowCut || b.type==Type::HighCut ? stageCount(b.slope) : 1; - } static bool valid(int index) noexcept { return index>=0 && index(s.remaining); - for (int i=0;i(i)]; - const auto& t=s.target[static_cast(i)]; - c.b0+=(t.b0-c.b0)/r; c.b1+=(t.b1-c.b1)/r; - c.b2+=(t.b2-c.b2)/r; c.a1+=(t.a1-c.a1)/r; c.a2+=(t.a2-c.a2)/r; + static int stageCountFor(const Band& b) noexcept { + if(!b.enabled) return 0; + return b.type==Type::LowCut || b.type==Type::HighCut ? stageCount(b.slope):1; + } + static bool sameTopology(const Band& a,const Band& b) noexcept { + return a.enabled==b.enabled && a.type==b.type + && a.route==b.route && stageCountFor(a)==stageCountFor(b); + } + Path makePath(const Band& b) const noexcept { + Path p; + p.band=b; + p.stages=stageCountFor(b); + p.coefficients=p.target=makeStages(b,sampleRate_); + return p; + } + void apply(Slot& s,const Band& value) noexcept { + if (sameTopology(s.primary.band,value)) { + s.primary.band=value; + if (value.enabled) { + s.primary.target=makeStages(value,sampleRate_); + s.primary.morphRemaining=std::max(1,static_cast(sampleRate_*0.012)); + } + return; } - --s.remaining; - if (s.remaining==0) { - const int next=configuredStages(s.band); - for (int lane=0;lane<2;++lane) - for(int i=next;i(lane)][static_cast(i)]={}; - s.stages=next; - if (!s.band.enabled) { s.active=false;s.state={}; } + // Only topology changes run two paths. This also smooths bypass, + // hard cut-slope switches and L/R/M/S routing changes. + s.secondary=makePath(value); + s.fadeLength=std::max(1,static_cast(sampleRate_*0.010)); + s.fadeRemaining=s.fadeLength; + } + void finishFade(Slot& s) noexcept { + if (--s.fadeRemaining!=0) return; + s.primary=s.secondary; + s.secondary={}; + if (!same(s.requested,s.primary.band)) + apply(s,s.requested); + } + static void advance(Path& p) noexcept { + if(p.morphRemaining==0) return; + const double remain=static_cast(p.morphRemaining); + for(int i=0;i(i)]; + const auto& t=p.target[static_cast(i)]; + c.b0+=(t.b0-c.b0)/remain;c.b1+=(t.b1-c.b1)/remain; + c.b2+=(t.b2-c.b2)/remain;c.a1+=(t.a1-c.a1)/remain; + c.a2+=(t.a2-c.a2)/remain; } + --p.morphRemaining; } - static double filter(Slot& s, double input, int lane) noexcept { - auto value=input; - for (int i=0;i(i)]; - auto& z=s.state[static_cast(lane)][static_cast(i)]; - const auto out=c.b0*value+z.z1; - const auto next1=c.b1*value-c.a1*out+z.z2; - const auto next2=c.b2*value-c.a2*out; - if (!std::isfinite(out) || !std::isfinite(next1) || !std::isfinite(next2)) { - z={};value=0.0; + static double filter(Path& p,double sample,int lane) noexcept { + double x=sample; + for(int i=0;i(i)]; + auto& z=p.state[static_cast(lane)][static_cast(i)]; + const double y=c.b0*x+z.z1; + const double z1=c.b1*x-c.a1*y+z.z2; + const double z2=c.b2*x-c.a2*y; + if(!std::isfinite(y)||!std::isfinite(z1)||!std::isfinite(z2)) { + z={};x=0.0; } else { - // Prevent long-lived denormals on silence without extra allocation. - z.z1=std::abs(next1)<1e-24 ? 0.0 : next1; - z.z2=std::abs(next2)<1e-24 ? 0.0 : next2; - value=out; + z.z1=std::abs(z1)<1e-24?0.0:z1; + z.z2=std::abs(z2)<1e-24?0.0:z2; + x=y; } } - return value; + return x; + } + static void processStereoPath(Path& p,double& l,double& r) noexcept { + advance(p); + switch(p.band.route) { + case Route::Stereo: l=filter(p,l,0);r=filter(p,r,1);break; + case Route::Left: l=filter(p,l,0);break; + case Route::Right: r=filter(p,r,1);break; + case Route::Mid: { + const auto mid=(l+r)*0.5; + const auto delta=filter(p,mid,0)-mid; + l+=delta;r+=delta;break; + } + case Route::Side: { + const auto side=(l-r)*0.5; + const auto delta=filter(p,side,0)-side; + l+=delta;r-=delta;break; + } + } + } + static void processMonoPath(Path& p,double& x) noexcept { + advance(p); + if(p.band.route!=Route::Right && p.band.route!=Route::Side) + x=filter(p,x,0); } double sampleRate_=48000.0; std::array slots_{}; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 353a864..0a664ee 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -10,16 +10,28 @@ constexpr const char* typeNames[]{"Bell","Low Sh","High Sh","Low Cut","High Cut" constexpr const char* routeNames[]{"Stereo","L","R","Mid","Side"}; } ArSonEQEditor::ArSonEQEditor(ArSonEQAudioProcessor& owner) - : juce::AudioProcessorEditor(owner),processor_(owner) { + : juce::AudioProcessorEditor(owner),processor_(owner),fft_(fftOrder_) { setResizable(true,true); setResizeLimits(680,420,1440,900); + graphEngine_.prepare(processor_.configuredSampleRate()); + for(int i=0;i(i)] = 0.5f*(1.0f-std::cos( + 2.0f*juce::MathConstants::pi*i/(fftSize_-1))); + levelsPre_.fill(-108.0f); + levelsPost_.fill(-108.0f); setSize(930,570); setWantsKeyboardFocus(true); - graphEngine_.prepare(processor_.configuredSampleRate()); - // Repaints only on parameter changes; never animates idle hover or FFT. - startTimerHz(20); + processor_.analyzer().setEnabled(true); + startTimerHz(30); timerCallback(); } +ArSonEQEditor::~ArSonEQEditor() { + stopTimer(); + processor_.analyzer().setEnabled(false); +} +void ArSonEQEditor::resized() { + rebuildResponseCurves(); +} juce::Rectangle ArSonEQEditor::graph() const { return juce::Rectangle(48.f,73.f, static_cast(getWidth())-76.f,static_cast(getHeight())-215.f); @@ -56,7 +68,91 @@ void ArSonEQEditor::timerCallback() { changed=true; } } - if(changed) repaint(); + if(changed) rebuildResponseCurves(); + updateSpectrum(); + if(changed || spectrumReady_) repaint(); +} +void ArSonEQEditor::rebuildResponseCurves() { + curveLeft_.clear(); + curveRight_.clear(); + curveCrossfeed_.clear(); + const auto r=graph(); + if(r.getWidth()<=0.0f || r.getHeight()<=0.0f) return; + const int points=std::min(420,std::max(120,static_cast(r.getWidth()/2))); + for(int i=0;i<=points;++i) { + const auto x=r.getX()+r.getWidth()*static_cast(i)/points; + const auto matrix=graphEngine_.matrixResponse(hzForX(x)); + const auto db=[](const std::complex& v) { + return 20.0*std::log10(std::max(std::abs(v),1e-20)); + }; + const auto yL=yForDb(db(matrix.ll)); + const auto yR=yForDb(db(matrix.rr)); + const auto cross=yForDb(db(matrix.lr)); + if(i==0) { + curveLeft_.startNewSubPath(x,yL); + curveRight_.startNewSubPath(x,yR); + curveCrossfeed_.startNewSubPath(x,cross); + } else { + curveLeft_.lineTo(x,yL); + curveRight_.lineTo(x,yR); + curveCrossfeed_.lineTo(x,cross); + } + } +} +void ArSonEQEditor::updateSpectrum() { + arson::eq::MeterFrame frame; + bool got=false; + int drained=0; + while(drained(i))&(fftSize_-1); + const size_t idx=static_cast(i); + fftPre_[idx]=preHistory_[pos]*window_[idx]; + fftPost_[idx]=postHistory_[pos]*window_[idx]; + } + fft_.performFrequencyOnlyForwardTransform(fftPre_.data()); + fft_.performFrequencyOnlyForwardTransform(fftPost_.data()); + constexpr float normalization=4.0f/fftSize_; + for(int i=0;i<=fftSize_/2;++i) { + const size_t k=static_cast(i); + const auto a=20.0f*std::log10(std::max(fftPre_[k]*normalization,1e-8f)); + const auto b=20.0f*std::log10(std::max(fftPost_[k]*normalization,1e-8f)); + levelsPre_[k]=0.75f*levelsPre_[k]+0.25f*std::clamp(a,-108.0f,0.0f); + levelsPost_[k]=0.75f*levelsPost_[k]+0.25f*std::clamp(b,-108.0f,0.0f); + } + spectrumReady_=true; +} +void ArSonEQEditor::drawSpectrum(juce::Graphics& g,juce::Rectangle r) { + if(!spectrumReady_) return; + const double sr=processor_.configuredSampleRate(); + juce::Path pre,post; + constexpr int points=320; + for(int i=0;i<=points;++i) { + const auto x=r.getX()+r.getWidth()*static_cast(i)/points; + const auto f=hzForX(x); + const auto bin=std::clamp(static_cast(std::lround(f*fftSize_/sr)),1,fftSize_/2); + const auto yForLevel=[&](float level) { + return r.getBottom() - std::clamp((level+108.0f)/96.0f,0.0f,1.0f) + *r.getHeight(); + }; + const auto a=yForLevel(levelsPre_[static_cast(bin)]); + const auto b=yForLevel(levelsPost_[static_cast(bin)]); + if(i==0){ pre.startNewSubPath(x,a);post.startNewSubPath(x,b); } + else { pre.lineTo(x,a);post.lineTo(x,b); } + } + g.setColour(juce::Colour(0xff708092).withAlpha(0.42f)); + g.strokePath(pre,juce::PathStrokeType(1.0f)); + g.setColour(juce::Colour(0xff5db8b2).withAlpha(0.55f)); + g.strokePath(post,juce::PathStrokeType(1.15f)); } void ArSonEQEditor::paint(juce::Graphics& g) { g.fillAll(bg); @@ -86,15 +182,15 @@ void ArSonEQEditor::paint(juce::Graphics& g) { g.drawText((db>0?"+":"")+juce::String(db), juce::Rectangle(7,y-7,32,15),juce::Justification::centredRight); } - juce::Path curve; - const int points=std::min(400,std::max(120,static_cast(r.getWidth()/2))); - for(int i=0;i<=points;++i) { - const auto x=r.getX()+r.getWidth()*static_cast(i)/points; - const auto y=yForDb(graphEngine_.stereoResponseDb(hzForX(x))); - if(i==0) curve.startNewSubPath(x,y);else curve.lineTo(x,y); - } - g.setColour(accent.withAlpha(0.9f)); - g.strokePath(curve,juce::PathStrokeType(2.f)); + // Analyzer is purely visual and drains on the message thread. + // Curves are cached and rebuilt only after parameter/geometry changes. + drawSpectrum(g,r); + g.setColour(accent.withAlpha(0.95f)); + g.strokePath(curveLeft_,juce::PathStrokeType(2.f)); + g.setColour(selectedColor.withAlpha(0.82f)); + g.strokePath(curveRight_,juce::PathStrokeType(1.1f)); + g.setColour(juce::Colour(0xff8a9ba8).withAlpha(0.45f)); + g.strokePath(curveCrossfeed_,juce::PathStrokeType(0.65f)); for(int i=0;i(i)]; if(!b.enabled) continue; @@ -106,7 +202,7 @@ void ArSonEQEditor::paint(juce::Graphics& g) { if(i==selected_) { g.setColour(ink);g.drawEllipse(x-8,y-8,16,16,1.f); } } g.setColour(juce::Colour(0xff7e91a0));g.setFont(11.f); - g.drawText("Double-click: add / bypass · Drag: frequency + gain · Wheel: Q", + g.drawText("FFT: grey input / teal output · EQ: cyan L→L / gold R→R · Drag: Hz + dB", juce::Rectangle(48,getHeight()-116,getWidth()-96,22), juce::Justification::centredLeft); drawModeButtons(g); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 3b4d39d..3f89073 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -1,14 +1,15 @@ #pragma once #include +#include #include #include "PluginProcessor.h" class ArSonEQEditor final : public juce::AudioProcessorEditor, private juce::Timer { public: explicit ArSonEQEditor(ArSonEQAudioProcessor&); - ~ArSonEQEditor() override = default; + ~ArSonEQEditor() override; void paint(juce::Graphics&) override; - void resized() override {} + void resized() override; void mouseDown(const juce::MouseEvent&) override; void mouseDrag(const juce::MouseEvent&) override; void mouseUp(const juce::MouseEvent&) override; @@ -17,6 +18,9 @@ class ArSonEQEditor final : public juce::AudioProcessorEditor, private juce::Tim void mouseWheelMove(const juce::MouseEvent&,const juce::MouseWheelDetails&) override; private: void timerCallback() override; + void updateSpectrum(); + void drawSpectrum(juce::Graphics&,juce::Rectangle); + void rebuildResponseCurves(); juce::Rectangle graph() const; int hitBand(juce::Point) const; float xForHz(double) const; @@ -31,6 +35,16 @@ class ArSonEQEditor final : public juce::AudioProcessorEditor, private juce::Tim ArSonEQAudioProcessor& processor_; arson::eq::Engine graphEngine_; std::array cached_{}; + static constexpr int fftOrder_=12; + static constexpr int fftSize_=1< preHistory_{},postHistory_{},window_{}; + std::array fftPre_{},fftPost_{}; + std::array levelsPre_{},levelsPost_{}; + size_t historyPosition_=0; + uint64_t framesSeen_=0; + bool spectrumReady_=false; + juce::Path curveLeft_,curveRight_,curveCrossfeed_; int selected_=-1,dragging_=-1; bool gestureOpen_=false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQEditor) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 5710f43..98a375d 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -80,16 +80,23 @@ void ArSonEQAudioProcessor::processAudio(juce::AudioBuffer& audio) { syncBands(); const int channels=audio.getNumChannels(),frames=audio.getNumSamples(); if (channels<1) return; + const bool tap=analyzer_.isEnabled(); auto* left=audio.getWritePointer(0); if (channels==1) { for (int s=0;s(x); + double x=left[s]; + const float before=static_cast(x); + engine_.processMono(x);left[s]=static_cast(x); + if (tap) analyzer_.push(before,static_cast(x)); } } else { auto* right=audio.getWritePointer(1); for (int s=0;s(0.5*(l+r)):0.0f; + engine_.process(l,r); left[s]=static_cast(l);right[s]=static_cast(r); + if (tap) analyzer_.push(before,static_cast(0.5*(l+r))); } for (int ch=2;ch #include #include "DSP/ParametricEQ.h" +#include "DSP/AnalyzerQueue.h" class ArSonEQAudioProcessor final : public juce::AudioProcessor { public: @@ -33,6 +34,7 @@ class ArSonEQAudioProcessor final : public juce::AudioProcessor { arson::eq::Band readBand(int index) const noexcept; double configuredSampleRate() const noexcept { return preparedRate_.load(std::memory_order_relaxed); } juce::AudioProcessorValueTreeState parameters; + arson::eq::AnalyzerQueue& analyzer() noexcept { return analyzer_; } private: struct ParamRefs { @@ -49,6 +51,7 @@ class ArSonEQAudioProcessor final : public juce::AudioProcessor { template void processAudio(juce::AudioBuffer&); std::array raw_{}; arson::eq::Engine engine_; + arson::eq::AnalyzerQueue analyzer_; std::atomic preparedRate_{48000.0}; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQAudioProcessor) }; diff --git a/docs/ARD.md b/docs/ARD.md index 976f9e4..5bc50d2 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -79,3 +79,18 @@ Before shipping: run Steinberg validator, JUCE pluginval, REAPER, and a second D ## Stage gates M0: repo structure, standalone DSP, unit tests, CMake; M1: VST3 adapter, host params, graph interaction and save state; M2: audited transitions, spectrum analyzer, host validation; M3: dynamic EQ; M4: phase variants/surround/other formats. Consult [ROADMAP.md](ROADMAP.md) for binary acceptance. Avoid costly CI on unneeded toolchains until the host wrapper exists. + + +## M1.5 / early M2 engineering reconciliation (2026-10-29) + +After auditing the initial native implementation, naive coefficient interpolation was replaced for **discrete topology changes**: enabled/bypass, filter shape, route and number of stages now use two fixed preallocated processing paths, a 10ms smoothstep crossfade and bounded last-request-wins pending transitions. This avoids changing the same path's topology/state instantly or restarting an unfinished transition. Topology crossfades cost extra CPU **only while a change is in progress**, and never introduce latency. Frequency/Q/gain updates retain stable-coefficient interpolation over 12ms on the active path. All work is performed with fixed storage and no heap operations on the callback. + +**Limitations:** exact pop/click-free behavior still requires listening and more stringent amplitude-difference stress tests with external hosts; high-rate topology automation can defer the most recent request by the remaining crossfade duration. For 24 automated bands all changing simultaneously, two-path execution increases CPU temporarily. This must be benchmarked at small buffers; it is not yet a measured CPU guarantee. + +The analyzer uses a fixed 16,384-frame SPSC ring of {pre-mono, post-mono} samples, with release/acquire indexed ownership. The audio thread only pushes when an editor is open; on overflow telemetry frames are dropped rather than delaying audio. The editor consumes on a 30Hz timer, computes Hann-windowed 4,096-point pre/post FFTs on the message thread, and draws both behind the EQ curve. FFT size limits low-frequency resolution (~11.7Hz per bin at 48kHz); future analyzer iterations can use lower-frequency multiresolution windows if CPU budget permits. The audio path does **not** invoke the FFT. + +The graph caches a 2x2 complex transfer matrix for the full cascade, including L/R/M/S and crossfeed. UI plots diagonal L<-L and R<-R responses and a subdued crossfeed line, recomputing only when EQ parameters, sample rate or editor geometry changes. This is a more accurate representation than the initial stereo-only approximate graph. It does not claim to equal a measured music-spectrum FFT or FabFilter's proprietary phase algorithms. + +The fixed APVTS parameter IDs remain unchanged. The project now tests single-thread finite/RT stress, measured sine gain against the analytic curve, switch continuity, no heap allocations during process, ring buffer overflow and concurrent producer-consumer integrity. + +CI efficiency: one small Linux headless job and one Windows VST3 job that also runs the headless tests; avoid a duplicate Windows headless matrix. CI begins only after a coherent multi-file milestone commit, not after each individual edit. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 601ad57..12abe2f 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -20,3 +20,13 @@ All contributors and parallel ChatGPT threads must read PRD + ARD + this file ** 4. Do not copy third-party proprietary GUI artwork, trademarks, presets or algorithms. 5. CI budget: fast headless DSP checks on each PR, heavy platform/plugin builds only on meaningful PR/controlled dispatch; cache dependencies where viable. 6. Make precise claims: **Designed**, **Implemented**, **Compiled**, **Validated in DAW** are different statuses. + + +### M1.5+Early M2 integrated milestone (2026-10-29) + +- **Implemented:** preallocated dual paths for topology changes, 10ms fades, deferred pending topology updates, 12ms continuous parameter smoothing; unchanged 24-slot host parameter contract. +- **Implemented:** actual L/R transfer matrix including M/S crossfeed, cached frequency response UI, 4,096 point dual pre/post FFT and lock-free bounded telemetry queue. +- **Added acceptance tests:** analytic vs measured frequency response, high-frequency automation/topology stress, audio-path allocation tracking, SPSC concurrency and capacity overflow. +- **CI policy:** headless Linux + combined Windows plugin/native tests. Do not rerun unrelated workflows. Note that Windows VST3 compilation is **not** a DAW validation. +- **Next release blockers:** host VST3 validation (pluginval/Steinberg validator), REAPER and a second DAW load/state/automation testing, click/noise golden captures, CPU profiling at 32/64/128 buffers, independent review of sample-rate change lifecycle. +- **Next user features:** coherent band inspector and numeric editing, A/B, undo; dynamic EQ with proper envelope and sidechain only after the real-time foundation is validated. diff --git a/tests/eq_analyzer_tests.cpp b/tests/eq_analyzer_tests.cpp new file mode 100644 index 0000000..00b9059 --- /dev/null +++ b/tests/eq_analyzer_tests.cpp @@ -0,0 +1,50 @@ +#include "../Source/DSP/AnalyzerQueue.h" +#include +#include +#include +#include +using namespace arson::eq; +static void require(bool ok,const char* msg) { + if(!ok){std::fprintf(stderr,"FAILED: %s\n",msg);std::exit(1);} +} +int main() { + AnalyzerQueue ring; + MeterFrame frame; + for(uint32_t i=0;i(i),-static_cast(i)),"buffer accepts capacity"); + require(!ring.push(777.f,-777.f),"full ring drops telemetry"); + for(uint32_t i=0;i(i) && frame.after==-frame.before,"FIFO ordered pairs"); + } + require(!ring.pop(frame),"empty returns false"); + constexpr int N=300000; + std::atomic finished{false}; + std::atomic pushed{0}; + std::thread producer([&] { + for(int i=0;i(i),-static_cast(i))) + pushed.fetch_add(1,std::memory_order_relaxed); + finished.store(true,std::memory_order_release); + }); + int consumed=0,previous=-1; + while(true) { + if(!ring.pop(frame)) { + if(finished.load(std::memory_order_acquire)) break; + std::this_thread::yield();continue; + } + const int index=static_cast(frame.before); + require(index>previous,"SPSC increasing order (dropped frames okay)"); + require(frame.after==-frame.before,"SPSC frame pair uncorrupted"); + previous=index;++consumed; + } + producer.join(); + // Above loop may have consumed one frame inside its condition; verify no residual. + while(ring.pop(frame)) { + require(static_cast(frame.before)>previous,"tail ordering"); + previous=static_cast(frame.before); + ++consumed; + } + require(consumed>0,"consumer receives samples"); + std::printf("SPSC received %d / %d frames (non-blocking drop allowed)\n",consumed,N); +} diff --git a/tests/eq_rt_tests.cpp b/tests/eq_rt_tests.cpp new file mode 100644 index 0000000..1a1013a --- /dev/null +++ b/tests/eq_rt_tests.cpp @@ -0,0 +1,161 @@ +#include "../Source/DSP/ParametricEQ.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +static std::atomic allocationCount{0}; +void* operator new(std::size_t size) { + if(void* p=std::malloc(size)) { + allocationCount.fetch_add(1,std::memory_order_relaxed); + return p; + } + throw std::bad_alloc(); +} +void operator delete(void* p) noexcept { std::free(p); } +void operator delete(void* p,std::size_t) noexcept { std::free(p); } +void* operator new[](std::size_t n) { + if(void* p=std::malloc(n)) { + allocationCount.fetch_add(1,std::memory_order_relaxed); + return p; + } + throw std::bad_alloc(); +} +void operator delete[](void* p) noexcept { std::free(p); } +void operator delete[](void* p,std::size_t) noexcept { std::free(p); } + +using namespace arson::eq; +static void check(bool v,const char* why) { + if(!v) {std::fprintf(stderr,"FAIL: %s\n",why);std::exit(1);} +} +static void settle(Engine& e,int samples=1600) { + for(int i=0;i=n/2) { + realIn+=x*std::cos(theta);imagIn+=x*std::sin(theta); + realOut+=y*std::cos(theta);imagOut+=y*std::sin(theta); + } + } + return 20*std::log10(std::hypot(realOut,imagOut)/std::hypot(realIn,imagIn)); +} +static void responses() { + for(const auto f:{100.0,1000.0,5000.0}) { + Engine e;e.prepare(48000); + Band b;b.enabled=true;b.type=Type::Bell;b.gainDb=9; + b.frequency=f;b.q=1.6; + e.setBand(0,b); + const double measured=magnitudeAt(Type::Bell,Route::Stereo,f,f); + const double expected=e.bandResponseDb(0,f); + check(std::abs(measured-expected)<0.13,"analytic response equals steady sine response"); + } + Engine e;e.prepare(48000); + Band b;b.enabled=true;b.type=Type::Bell;b.gainDb=12;b.frequency=1500;b.q=2; + b.route=Route::Stereo;e.setBand(0,b); + auto m=e.matrixResponse(1500); + check(std::abs(m.ll-m.rr)<1e-9,"stereo L/R symmetry"); + check(std::abs(m.lr)<1e-9,"stereo no crossfeed"); + b.route=Route::Mid;e.setBand(0,b); + m=e.matrixResponse(1500); + check(std::abs(m.ll-m.rr)<1e-9,"mid balanced diagonal"); + check(std::abs(m.lr)>0.1 && std::abs(m.lr-m.rl)<1e-9,"mid crossfeed"); + const auto mid=m; + b.route=Route::Side;e.setBand(0,b); + m=e.matrixResponse(1500); + check(std::abs(mid.lr+m.lr)<1e-9,"side crossfeed opposite mid"); + // Two-bands matrix is not generally commutative; preserve DSP order. + Band a=b;a.route=Route::Left;a.gainDb=-6;a.frequency=3000; + e.setBand(1,a); + const auto m2=e.matrixResponse(1500); + check(std::abs(m2.ll-m.ll)>1e-3,"matrix cascades asymmetric L band"); +} +static void noAllocAudioPath() { + Engine e;e.prepare(48000); + std::mt19937 gen(22); + for(int i=0;i(i%6); + b.route=static_cast(i%5); + b.gainDb=static_cast(i%11)-5; + b.q=0.4+static_cast(i%7); + b.slope=(i%4+1)*12; + e.setBand(i,b); + } + const auto before=allocationCount.load(std::memory_order_relaxed); + double peak=0.0; + for(int i=0;i<64000;++i) { + double l=0.003*std::sin(2*kPi*361.0*i/48000.0); + double r=0.003*std::sin(2*kPi*739.0*i/48000.0); + if(i%53==0) { + const int id=(i/53)%kMaxBands; + auto b=e.band(id); + b.frequency=150.0+(i*47)%17250; + b.gainDb=static_cast(i%31)-15; + b.q=0.1+(i%31)*0.7; + if(i%371==0) { + b.type=static_cast((i/371)%6); + b.route=static_cast((i/371)%5); + b.enabled=((i/371)%3!=0); + b.slope=12*(1+(i/371)%4); + } + e.setBand(id,b); + } + e.process(l,r); + check(std::isfinite(l) && std::isfinite(r),"stress samples must be finite"); + peak=std::max(peak,std::max(std::abs(l),std::abs(r))); + check(peak<1e4,"stress runaway guard"); + } + const auto after=allocationCount.load(std::memory_order_relaxed); + check(before==after,"audio callback allocates no memory (24-band automation stress)"); +} +static void topologyContinuity() { + Engine e;e.prepare(48000); + Band b;b.enabled=true;b.type=Type::Bell;b.gainDb=12;b.frequency=1000; + b.q=8;b.route=Route::Stereo; + e.setBand(0,b); + constexpr double hz=997.0,amp=0.025; + double previous=0.0,maxStep=0.0; + for(int i=0;i<48000;++i) { + if(i==12000) {b.route=Route::Side;e.setBand(0,b);} + if(i==16000) {b.route=Route::Mid;e.setBand(0,b);} + if(i==20000) {b.slope=48;b.type=Type::LowCut;e.setBand(0,b);} + if(i==24000) {b.type=Type::HighCut;e.setBand(0,b);} + if(i==28000) {b.enabled=false;e.setBand(0,b);} + if(i==32000) {b.enabled=true;b.route=Route::Stereo;b.type=Type::Bell;e.setBand(0,b);} + if(i>=36000 && i<40000 && i%19==0) { + b.route=static_cast((i/19)%5); + b.type=static_cast((i/19)%6); + e.setBand(0,b); + } + double l=amp*std::sin(2*kPi*hz*i/48000.0); + double r=l; + e.process(l,r); + maxStep=std::max(maxStep,std::abs(l-previous)); + previous=l; + check(std::isfinite(l)&&std::isfinite(r),"automated topology is finite"); + } + check(maxStep<0.22,"topology change bounded sample discontinuity"); + std::printf("RT topology max adjacent step: %.7f\n",maxStep); +} +int main() { + static_assert(std::is_nothrow_move_constructible::value,"DSP no-throw"); + responses(); + topologyContinuity(); + noAllocAudioPath(); + std::puts("ArSonEQ RT/transfer tests passed"); +} From c758d43342b1360a3b57f07f49894e0b7dd534c5 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 21:30:32 +0700 Subject: [PATCH 08/23] feat(M2): port MaSonKuPik EQ interaction to lightweight embedded WebView2 editor --- .github/workflows/dsp.yml | 4 + .github/workflows/vst3-windows.yml | 13 +- CMakeLists.txt | 18 +- README.md | 9 + Source/PluginProcessor.cpp | 9 + Source/WebEditor.cpp | 264 +++++++++++++++++++++++ Source/WebEditor.h | 51 +++++ WebUI/app.js | 323 +++++++++++++++++++++++++++++ WebUI/index.html | 33 +++ WebUI/smoke.test.cjs | 71 +++++++ WebUI/style.css | 10 + docs/ARD.md | 17 ++ docs/MIGRATION.md | 7 + docs/PRD.md | 5 + docs/ROADMAP.md | 13 ++ 15 files changed, 843 insertions(+), 4 deletions(-) create mode 100644 Source/WebEditor.cpp create mode 100644 Source/WebEditor.h create mode 100644 WebUI/app.js create mode 100644 WebUI/index.html create mode 100644 WebUI/smoke.test.cjs create mode 100644 WebUI/style.css diff --git a/.github/workflows/dsp.yml b/.github/workflows/dsp.yml index e6b9246..6e81dd0 100644 --- a/.github/workflows/dsp.yml +++ b/.github/workflows/dsp.yml @@ -24,3 +24,7 @@ jobs: run: cmake --build build --config Release --parallel 2 - name: Test DSP, transitions, analyzer queue run: ctest --test-dir build -C Release --output-on-failure + - name: JS syntax + offline UI bridge smoke (no npm needed) + run: | + node --check WebUI/app.js + node WebUI/smoke.test.cjs diff --git a/.github/workflows/vst3-windows.yml b/.github/workflows/vst3-windows.yml index 79f4807..07aa3d7 100644 --- a/.github/workflows/vst3-windows.yml +++ b/.github/workflows/vst3-windows.yml @@ -18,8 +18,19 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - name: Cache pinned WebView2 SDK + uses: actions/cache@v4 + id: webview2 + with: + path: ${{ runner.temp }}/arsoneq-nuget + key: webview2-sdk-1.0.3485.44 + - name: Install WebView2 headers and loader (build-time only) + if: steps.webview2.outputs.cache-hit != 'true' + shell: pwsh + run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory "$env:RUNNER_TEMP/arsoneq-nuget" -NonInteractive - name: Configure pinned JUCE and headless tests - run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=ON + shell: pwsh + run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=ON "-DJUCE_WEBVIEW2_PACKAGE_LOCATION=$env:RUNNER_TEMP/arsoneq-nuget" - name: Compile Release VST3 and tests run: cmake --build build-vst --config Release --target ArSonEQ_VST3 arson_eq_core_tests arson_eq_rt_tests arson_eq_analyzer_tests --parallel 2 - name: Verify native tests on Windows diff --git a/CMakeLists.txt b/CMakeLists.txt index bcdbdc2..ec4f0d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,15 +55,27 @@ if(ARSONEQ_BUILD_PLUGIN) NEEDS_MIDI_OUTPUT FALSE IS_MIDI_EFFECT FALSE COPY_PLUGIN_AFTER_BUILD FALSE - PRODUCT_NAME "ArSonEQ") + PRODUCT_NAME "ArSonEQ" + NEEDS_WEBVIEW2 TRUE) target_sources(ArSonEQ PRIVATE Source/PluginProcessor.cpp Source/PluginEditor.cpp) + if(WIN32) + # Browser UI is plain static HTML/CSS/JS embedded in the VST3. + # No Node/React/vite/npm at runtime and no local web server. + juce_add_binary_data(ArSonEQWebAssets SOURCES + WebUI/index.html WebUI/style.css WebUI/app.js) + target_sources(ArSonEQ PRIVATE Source/WebEditor.cpp) + target_link_libraries(ArSonEQ PRIVATE ArSonEQWebAssets) + endif() target_link_libraries(ArSonEQ PRIVATE arson_eq_dsp - juce::juce_audio_utils juce::juce_dsp + juce::juce_audio_utils juce::juce_gui_extra juce::juce_dsp juce::juce_recommended_config_flags juce::juce_recommended_warning_flags juce::juce_recommended_lto_flags) target_compile_definitions(ArSonEQ PRIVATE - JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0) + JUCE_WEB_BROWSER=1 JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0) + if(WIN32) + target_compile_definitions(ArSonEQ PRIVATE JUCE_USE_WIN_WEBVIEW2=1) + endif() endif() diff --git a/README.md b/README.md index 12b49f9..c8223ce 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,12 @@ FabFilter and Pro-Q are trademarks of their respective owner, which is not affil The M1.5 upgrade uses preallocated dual-path crossfades for discrete filter topology, route and enabled changes. Continuous gain/frequency/Q movements use coefficient smoothing. A zero-latency minimum-phase DSP path remains the only implemented phase mode. A single-producer/single-consumer telemetry queue feeds two 4,096-point FFTs (input and output) on the editor thread, without FFT execution in the audio callback. UI transfer curves reflect L/R/M/S routing via a matrix calculation and are cached until parameters or geometry change. New headless checks include dynamic transitions, algebraic-vs-measured response, heap-allocation checks in DSP processing, and SPSC thread safety. This is **not** certification of click-free behavior on every host or of low-CPU targets: host testing, CPU profiles, pluginval and independent DAW testing remain necessary before release. + + +## M2 Windows web GUI (MaSonKuPik-inspired) + +On Windows, the editor prefers a **premium dark HTML/CSS/Canvas 2D UI** hosted by JUCE 9 WebView2. Assets are embedded into the VST3; no installer web server, external network, React runtime, or npm package install. WebView2 must be available on the user's machine. If unsupported, the native JUCE editor is retained. The DSP continues to run independently of either editor. + +Control map: double-click empty canvas to create a bell filter, double-click an existing node to remove; drag for frequency/gain; wheel over a node for Q or cut slope; click for inspector; route filters to Stereo/L/R/Mid/Side; edit numeric frequency/gain/Q in the right inspector; Delete removes selected band. Native APVTS parameter IDs are not changed. The response curve is computed in the C++ DSP, and a bounded 25Hz FFT stream from the editor's native queue drives the input/output spectrum behind the curve. + +Source `WebUI/` is deliberately tiny and zero-dependency. Run `node --check WebUI/app.js && node WebUI/smoke.test.cjs` for an offline bridge wiring smoke check. This is NOT a substitute for actual DAW/WebView2 UI testing, host recall validation or CPU/memory profiling. diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 98a375d..4820497 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -1,5 +1,8 @@ #include "PluginProcessor.h" #include "PluginEditor.h" +#if JUCE_WINDOWS +#include "WebEditor.h" +#endif #include juce::String ArSonEQAudioProcessor::parameterId(int band, const char* field) { @@ -115,6 +118,12 @@ void ArSonEQAudioProcessor::setStateInformation(const void* data,int size) { } } juce::AudioProcessorEditor* ArSonEQAudioProcessor::createEditor() { +#if JUCE_WINDOWS + // Prefer MaSonKuPik-inspired zero-framework WebView2 GUI. Never force + // Internet Explorer as a fallback; retain the proven JUCE native editor. + if (ArSonEQWebEditor::supported()) + return new ArSonEQWebEditor(*this); +#endif return new ArSonEQEditor(*this); } juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new ArSonEQAudioProcessor(); } diff --git a/Source/WebEditor.cpp b/Source/WebEditor.cpp new file mode 100644 index 0000000..c5305ec --- /dev/null +++ b/Source/WebEditor.cpp @@ -0,0 +1,264 @@ +#include "WebEditor.h" +#include +#include +#include + +namespace { +constexpr int graphPoints=256; +constexpr int spectrumPoints=224; +constexpr double lowest=20.0,highest=20000.0; + +juce::var makeObject() { return juce::var(new juce::DynamicObject()); } +void property(juce::var& object,const char* key,juce::var value) { + object.getDynamicObject()->setProperty(juce::Identifier(key),std::move(value)); +} +juce::WebBrowserComponent::Options browserOptions(ArSonEQWebEditor* owner, + std::function command, + std::function(const juce::String&)> resource) { + using Web=juce::WebBrowserComponent; + const auto cache=juce::File::getSpecialLocation(juce::File::tempDirectory) + .getChildFile("ArSonEQ-WebView2"); + return Web::Options{} + .withBackend(Web::Options::Backend::webview2) + .withWinWebView2Options(Web::Options::WinWebView2{} + .withUserDataFolder(cache) + .withStatusBarDisabled() + .withBackgroundColour(juce::Colour(0xff0b0f16))) + .withNativeIntegrationEnabled() + .withEventListener("eq-command",[command=std::move(command)](juce::var message) { + command(message); + }) + .withResourceProvider(std::move(resource)); +} +} // namespace + +bool ArSonEQWebEditor::supported() { + // Do not silently fall back to legacy Internet Explorer: it can't run this + // modern Canvas UI and would expose a blank / broken editor. + using Web=juce::WebBrowserComponent; + return Web::areOptionsSupported(Web::Options{} + .withBackend(Web::Options::Backend::webview2)); +} + +std::optional +ArSonEQWebEditor::resource(const juce::String& url) { + const unsigned char* ptr=nullptr; + int length=0; + juce::String mime; + if(url=="/"||url=="/index.html") { + ptr=BinaryData::index_html;length=BinaryData::index_htmlSize;mime="text/html; charset=utf-8"; + } else if(url=="/style.css") { + ptr=BinaryData::style_css;length=BinaryData::style_cssSize;mime="text/css; charset=utf-8"; + } else if(url=="/app.js") { + ptr=BinaryData::app_js;length=BinaryData::app_jsSize;mime="text/javascript; charset=utf-8"; + } else return std::nullopt; + if(ptr==nullptr || length<=0) return std::nullopt; + juce::WebBrowserComponent::Resource result; + result.data.resize(static_cast(length)); + std::memcpy(result.data.data(),ptr,static_cast(length)); + result.mimeType=mime; + return result; +} +ArSonEQWebEditor::ArSonEQWebEditor(ArSonEQAudioProcessor& p) + : AudioProcessorEditor(p),processor_(p), + browser_(browserOptions(this, + [this](const juce::var& message){ onCommand(message); }, + [](const juce::String& url){ return resource(url); })) { + setOpaque(true); + addAndMakeVisible(browser_); + setResizable(true,true); + setResizeLimits(820,490,1680,1000); + graphEngine_.prepare(p.configuredSampleRate()); + window_.fill(0.0f); + for(int i=0;i(i)]=0.5f*(1.0f- + std::cos(2.0f*juce::MathConstants::pi*i/(fftSize_-1))); + levelsPre_.fill(-108.f); + levelsPost_.fill(-108.f); + setSize(1110,680); + processor_.analyzer().setEnabled(true); + browser_.goToURL(juce::WebBrowserComponent::getResourceProviderRoot()); + startTimerHz(25); +} +ArSonEQWebEditor::~ArSonEQWebEditor() { + stopTimer(); + processor_.analyzer().setEnabled(false); + for(int i=0;i(i)][static_cast(j)]) + if(auto* param=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(i,j==0?"freq":"gain"))) + param->endChangeGesture(); +} +void ArSonEQWebEditor::resized() { browser_.setBounds(getLocalBounds()); } + +void ArSonEQWebEditor::setField(int id,const char* field,float value) { + if(id<0||id>=arson::eq::kMaxBands||!std::isfinite(value))return; + if(auto* param=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(id,field))) { + const float normal=param->convertTo0to1(value); + param->beginChangeGesture(); + param->setValueNotifyingHost(normal); + param->endChangeGesture(); + } +} +void ArSonEQWebEditor::edit(int id,const juce::String& field,float value,bool useGesture) { + if(id<0||id>=arson::eq::kMaxBands||!std::isfinite(value))return; + const char* key=nullptr; + if(field=="freq") {key="freq";value=juce::jlimit(20.f,20000.f,value);} + else if(field=="gain") {key="gain";value=juce::jlimit(-24.f,24.f,value);} + else if(field=="q") {key="q";value=juce::jlimit(.1f,24.f,value);} + else if(field=="type") {key="type";value=std::round(juce::jlimit(0.f,5.f,value));} + else if(field=="route") {key="route";value=std::round(juce::jlimit(0.f,4.f,value));} + else if(field=="slope") {key="slope";value=std::round(juce::jlimit(0.f,3.f,value));} + else if(field=="enabled") {key="enabled";value=value>.5f?1.f:0.f;} + if(!key)return; // strict field allow-list, no arbitrary host parameter access + if(auto* param=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(id,key))) { + if(useGesture)param->beginChangeGesture(); + param->setValueNotifyingHost(param->convertTo0to1(value)); + if(useGesture)param->endChangeGesture(); + } +} +void ArSonEQWebEditor::gesture(int id,const juce::var& fields,bool begin) { + if(id<0||id>=arson::eq::kMaxBands||!fields.isArray())return; + for(const auto& item:*fields.getArray()) { + const auto field=item.toString(); + const int n=field=="freq"?0:field=="gain"?1:-1; + if(n<0)continue; + auto& current=gestures_[static_cast(id)][static_cast(n)]; + if(current==begin)continue; + if(auto* param=processor_.parameters.getParameter( + ArSonEQAudioProcessor::parameterId(id,n==0?"freq":"gain"))) { + if(begin)param->beginChangeGesture(); + else param->endChangeGesture(); + current=begin; + } + } +} +void ArSonEQWebEditor::onCommand(const juce::var& message) { + if(!message.isObject())return; + const auto kind=message.getProperty("kind",{}).toString(); + if(kind=="ready") {ready_=true;sendState(true);return;} + const int id=static_cast(message.getProperty("id",-1)); + if(kind=="select") { + selected_=id>=0&&id( + static_cast(message.getProperty("value",0.0))); + edit(id,message.getProperty("field",{}).toString(),value, + static_cast(message.getProperty("gesture",true))); + } else if(kind=="add") { + const float freq=static_cast(static_cast(message.getProperty("freq",1000.0))); + const float gain=static_cast(static_cast(message.getProperty("gain",0.0))); + if(id<0||id>=arson::eq::kMaxBands)return; + setField(id,"type",0.f);setField(id,"route",0.f); + setField(id,"q",1.f);setField(id,"slope",0.f); + edit(id,"freq",freq,true);edit(id,"gain",gain,true); + edit(id,"enabled",1.f,true); + selected_=id; + sendState(true); + } +} +void ArSonEQWebEditor::sendState(bool response) { + if(!ready_)return; + auto value=makeObject(); + property(value,"rate",processor_.configuredSampleRate()); + juce::Array bands; + for(int i=0;i(b.type)); + property(item,"route",static_cast(b.route)); + property(item,"freq",b.frequency); + property(item,"gain",b.gainDb); + property(item,"q",b.q); + property(item,"slope",arson::eq::stageCount(b.slope)-1); + bands.add(std::move(item)); + } + property(value,"bands",std::move(bands)); + if(response) { + auto curves=makeObject(); + juce::Array l,r,c,b; + for(int i=0;i(i)/(graphPoints-1)); + const auto matrix=graphEngine_.matrixResponse(hz); + const auto db=[](const std::complex& v) { + return juce::jlimit(-120.0,40.0,20.0*std::log10( + std::max(1.0e-20,std::abs(v)))); + }; + l.add(db(matrix.ll));r.add(db(matrix.rr)); + c.add(db(matrix.lr)); + b.add(selected_>=0?graphEngine_.bandResponseDb(selected_,hz):0.0); + } + property(curves,"l",std::move(l)); + property(curves,"r",std::move(r)); + property(curves,"cross",std::move(c)); + property(curves,"band",std::move(b)); + property(value,"curve",std::move(curves)); + } + browser_.emitEventIfBrowserIsVisible("eq-state",value); +} +void ArSonEQWebEditor::sendSpectrum() { + arson::eq::MeterFrame f; + int drained=0; + while(drained(i))&(fftSize_-1); + fftPre_[static_cast(i)]=pre_[pos]*window_[static_cast(i)]; + fftPost_[static_cast(i)]=post_[pos]*window_[static_cast(i)]; + } + fft_.performFrequencyOnlyForwardTransform(fftPre_.data()); + fft_.performFrequencyOnlyForwardTransform(fftPost_.data()); + const auto sr=processor_.configuredSampleRate(); + juce::Array before,after; + for(int i=0;i(i)/(spectrumPoints-1)); + const int index=juce::jlimit(1,fftSize_/2,static_cast( + std::round(hz*fftSize_/sr))); + const auto k=static_cast(index); + const auto magnitude=[](float x) { + return 20.0f*std::log10(std::max(x*4.f/fftSize_,1.0e-8f)); + }; + const auto a=juce::jlimit(-108.f,0.f,magnitude(fftPre_[k])); + const auto b=juce::jlimit(-108.f,0.f,magnitude(fftPost_[k])); + levelsPre_[k]=.67f*levelsPre_[k]+.33f*a; + levelsPost_[k]=.67f*levelsPost_[k]+.33f*b; + before.add(static_cast(levelsPre_[k])); + after.add(static_cast(levelsPost_[k])); + } + auto snapshot=makeObject(); + property(snapshot,"pre",std::move(before)); + property(snapshot,"post",std::move(after)); + browser_.emitEventIfBrowserIsVisible("eq-spectrum",snapshot); +} +void ArSonEQWebEditor::timerCallback() { + bool changed=false; + const auto rate=processor_.configuredSampleRate(); + if(graphEngine_.sampleRate()!=rate) { + graphEngine_.prepare(rate);changed=true; + } + for(int i=0;i(i)],b)) { + cache_[static_cast(i)]=b; + graphEngine_.setBand(i,b); + changed=true; + } + } + if(changed)sendState(true); + sendSpectrum(); +} diff --git a/Source/WebEditor.h b/Source/WebEditor.h new file mode 100644 index 0000000..ce0f8e9 --- /dev/null +++ b/Source/WebEditor.h @@ -0,0 +1,51 @@ +#pragma once +#include "PluginProcessor.h" +#include +#include +#include +#include + +// Local-only WebView2/C++ bridge. Audio remains completely native and unaware +// of its editor. No HTTP requests, Web Audio DSP, React, or JS in processBlock. +class ArSonEQWebEditor final : public juce::AudioProcessorEditor, + private juce::Timer { +public: + explicit ArSonEQWebEditor(ArSonEQAudioProcessor&); + ~ArSonEQWebEditor() override; + void resized() override; + static bool supported(); +private: + class LocalBrowser final : public juce::WebBrowserComponent { + public: + explicit LocalBrowser(const juce::WebBrowserComponent::Options& options) + : juce::WebBrowserComponent(options) {} + bool pageAboutToLoad(const juce::String& url) override { + return url.startsWith(getResourceProviderRoot()); + } + }; + static std::optional resource(const juce::String&); + void onCommand(const juce::var&); + void edit(int, const juce::String&, float, bool gesture); + void gesture(int, const juce::var&, bool begin); + void setField(int, const char*, float); + void sendState(bool response); + void sendSpectrum(); + void timerCallback() override; + static constexpr int fftOrder_=12; + static constexpr int fftSize_=1< cache_{}; + std::array,arson::eq::kMaxBands> gestures_{}; + juce::dsp::FFT fft_{fftOrder_}; + std::array pre_{},post_{},window_{}; + std::array fftPre_{},fftPost_{}; + std::array levelsPre_{},levelsPost_{}; + size_t head_=0; + uint64_t framesSeen_=0; + int framesSinceFFT_=0; + int selected_=-1; + bool ready_=false; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQWebEditor) +}; \ No newline at end of file diff --git a/WebUI/app.js b/WebUI/app.js new file mode 100644 index 0000000..6abad74 --- /dev/null +++ b/WebUI/app.js @@ -0,0 +1,323 @@ +/* ArSonEQ Studio web canvas. Adapted interaction vocabulary from user's MaSonKuPik EQ. + * WebView contains NO audio DSP, no Web Audio, no libraries, no network requests. + * Backend owns authoritative host parameters and transfer functions. + */ +(() => { +"use strict"; +const $=id=>document.getElementById(id); +const canvas=$("eqCanvas"), wrap=$("graphWrap"), ctx=canvas.getContext("2d",{alpha:false}); +const TYPES=["Bell","Low Shelf","High Shelf","Low Cut","High Cut","Notch"]; +const COLORS=["#ff936f","#ffd07a","#9fe37f","#57dcca","#63bde9","#b194fa","#ed98d9","#ef8eb4"]; +const F0=20,F1=20000,RANGE=18,MAX=24; +const clamp=(x,a,b)=>Math.max(a,Math.min(b,x)); +const hzX=(f,w)=>Math.log(clamp(f,F0,F1)/F0)/Math.log(F1/F0)*w; +const xHz=(x,w)=>F0*Math.pow(F1/F0,clamp(x/w,0,1)); +const dbY=(v,h)=>h*0.5-clamp(v,-RANGE,RANGE)/RANGE*h*0.5; +const yDb=(y,h)=>clamp((h*0.5-y)/(h*0.5)*RANGE,-RANGE,RANGE); +const isCut=t=>t===3||t===4; +const isFiniteNumber=n=>typeof n==="number"&&Number.isFinite(n); +const noteFor=hz=>{if(!isFiniteNumber(hz)||hz<=0)return "—";const midi=Math.round(69+12*Math.log2(hz/440));return ["C","C♯","D","D♯","E","F","F♯","G","G♯","A","A♯","B"][(midi+1200)%12]+(Math.floor(midi/12)-1);}; +const backend=window.__JUCE__?.backend; +let bands=Array.from({length:MAX},(_,i)=>({id:i,enabled:false,type:0,route:0,freq:1000,gain:0,q:1,slope:0})); +let curves={l:[],r:[],cross:[],band:[]},spec={pre:[],post:[]},samplerate=48000; +let selected=-1,hovered=-1,showSpectrum=true,dragging=null,pendingDrag=null; +let w=1,h=1,dpr=1,dirty=false,connected=false,hasSpectrum=false; +const emit=payload=>{if(backend?.emitEvent)backend.emitEvent("eq-command",payload);}; +const changed=()=>{if(!dirty){dirty=true;requestAnimationFrame(()=>{dirty=false;draw();});}}; +const col=i=>COLORS[i%COLORS.length]; +const active=()=>bands.map((b,i)=>b.enabled?i:-1).filter(i=>i>=0); +const updateBandLocal=(id,field,value)=>{ + if(id<0||id>=MAX||!Number.isFinite(value))return; + bands[id][field]=value; + renderInspector();changed(); +}; +const setParam=(id,field,value,gesture=true)=>{ + if(!Number.isFinite(value)||id<0||id>=MAX)return; + updateBandLocal(id,field,value); + emit({kind:"edit",id,field,value,gesture}); +}; +const select=i=>{ + selected=(i>=0&&i{ + const idx=bands.findIndex(b=>!b.enabled); + if(idx<0)return; + const freq=xHz(x,w),gain=yDb(y,h); + bands[idx]={...bands[idx],enabled:true,type:0,route:0,freq,gain,q:1,slope:0}; + emit({kind:"add",id:idx,freq,gain}); + select(idx); +}; +const removeSelected=()=>{ + if(selected<0)return; + setParam(selected,"enabled",0); + select(-1); +}; +const bandHit=(x,y)=>{ + let choice=-1,best=16*16; + for(let i=0;if>=1000?(f/1000).toFixed(f%1000===0?0:1)+"k":Math.round(f)+""; +const number=n=>Number.isFinite(n)?n.toFixed(1):"—"; +const renderRail=()=>{ + const list=active(); + $("bandCount").textContent=list.length+" / 24"; + const rail=$("bandRail");rail.replaceChildren(); + for(const i of list){ + const chip=document.createElement("button"); + chip.type="button";chip.className="band-chip on"+(selected===i?" selected":""); + chip.style.setProperty("--chip",col(i)); + chip.textContent=String(i+1).padStart(2,"0")+" · "+formatHz(bands[i].freq); + chip.onclick=()=>select(i);rail.appendChild(chip); + } +}; +const renderInspector=()=>{ + const b=selected>=0?bands[selected]:null; + $("emptyInspector").hidden=!!b;$("bandInspector").hidden=!b; + $("activeLabel").textContent=b?"BAND "+String(selected+1).padStart(2,"0"):"NO SELECTION"; + if(!b)return; + $("bandTitle").textContent="Band "+String(selected+1).padStart(2,"0"); + $("bandDot").style.background=col(selected); + $("enableBtn").textContent=b.enabled?"● ACTIVE":"○ BYPASSED"; + $("enableBtn").classList.toggle("off",!b.enabled); + $("typeSelect").value=String(b.type); + $("slopeSelect").value=String(b.slope); + const setValue=(id,v)=>{const input=$(id);if(document.activeElement!==input)input.value=String(v);}; + setValue("freqInput",Math.round(b.freq*10)/10); + setValue("gainInput",Math.round(b.gain*100)/100); + setValue("qInput",Math.round(b.q*100)/100); + $("gainInput").disabled=isCut(b.type)||b.type===5; + $("slopeSelect").disabled=!isCut(b.type); + $("noteLabel").textContent=noteFor(b.freq); + $("routeGroup").querySelectorAll("button").forEach(btn=>btn.classList.toggle("active",Number(btn.dataset.route)===b.route)); +}; +const mapLocal=e=>{const r=canvas.getBoundingClientRect();return{x:clamp(e.clientX-r.left,0,r.width),y:clamp(e.clientY-r.top,0,r.height)};}; +const drawSmooth=(arr,color,lineWidth=2,fill=false,alpha=1)=>{ + if(!arr||arr.length<2)return; + ctx.beginPath(); + for(let i=0;i{ + if(!values?.length)return; + const floor=-104,ceil=-14; + ctx.beginPath(); + for(let i=0;i{ + if(w<2||h<2)return; + ctx.save();ctx.setTransform(dpr,0,0,dpr,0,0); + ctx.fillStyle="#101a27";ctx.fillRect(0,0,w,h); + const bg=ctx.createLinearGradient(0,0,0,h); + bg.addColorStop(0,"rgba(23,41,55,.28)");bg.addColorStop(1,"rgba(7,13,23,.45)"); + ctx.fillStyle=bg;ctx.fillRect(0,0,w,h); + ctx.font="10px Consolas,monospace"; + for(const f of [20,30,40,50,70,100,200,300,500,700,1000,2000,3000,5000,7000,10000,20000]){ + const x=hzX(f,w); + ctx.strokeStyle=[20,100,1000,10000].includes(f)?"#314150":"#25313e"; + ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,h);ctx.lineWidth=.65;ctx.stroke(); + if([30,50,100,200,500,1000,2000,5000,10000].includes(f)){ + ctx.textAlign="center";ctx.fillStyle="#8297a9";ctx.fillText(formatHz(f),x,h-8); + } + } + for(let db=-18;db<=18;db+=6){ + const y=dbY(db,h);ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(w,y); + ctx.lineWidth=db===0?1.15:.7;ctx.strokeStyle=db===0?"#607383":"#2b3a48";ctx.stroke(); + ctx.fillStyle="#7990a2";ctx.textAlign="right"; + ctx.fillText((db>0?"+":"")+db+" dB",w-10,clamp(y-7,11,h-20)); + } + if(showSpectrum){drawSpectrum(spec.post,"#71cfb3",true);drawSpectrum(spec.pre,"#7897ab",false);} + if(selected>=0&&bands[selected]?.enabled&&curves.band?.length){ + drawSmooth(curves.band,col(selected),1.3,true,.55); + } + drawSmooth(curves.l,"#65e8f3",2.5,true,1); + drawSmooth(curves.r,"#f5ca80",1.05,false,.73); + // The physical crossfeed curve is hidden to avoid a misleading -108dB line. + for(let i=0;i{ + const r=wrap.getBoundingClientRect(),oldW=w,oldH=h; + w=Math.max(1,r.width);h=Math.max(1,r.height); + dpr=Math.min(2,window.devicePixelRatio||1); + const cw=Math.max(1,Math.round(w*dpr)),ch=Math.max(1,Math.round(h*dpr)); + if(canvas.width!==cw||canvas.height!==ch){canvas.width=cw;canvas.height=ch;} + if(oldW!==w||oldH!==h)changed(); +}; +new ResizeObserver(resize).observe(wrap); +window.addEventListener("resize",resize); +function applyHostState(data){ + if(!data||!Array.isArray(data.bands)||data.bands.length!==MAX)return; + connected=true;samplerate=isFiniteNumber(data.rate)?data.rate:samplerate; + bands=data.bands.map((b,i)=>({ + id:i,enabled:!!b.enabled,type:clamp(b.type|0,0,5),route:clamp(b.route|0,0,4), + freq:clamp(Number(b.freq)||1000,20,20000),gain:clamp(Number(b.gain)||0,-24,24), + q:clamp(Number(b.q)||1,.1,24),slope:clamp(b.slope|0,0,3) + })); + if(dragging){ const b=bands[dragging.id];if(b){b.freq=dragging.freq;b.gain=dragging.gain;} } + if(data.curve){curves=data.curve;} + $("stateInfo").textContent="24 BANDS / "+(samplerate/1000).toFixed(1)+" kHz / ZERO LATENCY"; + $("bridgeStatus").innerHTML=' NATIVE DSP CONNECTED'; + renderInspector();renderRail();changed(); +} +function applySpectrum(data){ + if(!data||!Array.isArray(data.pre)||!Array.isArray(data.post))return; + spec=data;hasSpectrum=true;if(showSpectrum)changed(); +} +if(backend?.addEventListener){ + backend.addEventListener("eq-state",applyHostState); + backend.addEventListener("eq-spectrum",applySpectrum); + emit({kind:"ready"}); +}else{ + $("bridgeStatus").textContent="WEB PREVIEW MODE — NO AUDIO ENGINE"; + curves.l=Array(256).fill(0);curves.r=Array(256).fill(0); +} +canvas.addEventListener("pointerdown",e=>{ + if(e.button!==0)return; + const p=mapLocal(e);const id=bandHit(p.x,p.y); + if(id<0){select(-1);return;} + select(id); + const b=bands[id]; + dragging={id,pointer:e.pointerId,freq:b.freq,gain:b.gain}; + canvas.setPointerCapture(e.pointerId); + emit({kind:"begin",id,fields:["freq",...(!isCut(b.type)&&b.type!==5?["gain"]:[])]}); +}); +canvas.addEventListener("pointermove",e=>{ + const p=mapLocal(e); const f=xHz(p.x,w); + $("hoverReadout").textContent=formatHz(f)+" Hz • "+noteFor(f)+" • "+number(yDb(p.y,h))+" dB"; + if(dragging && dragging.pointer===e.pointerId){ + dragging.freq=f; + if(!isCut(bands[dragging.id].type)&&bands[dragging.id].type!==5) dragging.gain=yDb(p.y,h); + pendingDrag={id:dragging.id,freq:dragging.freq,gain:dragging.gain}; + // At most one native command bundle per animation frame. + if(!canvas.dataset.dragRaf){ + canvas.dataset.dragRaf="1"; + requestAnimationFrame(flushDrag); + } + changed();return; + } + const hit=bandHit(p.x,p.y); + if(hit!==hovered){hovered=hit;changed();} + const tooltip=$("graphTooltip"); + if(hit>=0){ + const b=bands[hit]; + tooltip.textContent="B"+(hit+1)+" "+formatHz(b.freq)+" Hz "+number(b.gain)+" dB · Q "+number(b.q); + tooltip.style.left=clamp(p.x+14,10,w-190)+"px"; + tooltip.style.top=clamp(p.y-50,8,h-45)+"px"; + tooltip.hidden=false; + }else tooltip.hidden=true; +}); +const flushDrag=()=>{ + canvas.dataset.dragRaf=""; + if(!pendingDrag)return; + const v=pendingDrag;pendingDrag=null; + setParam(v.id,"freq",v.freq,false); + if(!isCut(bands[v.id].type)&&bands[v.id].type!==5)setParam(v.id,"gain",v.gain,false); + renderRail(); +}; +const finishDrag=e=>{ + if(!dragging||dragging.pointer!==e.pointerId)return; + // Always commit the final pointer location before closing the host gesture. + flushDrag(); + const d=dragging; + dragging=null; + emit({kind:"end",id:d.id,fields:["freq",...(!isCut(bands[d.id].type)&&bands[d.id].type!==5?["gain"]:[])]}); + changed(); +}; +canvas.addEventListener("pointerup",finishDrag); +canvas.addEventListener("pointercancel",finishDrag); +canvas.addEventListener("pointerleave",()=>{hovered=-1;$("graphTooltip").hidden=true;changed();}); +canvas.addEventListener("dblclick",e=>{ + const p=mapLocal(e),id=bandHit(p.x,p.y); + if(id>=0){select(id);removeSelected();} + else addBand(p.x,p.y); +}); +canvas.addEventListener("wheel",e=>{ + const p=mapLocal(e),id=bandHit(p.x,p.y); + if(id<0)return; + e.preventDefault(); + const b=bands[id],direction=e.deltaY<0?1:-1; + if(isCut(b.type))setParam(id,"slope",clamp(b.slope+direction,0,3)); + else setParam(id,"q",clamp(b.q*Math.pow(1.14,direction),.1,24)); + select(id); +},{passive:false}); +const ctrl=(id,field,converter=Number)=>{ + $(id).addEventListener("change",()=>{ + if(selected<0)return;const v=converter($(id).value); + if(Number.isFinite(v))setParam(selected,field,v); + }); +}; +ctrl("typeSelect","type",Number);ctrl("slopeSelect","slope",Number); +ctrl("freqInput","freq",v=>clamp(Number(v),20,20000)); +ctrl("gainInput","gain",v=>clamp(Number(v),-24,24)); +ctrl("qInput","q",v=>clamp(Number(v),.1,24)); +$("enableBtn").onclick=()=>{if(selected>=0)setParam(selected,"enabled",bands[selected].enabled?0:1);}; +$("removeBtn").onclick=removeSelected; +$("routeGroup").addEventListener("click",e=>{ + const btn=e.target.closest("[data-route]"); + if(selected>=0&&btn)setParam(selected,"route",Number(btn.dataset.route)); +}); +$("viewBtn").onclick=()=>{ + showSpectrum=!showSpectrum;$("spectrumStatus").textContent=showSpectrum?"ON":"OFF";changed(); +}; +$("helpBtn").onclick=()=>$("quickHelp").scrollIntoView({behavior:"smooth",block:"nearest"}); +window.addEventListener("keydown",e=>{ + if(e.target.matches("input,select"))return; + if((e.key==="Delete"||e.key==="Backspace")&&selected>=0){ + e.preventDefault();removeSelected(); + } +}); +resize();renderInspector();renderRail();changed(); +})(); \ No newline at end of file diff --git a/WebUI/index.html b/WebUI/index.html new file mode 100644 index 0000000..69ea9b1 --- /dev/null +++ b/WebUI/index.html @@ -0,0 +1,33 @@ + + + +ArSonEQ Studio + +
+
ArSonEQPRECISION PARAMETRIC EQUALIZER
+
24-BAND / ZERO LATENCY
+
v0.2 TEST
+
+
+
FREQUENCY RESPONSEHover spectrum for frequency
+
INPUT OUTPUT EQ
+
+
+ +
ACTIVE BANDS 0 / 24
+
+ +
+
CONNECTING TO AUDIO ENGINEDESIGNED FOR HOST AUTOMATION · 24 FIXED SLOTSARSÓN AUDIO LAB
+
\ No newline at end of file diff --git a/WebUI/smoke.test.cjs b/WebUI/smoke.test.cjs new file mode 100644 index 0000000..56a5fa3 --- /dev/null +++ b/WebUI/smoke.test.cjs @@ -0,0 +1,71 @@ +// Zero-dependency smoke test of bundled WebUI startup and host-command bridge. +// Runs in Node using a minimal fake DOM/canvas. Catches regressions in real JS +// interaction wiring without building JUCE or opening a DAW. +const fs=require("node:fs"),vm=require("node:vm"),assert=require("node:assert/strict"); +const calls=[],handlers={},nodes={}; +function element(id) { + if(nodes[id])return nodes[id]; + const events={}; + const node={ + id,value:"",style:{setProperty(){}},className:"",textContent:"",hidden:false, + dataset:{},width:800,height:400,disabled:false,children:[], + classList:{toggle(){},add(){},remove(){}}, + addEventListener(name,callback){events[name]=callback;}, + dispatch(name,payload){assert.ok(events[name],id+" has "+name);events[name](payload||{});}, + appendChild(child){this.children.push(child);return child;}, + replaceChildren(){this.children=[];}, + querySelectorAll(){return [0,1,2,3,4].map(i=>({ + dataset:{route:String(i)},classList:{toggle(){}} + }));}, + getBoundingClientRect(){return{left:0,top:0,width:800,height:400};}, + setPointerCapture(){}, + scrollIntoView(){}, + getContext(){return ctx;} + }; + return nodes[id]=node; +} +const ctx={ + fillRect(){},beginPath(){},moveTo(){},lineTo(){},stroke(){},fill(){}, + arc(){},save(){},restore(){},fillText(){},setTransform(){}, + createLinearGradient(){return{addColorStop(){}};} +}; +const document={activeElement:null, + getElementById:element, + createElement:()=>element("created-"+Object.keys(nodes).length) +}; +const backend={ + addEventListener(name,fn){handlers[name]=fn;}, + emitEvent(name,data){calls.push({name,data});} +}; +const window={ + __JUCE__:{backend},devicePixelRatio:1, + addEventListener(){}, + requestAnimationFrame(fn){fn();} +}; +const sandbox={ + document,window,ResizeObserver:class{constructor(fn){this.fn=fn;}observe(){this.fn();}}, + requestAnimationFrame:fn=>fn(),console,Math,Array,Number,JSON,Set +}; +vm.runInNewContext(fs.readFileSync("WebUI/app.js","utf8"),sandbox,{timeout:2000,filename:"app.js"}); +const find=k=>calls.filter(x=>x.data.kind===k).map(x=>x.data); +assert.ok(find("ready").length,"JS announces ready to native engine"); +assert.equal(typeof handlers["eq-state"],"function"); +assert.equal(typeof handlers["eq-spectrum"],"function"); +const bands=Array.from({length:24},(_,i)=>({ + enabled:i===0,type:0,route:0,freq:i===0?1000:2000,gain:i===0?6:0,q:1,slope:0 +})); +const curve=Array(256).fill(0); +handlers["eq-state"]({bands,rate:48000,curve:{l:curve,r:curve,cross:curve,band:curve}}); +assert.ok(element("bridgeStatus").innerHTML.includes("CONNECTED"),"UI becomes connected"); +assert.ok(element("bandCount").textContent.includes("1 / 24"),"host band snapshot reflected"); +handlers["eq-spectrum"]({pre:Array(224).fill(-80),post:Array(224).fill(-75)}); +element("eqCanvas").dispatch("pointerdown",{button:0,pointerId:1,clientX:452,clientY:133}); +assert.ok(find("begin").length,"host gesture starts on drag"); +element("eqCanvas").dispatch("pointermove",{pointerId:1,clientX:500,clientY:170}); +element("eqCanvas").dispatch("pointerup",{pointerId:1}); +assert.ok(find("end").length,"host gesture ends after drag"); +assert.ok(find("edit").some(x=>x.field==="freq"),"drag automates frequency"); +element("eqCanvas").dispatch("dblclick",{clientX:100,clientY:300}); +assert.ok(find("add").length,"double click empty graph creates band"); +handlers["eq-state"]({bands,rate:48000,curve:{l:curve,r:curve,cross:curve,band:curve}}); +console.log("ArSonEQ WebUI smoke PASS: load, native events, spectrum, drag gestures, add band"); diff --git a/WebUI/style.css b/WebUI/style.css new file mode 100644 index 0000000..cc9ec66 --- /dev/null +++ b/WebUI/style.css @@ -0,0 +1,10 @@ +:root{color-scheme:dark;--bg:#0b0f16;--panel:#111722;--line:rgba(164,189,210,.12);--text:#e7eff7;--muted:#8190a4;--cyan:#64e4ec;--amber:#f5c46c} +*{box-sizing:border-box}html,body{height:100%;margin:0;overflow:hidden;background:var(--bg);font-family:Inter,"Segoe UI",Arial,sans-serif;color:var(--text);user-select:none;-webkit-user-select:none}button,input,select{font:inherit}button{cursor:pointer}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--cyan);outline-offset:2px}#app{height:100%;min-height:440px;display:flex;flex-direction:column;background:radial-gradient(ellipse at 32% 0%,#172431 0%,transparent 48%),var(--bg)} +.top{height:68px;min-height:68px;display:flex;align-items:center;justify-content:space-between;padding:0 25px;border-bottom:1px solid var(--line);gap:12px}.brand{display:flex;gap:11px;align-items:center}.logo{position:relative;display:grid;place-items:center;width:39px;height:39px;font-size:29px;font-weight:800;color:#e4f7ff;letter-spacing:-5px;border:1px solid #314456;border-radius:12px;background:linear-gradient(140deg,#233645,#0c151f);box-shadow:0 4px 18px #02070d}.logo .mark{font-size:11px;color:var(--cyan);transform:translate(-1px,5px)}.brand-text{display:flex;flex-direction:column;gap:2px}.brand-text strong{font-size:21px;letter-spacing:-1px}.brand-text strong span{color:var(--cyan);font-weight:400}.brand-text small{font-size:8px;letter-spacing:2px;color:#8797a8}.top-center{font-size:10px;letter-spacing:1.7px;color:#abc0d1;display:flex;align-items:center;gap:9px}.dot{background:var(--cyan);width:5px;height:5px;box-shadow:0 0 10px var(--cyan);border-radius:50%}.top-actions{display:flex;align-items:center;gap:12px}.subtle{border:1px solid #304052;border-radius:7px;color:#d1e0ea;background:linear-gradient(#182330,#121b26);padding:8px 11px;font-size:10px;font-weight:700;letter-spacing:.6px}.subtle:hover{background:#223446}.version{font:10px Consolas,monospace;color:#697e92}.top-actions button#helpBtn{min-width:32px;font-size:13px}.top-actions #spectrumStatus{color:var(--cyan)} +.workspace{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 294px}.graph-shell{min-width:0;display:flex;flex-direction:column;padding:15px 18px 8px 20px;gap:0}.graph-toolbar{height:43px;display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.graph-titles{display:flex;flex-direction:column;gap:7px}.graph-titles b{font-size:10px;letter-spacing:1.9px;color:#a6b6c5}.graph-titles span{font:10px Consolas,monospace;color:#788b9d}.legend{white-space:nowrap;color:#869bad;font-size:9px;letter-spacing:.8px;display:flex;align-items:center;gap:5px;padding-top:5px}.legend-dot{width:6px;height:6px;display:inline-block;border-radius:50%;margin-left:7px}.legend-dot.input{background:#718192}.legend-dot.output{background:#7fbf98}.legend-dot.equalizer{background:var(--cyan)} +.graph-wrap{position:relative;flex:1;min-height:240px;overflow:hidden;border-radius:12px;border:1px solid #314050;background:linear-gradient(180deg,rgba(23,34,47,.88),rgba(12,19,29,.98));box-shadow:inset 0 0 40px rgba(0,0,0,.24),0 18px 35px rgba(0,0,0,.12);cursor:crosshair;touch-action:none}.graph-wrap canvas{display:block;width:100%;height:100%}.graph-overlay{position:absolute;pointer-events:none;background:#0c1827e8;border:1px solid #426078;border-radius:8px;padding:8px 10px;box-shadow:0 8px 25px #0009;font-size:11px;white-space:nowrap}.graph-footer{display:flex;justify-content:space-between;margin:8px 2px 11px;color:#748598;font:10px Consolas,monospace;letter-spacing:1px}.graph-footer span:nth-child(2){letter-spacing:2px;font-size:9px;color:#586c7e} +.bottom-rail{min-height:66px;border-top:1px solid var(--line);padding-top:11px}.rail-title{display:flex;align-items:center;gap:9px;font-size:9px;letter-spacing:1.4px;font-weight:700;color:#8899ab}.rail-indicator{width:7px;height:7px;border:1px solid #60dae7;border-radius:2px;transform:rotate(45deg)}#bandCount{font:10px Consolas,monospace;color:var(--cyan)}.band-rail{display:flex;gap:7px;overflow-x:auto;padding:9px 0 2px;scrollbar-width:thin}.band-chip{color:#a9bdd0;font:10px Consolas,monospace;border:1px solid #2b3949;background:#121c28;border-radius:6px;padding:5px 8px;min-width:48px;text-align:center}.band-chip.on{border-color:var(--chip,#67e2e8);background:#1d2b36}.band-chip.selected{box-shadow:0 0 0 1px #ffffffaa inset}.band-chip:hover{background:#263647} +.inspector{border-left:1px solid #2b3846;background:linear-gradient(165deg,#141d29,#111722 63%);display:flex;flex-direction:column;padding:19px 18px 14px;min-height:0;overflow:auto}.inspector-heading{height:29px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);padding-bottom:13px;font-size:10px;letter-spacing:1.5px;font-weight:700;color:#aabbcb}.mini-tag{font-size:8px;letter-spacing:.6px;color:#7a91a5;border:1px solid #344250;border-radius:4px;padding:4px 5px}.empty-inspector{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:12px;min-height:150px}.empty-orb{width:66px;height:66px;border-radius:50%;border:1px dashed #517e8b;color:#5dcad1;display:grid;place-items:center;font-size:33px;background:#162937}.empty-inspector strong{font-size:15px}.empty-inspector p{text-align:center;font-size:11px;line-height:1.8;color:#8499ac;margin:0}.band-inspector{padding-top:16px;flex:1}.band-inspector[hidden],.empty-inspector[hidden],.graph-overlay[hidden]{display:none}.band-identity{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}.band-identity>div{display:flex;align-items:center;gap:8px}.band-identity b{font-size:16px}.band-dot{height:10px;width:10px;border-radius:50%;background:var(--cyan);box-shadow:0 0 13px currentColor}.enable-btn{padding:6px 7px;font-size:10px;border:1px solid #307566;background:#142c2b;color:#74f0bd;border-radius:5px}.enable-btn.off{background:#232733;border-color:#424a57;color:#8793a5}.field-group{margin:13px 0 16px}.field-group>label,.metric-grid label{font-size:9px;letter-spacing:1.2px;color:#7f91a3;font-weight:700;display:block}.field-group select,.metric select{margin-top:8px;width:100%;height:37px;background:#0b131d;color:#dcebf8;border:1px solid #324354;border-radius:6px;padding:0 9px;outline:none;cursor:pointer}.metric-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-bottom:13px}.metric{margin-top:8px;background:#0b131d;border:1px solid #324354;border-radius:6px;height:42px;display:flex;align-items:center;padding:0 9px}.metric:focus-within{border-color:#5aa9bd}.metric input{width:100%;min-width:0;font:15px Consolas,monospace;background:transparent;color:#e3f5fa;border:none;outline:0}.metric input::-webkit-inner-spin-button{-webkit-appearance:none}.metric span{font:10px Consolas,monospace;color:#8c9fb0}.metric select{margin:0;padding:0;background:transparent;border:0;color:#deebf7;font-size:10px}.route-group{display:grid;grid-template-columns:repeat(5,1fr);gap:3px;margin-top:9px}.route-group button{height:34px;padding:0;border:1px solid #2d3d4d;border-radius:5px;background:#0c151f;color:#a2b2c1;font-size:9px}.route-group button.active{background:#17414b;border-color:#3cb5c3;color:#92f6ff}.inspector-bottom{margin-top:22px;padding:14px 0;border-top:1px solid #293847;display:flex;align-items:center;justify-content:space-between}.note-info{display:flex;flex-direction:column;gap:5px}.note-info span{font-size:9px;color:#8296a6;letter-spacing:1px}.note-info b{font:15px Consolas,monospace;color:var(--amber)}.remove-btn{font-size:9px;letter-spacing:1px;background:#2b2026;color:#e5a2a9;border:1px solid #50313a;border-radius:6px;padding:10px}.remove-btn:hover{background:#3c2832}.quick-help{margin-top:auto;border-top:1px solid var(--line);padding-top:12px;color:#8195a7;font-size:10px}.quick-help b{display:block;font-size:9px;letter-spacing:1.4px;margin-bottom:8px;color:#a6b5c4}.quick-help div{padding:4px 0}.quick-help kbd{display:inline-block;min-width:25px;background:#263342;color:#cedde9;font:9px Consolas,monospace;text-align:center;padding:4px 5px;border-radius:4px;margin-right:7px} +.status{height:33px;min-height:33px;border-top:1px solid var(--line);background:#0a0e14;display:flex;justify-content:space-between;align-items:center;padding:0 19px;gap:8px;color:#6f8194;font:9px Consolas,monospace;letter-spacing:.3px}.status span:first-child{color:#8aafaa}.connection{display:inline-block;width:6px;height:6px;background:#748899;border-radius:50%;margin-right:5px}.connection.ready{background:#4bdaa9;box-shadow:0 0 8px #3bdfbd} +@media(max-width:910px){.workspace{grid-template-columns:minmax(0,1fr) 252px}.inspector{padding:15px 12px}.graph-shell{padding-left:12px;padding-right:12px}.top-center{display:none}.quick-help{display:none}.graph-titles span{font-size:9px}.legend{font-size:8px}.top{padding:0 14px}} +@media(max-height:575px){.top{height:53px;min-height:53px}.graph-toolbar{height:31px}.bottom-rail{min-height:56px}.graph-footer{margin-bottom:6px}.inspector-bottom{margin-top:8px}.field-group{margin:8px 0}.band-identity{margin-bottom:8px}.quick-help{display:none}} diff --git a/docs/ARD.md b/docs/ARD.md index 5bc50d2..ac55bbd 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -94,3 +94,20 @@ The graph caches a 2x2 complex transfer matrix for the full cascade, including L The fixed APVTS parameter IDs remain unchanged. The project now tests single-thread finite/RT stress, measured sine gain against the analytic curve, switch continuity, no heap allocations during process, ring buffer overflow and concurrent producer-consumer integrity. CI efficiency: one small Linux headless job and one Windows VST3 job that also runs the headless tests; avoid a duplicate Windows headless matrix. CI begins only after a coherent multi-file milestone commit, not after each individual edit. + + +## M2 GUI Architecture — native DSP + bundled JUCE WebView2 shell + +**Decision**: User explicitly requested porting MaSonKuPik EQ presentation, with an optimized web GUI. On Windows the editor uses JUCE 9.0.4 WebBrowserComponent with the WebView2 backend. Assets are three embedded local-only files: `WebUI/index.html`, `style.css`, `app.js`. There are **no npm runtime dependencies**, React, Tailwind, live web requests, localhost server, remote fonts, Web Audio DSP, or online CDNs. Windows native JUCE editor remains as a fallback if WebView2 options are unsupported; the DSP and VST3 parameters are unchanged. + +**Bridge and ownership**: +- C++ reads the authoritative 168 APVTS host parameters (24 slots x 7) on the editor message thread at 25Hz. Browser can only submit allow-listed `enabled/type/route/freq/gain/q/slope` commands via one `eq-command` listener. Numeric values and indices are bounded. Gestures (`begin` / `edit` / `end`) use `beginChangeGesture`, `setValueNotifyingHost`, `endChangeGesture` to preserve host automation. +- UI response curves are computed from the **same native DSP transfer matrix**, including stereo L/R and M/S; transmitted only on changed bands, sample rate, or selected band (256 log-spaced points). No offline Web Audio simulation or JS filter coefficients. +- Pre/post audio telemetry enters existing fixed-size SPSC queue; the message thread performs FFT and sends 224 log bins via a bounded 25Hz event. The WebView does **not** call native audio processing, use Web Audio, or access the audio callback. +- Canvas 2D retains MaSonKuPik interaction logic (double-click to add/remove, pointer drag, wheel Q/slope, notes and inspector), but uses a new self-contained DOM/Canvas implementation to avoid shipping its entire mastering app and dependency graph. Rendering is event-driven: only repaint after changed state or spectrum and maintain a 2x maximum device pixel ratio. +- Embedded resource provider only serves exact static resource paths; page navigation is limited to local resource root; CSP denies all external origins. Avoid security expansion by never loading third-party pages in a native-integrated WebView. +- WebView2 is a Chromium runtime and may use more baseline memory than JUCE's native editor. A tiny JS bundle is not the same as a zero-cost WebView2 process. Measure resident memory, first-open time, CPU and multi-instance behavior on Windows before calling the UI "ultra-lightweight". + +**CI**: Javascript syntax + no-dependency mock-DOM smoke on Linux; Windows build checks pinned WebView2 SDK headers/loader and embeds the assets into the VST3 artifact. Use a cached pinned NuGet SDK and retain native DSP test suites. Real DAW/WebView2 runtime inspection remains a gate. + +**Compatibility**: Never change existing host parameter IDs, plug-in ID, manufacturer ID, plugin binary format, state schema or audio process methods just to support GUI redesign. Native editor must remain available as a recovery path. If runtime initialization fails after CMake-supported capability probe, report failure and improve fallback rather than claiming success. diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md index 8dc7493..069b0bc 100644 --- a/docs/MIGRATION.md +++ b/docs/MIGRATION.md @@ -27,3 +27,10 @@ Reference links: - https://www.fabfilter.com/news/1543478400/fabfilter-releases-fabfilter-pro-q-3-equalizer-plug-in-with-dynamic-eq - https://github.com/juce-framework/JUCE - https://www.steinberg.net/developers/vstsdk/ + + +## M2 web UI port decision and origin + +Ported the *interaction contract* and aesthetic structure observed in `masonkupik/src/components/plugins/EQEditor.tsx`: dragging frequency/gain, per-band shape selection, wheel Q/slope, colorful handles, selected-band ghost curve, dark log-grid and a pre/post analyzer behind the response. The ArSonEQ implementation is rewritten as `WebUI/{index.html,style.css,app.js}` with no React, Zustand, Lucide, @/ imports, browser mastering chain, offline AudioContext, external fonts, build toolchain, or MaSonKuPik presets. It uses existing native JUCE/APVTS parameter IDs and native C++ response coefficients. + +The source MaSonKuPik app remains private and its files are not exported into the public destination. Avoid copying unrelated third-party UI assets and commercial FabFilter artwork. Similar *usability standards* are an inspiration, not a claim of Pro-Q3 design or feature parity. diff --git a/docs/PRD.md b/docs/PRD.md index ee2c8c1..f67c243 100644 --- a/docs/PRD.md +++ b/docs/PRD.md @@ -71,3 +71,8 @@ Do not copy FabFilter branding, logos, code, proprietary filter algorithms, exac ## 8. Release acceptance VST3 validator, host projects, automation/snapshot recall, phase/frequency/impulse tests, soak stress, CPU/memory benchmark and at least two real audio listening scenarios must pass before declaring production. Release artifacts must be traceable to a pinned commit and have an actual reproducible build. + + +## P1 premium web UI product requirements — MaSonKuPik-inspired editor + +The Windows VST3 ships a complete offline self-contained HTML/CSS/Canvas GUI through JUCE WebView2. The full DSP remains portable C++ and continues working if GUI/WebView2 cannot start. User-visible P1 needs: rich logarithmic graph, input/output spectrum, exact native response, eight rotating band palettes, click/drag handles, wheel Q or cut slope, double-click add/delete, inspector with numerical frequency/gain/Q controls and shape/slope/channel selectors, status and nearest musical note. Performance intent: no React rendering loop, no network access, at most 25Hz analyzer push from C++, capped DPR, event-driven redraw when idle. No claim of absolute low memory is permitted until WebView2 and native editor are benchmarked on actual Windows hardware. The plugin must remain useful in supported DAWs and preserve all 168 parameter identities and project-state persistence. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 12abe2f..6183239 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -30,3 +30,16 @@ All contributors and parallel ChatGPT threads must read PRD + ARD + this file ** - **CI policy:** headless Linux + combined Windows plugin/native tests. Do not rerun unrelated workflows. Note that Windows VST3 compilation is **not** a DAW validation. - **Next release blockers:** host VST3 validation (pluginval/Steinberg validator), REAPER and a second DAW load/state/automation testing, click/noise golden captures, CPU profiling at 32/64/128 buffers, independent review of sample-rate change lifecycle. - **Next user features:** coherent band inspector and numeric editing, A/B, undo; dynamic EQ with proper envelope and sidechain only after the real-time foundation is validated. + + +### M2 — MaSonKuPik UI port / premium compact native-web hybrid + +- [x] Implement standalone browser UI bundle (HTML/CSS/Canvas 2D and vanilla JS) with 24-band editing, premium dark appearance, interactive frequency graph and inspector. +- [x] Use native JUCE WebBrowserComponent/WebView2 editor with local-only embedded resources, allow-listed host parameter updates, host gestures and native fallback. +- [x] Drive spectrum and exact filter-response curves from the C++ DSP and existing lock-free ring; no JavaScript DSP or React build tool. +- [x] Add CI javascript syntax and bridge wiring mock-DOM smoke test. +- [ ] Validate host loads web UI rather than native fallback on a real Windows WebView2 runtime; test resizes, multiple instances, keyboard focus, automation, DAW save/restore. +- [ ] Measure first-open latency, idle memory footprint, 25Hz analyzer UI CPU, 32/64/128 audio buffers and performance with many bands. +- [ ] Production GUI enhancements: coherent undo/redo and A/B, spectral analyzer calibration, keyboard navigation, touch ergonomics, peak-hold; then Dynamic EQ engine work. + +Do not mark M2 DAW-validated based solely on the Windows compilation or mock-DOM smoke check. From d5799629882627a7d69f2749b9a086d227de81e9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 21:34:58 +0700 Subject: [PATCH 09/23] fix(M2): WebView lifecycle safety, binary-data types and bridge smoke harness --- README.md | 4 ++++ Source/WebEditor.cpp | 23 +++++++++++++++++------ Source/WebEditor.h | 5 +++++ WebUI/smoke.test.cjs | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c8223ce..dfd9d3d 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,7 @@ On Windows, the editor prefers a **premium dark HTML/CSS/Canvas 2D UI** hosted b Control map: double-click empty canvas to create a bell filter, double-click an existing node to remove; drag for frequency/gain; wheel over a node for Q or cut slope; click for inspector; route filters to Stereo/L/R/Mid/Side; edit numeric frequency/gain/Q in the right inspector; Delete removes selected band. Native APVTS parameter IDs are not changed. The response curve is computed in the C++ DSP, and a bounded 25Hz FFT stream from the editor's native queue drives the input/output spectrum behind the curve. Source `WebUI/` is deliberately tiny and zero-dependency. Run `node --check WebUI/app.js && node WebUI/smoke.test.cjs` for an offline bridge wiring smoke check. This is NOT a substitute for actual DAW/WebView2 UI testing, host recall validation or CPU/memory profiling. + +### Windows fallback + +Set environment variable `ARSONEQ_USE_NATIVE_GUI=1` before launching your DAW to force the original JUCE native editor if WebView2 is unsupported or fails in the host. Restart the host to make it take effect. The embedded JS is not an audio dependency; DSP processing remains available without any GUI. diff --git a/Source/WebEditor.cpp b/Source/WebEditor.cpp index c5305ec..be73bca 100644 --- a/Source/WebEditor.cpp +++ b/Source/WebEditor.cpp @@ -12,7 +12,7 @@ juce::var makeObject() { return juce::var(new juce::DynamicObject()); } void property(juce::var& object,const char* key,juce::var value) { object.getDynamicObject()->setProperty(juce::Identifier(key),std::move(value)); } -juce::WebBrowserComponent::Options browserOptions(ArSonEQWebEditor* owner, +juce::WebBrowserComponent::Options browserOptions( std::function command, std::function(const juce::String&)> resource) { using Web=juce::WebBrowserComponent; @@ -36,13 +36,16 @@ bool ArSonEQWebEditor::supported() { // Do not silently fall back to legacy Internet Explorer: it can't run this // modern Canvas UI and would expose a blank / broken editor. using Web=juce::WebBrowserComponent; + if(juce::SystemStats::getEnvironmentVariable( + "ARSONEQ_USE_NATIVE_GUI","")=="1") + return false; return Web::areOptionsSupported(Web::Options{} .withBackend(Web::Options::Backend::webview2)); } std::optional ArSonEQWebEditor::resource(const juce::String& url) { - const unsigned char* ptr=nullptr; + const char* ptr=nullptr; int length=0; juce::String mime; if(url=="/"||url=="/index.html") { @@ -61,10 +64,14 @@ ArSonEQWebEditor::resource(const juce::String& url) { } ArSonEQWebEditor::ArSonEQWebEditor(ArSonEQAudioProcessor& p) : AudioProcessorEditor(p),processor_(p), - browser_(browserOptions(this, + browser_(browserOptions( [this](const juce::var& message){ onCommand(message); }, [](const juce::String& url){ return resource(url); })) { setOpaque(true); + browser_.onLoaded=[this] { + pageLoaded_=true; + if(ready_)sendState(true); + }; addAndMakeVisible(browser_); setResizable(true,true); setResizeLimits(820,490,1680,1000); @@ -139,7 +146,11 @@ void ArSonEQWebEditor::gesture(int id,const juce::var& fields,bool begin) { void ArSonEQWebEditor::onCommand(const juce::var& message) { if(!message.isObject())return; const auto kind=message.getProperty("kind",{}).toString(); - if(kind=="ready") {ready_=true;sendState(true);return;} + if(kind=="ready") { + ready_=true; + if(pageLoaded_)sendState(true); + return; + } const int id=static_cast(message.getProperty("id",-1)); if(kind=="select") { selected_=id>=0&&id bands; @@ -213,7 +224,7 @@ void ArSonEQWebEditor::sendSpectrum() { head_=(head_+1)&(fftSize_-1); ++framesSeen_;++framesSinceFFT_;++drained; } - if(!ready_||framesSeen_(i))&(fftSize_-1); diff --git a/Source/WebEditor.h b/Source/WebEditor.h index ce0f8e9..aa69c6e 100644 --- a/Source/WebEditor.h +++ b/Source/WebEditor.h @@ -17,6 +17,10 @@ class ArSonEQWebEditor final : public juce::AudioProcessorEditor, private: class LocalBrowser final : public juce::WebBrowserComponent { public: + std::function onLoaded; + void pageFinishedLoading(const juce::String&) override { + if(onLoaded)onLoaded(); + } explicit LocalBrowser(const juce::WebBrowserComponent::Options& options) : juce::WebBrowserComponent(options) {} bool pageAboutToLoad(const juce::String& url) override { @@ -47,5 +51,6 @@ class ArSonEQWebEditor final : public juce::AudioProcessorEditor, int framesSinceFFT_=0; int selected_=-1; bool ready_=false; + bool pageLoaded_=false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ArSonEQWebEditor) }; \ No newline at end of file diff --git a/WebUI/smoke.test.cjs b/WebUI/smoke.test.cjs index 56a5fa3..fc7ff43 100644 --- a/WebUI/smoke.test.cjs +++ b/WebUI/smoke.test.cjs @@ -26,7 +26,7 @@ function element(id) { } const ctx={ fillRect(){},beginPath(){},moveTo(){},lineTo(){},stroke(){},fill(){}, - arc(){},save(){},restore(){},fillText(){},setTransform(){}, + arc(){},closePath(){},save(){},restore(){},fillText(){},setTransform(){}, createLinearGradient(){return{addColorStop(){}};} }; const document={activeElement:null, From 8d209f6a2d51e8840f881d01bdadcc26f06187fc Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 22:11:15 +0700 Subject: [PATCH 10/23] feat(M2.1): compact full-canvas EQ with ArSonMix chrome and contextual band inspector --- README.md | 7 ++++ Source/WebEditor.cpp | 5 ++- WebUI/app.js | 98 ++++++++++++++++++++++++++++++-------------- WebUI/index.html | 70 +++++++++++++++++++------------ WebUI/smoke.test.cjs | 14 +++++++ WebUI/style.css | 24 ++++++----- docs/ARD.md | 12 ++++++ docs/PRD.md | 4 ++ docs/ROADMAP.md | 9 ++++ 9 files changed, 173 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index dfd9d3d..8c01759 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,10 @@ Source `WebUI/` is deliberately tiny and zero-dependency. Run `node --check WebU ### Windows fallback Set environment variable `ARSONEQ_USE_NATIVE_GUI=1` before launching your DAW to force the original JUCE native editor if WebView2 is unsupported or fails in the host. Restart the host to make it take effect. The embedded JS is not an audio dependency; DSP processing remains available without any GUI. + + +## M2.1 — Compact premium editor + +Based on user-provided screenshots comparing Pro-Q 3, ArSonMix and ArSonEQ, the first WebView2 UI was redesigned around a **full-width EQ graph**. Initial WebView2 editor size is **900 × 535** (host title bar excluded), resizable from 760 × 455. Selected nodes open a small movable-by-anchor floating filter popup rather than occupying a permanent empty 294px sidebar. The top/bottom rails are compact, frequencies and dB labels remain visible in the graph, and the active-band list is available from the BANDS button. The materials follow ArSonMix's dark glass workspace / aluminum control / turquoise status language without copying third-party graphical assets. A no-network, no-React JavaScript/Canvas editor is still bundled into the VST3. + +Controls: single-click a node to select and open floating controls; click empty canvas to dismiss; double-click to add/delete; drag Hz/dB; wheel to change Q/slope; click BANDS for other active bands, ? for concise help. The existing native fallback and DAW automation parameters are preserved. Native host visual QA, memory/CPU data and pluginval remain necessary before calling the GUI production-ready. diff --git a/Source/WebEditor.cpp b/Source/WebEditor.cpp index be73bca..b163a7d 100644 --- a/Source/WebEditor.cpp +++ b/Source/WebEditor.cpp @@ -74,7 +74,8 @@ ArSonEQWebEditor::ArSonEQWebEditor(ArSonEQAudioProcessor& p) }; addAndMakeVisible(browser_); setResizable(true,true); - setResizeLimits(820,490,1680,1000); + // Full-canvas EQ fits a normal DAW floating plugin window (~Pro-Q aspect). + setResizeLimits(760,455,1360,850); graphEngine_.prepare(p.configuredSampleRate()); window_.fill(0.0f); for(int i=0;i::pi*i/(fftSize_-1))); levelsPre_.fill(-108.f); levelsPost_.fill(-108.f); - setSize(1110,680); + setSize(900,535); processor_.analyzer().setEnabled(true); browser_.goToURL(juce::WebBrowserComponent::getResourceProviderRoot()); startTimerHz(25); diff --git a/WebUI/app.js b/WebUI/app.js index 6abad74..d207050 100644 --- a/WebUI/app.js +++ b/WebUI/app.js @@ -7,7 +7,7 @@ const $=id=>document.getElementById(id); const canvas=$("eqCanvas"), wrap=$("graphWrap"), ctx=canvas.getContext("2d",{alpha:false}); const TYPES=["Bell","Low Shelf","High Shelf","Low Cut","High Cut","Notch"]; -const COLORS=["#ff936f","#ffd07a","#9fe37f","#57dcca","#63bde9","#b194fa","#ed98d9","#ef8eb4"]; +const COLORS=["#ff9473","#e5b855","#a99aff","#77d5a4","#53ccd2","#b58eea","#eb87a9","#78b6e9"]; const F0=20,F1=20000,RANGE=18,MAX=24; const clamp=(x,a,b)=>Math.max(a,Math.min(b,x)); const hzX=(f,w)=>Math.log(clamp(f,F0,F1)/F0)/Math.log(F1/F0)*w; @@ -38,6 +38,8 @@ const setParam=(id,field,value,gesture=true)=>{ }; const select=i=>{ selected=(i>=0&&i{ chip.onclick=()=>select(i);rail.appendChild(chip); } }; +const positionInspector=()=>{ + if(selected<0||$("inspector").hidden)return; + const b=bands[selected],panel=$("inspector"); + const pw=panel.offsetWidth||466,ph=panel.offsetHeight||174; + const x=hzX(b.freq,w),y=dbY(isCut(b.type)?0:b.gain,h); + const px=clamp(x-pw*.5,10,Math.max(10,w-pw-10)); + const roomBelow=h-y-22,roomAbove=y-30; + let py=roomBelow>=ph+10?y+19:roomAbove>=ph+10?y-ph-19:h-ph-12; + py=clamp(py,33,Math.max(33,h-ph-12)); + panel.style.left=Math.round(px)+"px"; + panel.style.top=Math.round(py)+"px"; +}; const renderInspector=()=>{ const b=selected>=0?bands[selected]:null; - $("emptyInspector").hidden=!!b;$("bandInspector").hidden=!b; - $("activeLabel").textContent=b?"BAND "+String(selected+1).padStart(2,"0"):"NO SELECTION"; + $("inspector").hidden=!b; + $("emptyInspector").hidden=true; + $("bandInspector").hidden=!b; if(!b)return; - $("bandTitle").textContent="Band "+String(selected+1).padStart(2,"0"); + $("activeLabel").textContent=["STEREO","LEFT","RIGHT","MID","SIDE"][b.route]||"STEREO"; + $("bandTitle").textContent="BAND "+String(selected+1).padStart(2,"0"); $("bandDot").style.background=col(selected); - $("enableBtn").textContent=b.enabled?"● ACTIVE":"○ BYPASSED"; + $("enableBtn").textContent=b.enabled?"● ON":"○ OFF"; $("enableBtn").classList.toggle("off",!b.enabled); $("typeSelect").value=String(b.type); $("slopeSelect").value=String(b.slope); @@ -96,7 +112,9 @@ const renderInspector=()=>{ $("gainInput").disabled=isCut(b.type)||b.type===5; $("slopeSelect").disabled=!isCut(b.type); $("noteLabel").textContent=noteFor(b.freq); - $("routeGroup").querySelectorAll("button").forEach(btn=>btn.classList.toggle("active",Number(btn.dataset.route)===b.route)); + $("routeGroup").querySelectorAll("button").forEach(btn=> + btn.classList.toggle("active",Number(btn.dataset.route)===b.route)); + positionInspector(); }; const mapLocal=e=>{const r=canvas.getBoundingClientRect();return{x:clamp(e.clientX-r.left,0,r.width),y:clamp(e.clientY-r.top,0,r.height)};}; const drawSmooth=(arr,color,lineWidth=2,fill=false,alpha=1)=>{ @@ -109,9 +127,9 @@ const drawSmooth=(arr,color,lineWidth=2,fill=false,alpha=1)=>{ if(fill){ ctx.lineTo(w,h/2);ctx.lineTo(0,h/2);ctx.closePath(); const grad=ctx.createLinearGradient(0,0,0,h); - grad.addColorStop(0,"rgba(89,227,235,.24)"); - grad.addColorStop(.5,"rgba(70,206,218,.07)"); - grad.addColorStop(1,"rgba(68,199,212,.13)"); + grad.addColorStop(0,"rgba(69,199,218,.15)"); + grad.addColorStop(.5,"rgba(69,199,218,.035)"); + grad.addColorStop(1,"rgba(69,199,218,.09)"); ctx.fillStyle=grad;ctx.fill(); } ctx.beginPath(); @@ -136,8 +154,8 @@ const drawSpectrum=(values,color,fill)=>{ if(fill){ ctx.lineTo(w,h);ctx.lineTo(0,h);ctx.closePath(); const grad=ctx.createLinearGradient(0,0,0,h); - grad.addColorStop(0,"rgba(81,187,157,.25)"); - grad.addColorStop(1,"rgba(45,133,122,.02)"); + grad.addColorStop(0,"rgba(90,196,163,.18)"); + grad.addColorStop(1,"rgba(66,134,117,.012)"); ctx.fillStyle=grad;ctx.fill(); }else{ ctx.strokeStyle=color;ctx.lineWidth=.85;ctx.globalAlpha=.5;ctx.stroke();ctx.globalAlpha=1; @@ -146,44 +164,51 @@ const drawSpectrum=(values,color,fill)=>{ const draw=()=>{ if(w<2||h<2)return; ctx.save();ctx.setTransform(dpr,0,0,dpr,0,0); - ctx.fillStyle="#101a27";ctx.fillRect(0,0,w,h); + ctx.fillStyle="#181820";ctx.fillRect(0,0,w,h); const bg=ctx.createLinearGradient(0,0,0,h); - bg.addColorStop(0,"rgba(23,41,55,.28)");bg.addColorStop(1,"rgba(7,13,23,.45)"); + bg.addColorStop(0,"rgba(29,34,43,.34)"); + bg.addColorStop(1,"rgba(7,14,21,.53)"); ctx.fillStyle=bg;ctx.fillRect(0,0,w,h); ctx.font="10px Consolas,monospace"; for(const f of [20,30,40,50,70,100,200,300,500,700,1000,2000,3000,5000,7000,10000,20000]){ const x=hzX(f,w); - ctx.strokeStyle=[20,100,1000,10000].includes(f)?"#314150":"#25313e"; + ctx.strokeStyle=[20,100,1000,10000].includes(f)?"#38414b":"#293039"; ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,h);ctx.lineWidth=.65;ctx.stroke(); if([30,50,100,200,500,1000,2000,5000,10000].includes(f)){ - ctx.textAlign="center";ctx.fillStyle="#8297a9";ctx.fillText(formatHz(f),x,h-8); + ctx.textAlign="center";ctx.fillStyle="#8d9ca9";ctx.fillText(formatHz(f),x,h-9); } } for(let db=-18;db<=18;db+=6){ const y=dbY(db,h);ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(w,y); - ctx.lineWidth=db===0?1.15:.7;ctx.strokeStyle=db===0?"#607383":"#2b3a48";ctx.stroke(); - ctx.fillStyle="#7990a2";ctx.textAlign="right"; - ctx.fillText((db>0?"+":"")+db+" dB",w-10,clamp(y-7,11,h-20)); + ctx.lineWidth=db===0?1.3:.65; + ctx.strokeStyle=db===0?"#a28347":"#30353d";ctx.stroke(); + ctx.fillStyle=db===0?"#f0c76b":"#93a0ad";ctx.textAlign="right"; + ctx.fillText((db>0?"+":"")+db,w-8,clamp(y-7,22,h-22)); } if(showSpectrum){drawSpectrum(spec.post,"#71cfb3",true);drawSpectrum(spec.pre,"#7897ab",false);} if(selected>=0&&bands[selected]?.enabled&&curves.band?.length){ drawSmooth(curves.band,col(selected),1.3,true,.55); } - drawSmooth(curves.l,"#65e8f3",2.5,true,1); - drawSmooth(curves.r,"#f5ca80",1.05,false,.73); + drawSmooth(curves.l,"#70e9d0",2.0,true,.98); + // Only show two channel response lines when they differ materially. + const distinct=curves.l?.length===curves.r?.length&&curves.l?.some((v,i)=>Math.abs(v-curves.r[i])>.12); + if(distinct)drawSmooth(curves.r,"#f1bf74",1.3,false,.87); // The physical crossfeed curve is hidden to avoid a misleading -108dB line. for(let i=0;i{ dpr=Math.min(2,window.devicePixelRatio||1); const cw=Math.max(1,Math.round(w*dpr)),ch=Math.max(1,Math.round(h*dpr)); if(canvas.width!==cw||canvas.height!==ch){canvas.width=cw;canvas.height=ch;} - if(oldW!==w||oldH!==h)changed(); + if(oldW!==w||oldH!==h){positionInspector();changed();} }; new ResizeObserver(resize).observe(wrap); window.addEventListener("resize",resize); @@ -209,7 +234,7 @@ function applyHostState(data){ if(dragging){ const b=bands[dragging.id];if(b){b.freq=dragging.freq;b.gain=dragging.gain;} } if(data.curve){curves=data.curve;} $("stateInfo").textContent="24 BANDS / "+(samplerate/1000).toFixed(1)+" kHz / ZERO LATENCY"; - $("bridgeStatus").innerHTML=' NATIVE DSP CONNECTED'; + $("bridgeStatus").textContent="NATIVE DSP CONNECTED"; renderInspector();renderRail();changed(); } function applySpectrum(data){ @@ -310,9 +335,20 @@ $("routeGroup").addEventListener("click",e=>{ if(selected>=0&&btn)setParam(selected,"route",Number(btn.dataset.route)); }); $("viewBtn").onclick=()=>{ - showSpectrum=!showSpectrum;$("spectrumStatus").textContent=showSpectrum?"ON":"OFF";changed(); + showSpectrum=!showSpectrum; + $("spectrumStatus").textContent=showSpectrum?"ON":"OFF"; + $("viewBtn").classList.toggle("active",showSpectrum); + changed(); +}; +$("bandsBtn").onclick=()=>{ + $("quickHelp").hidden=true; + $("bandList").hidden=!$("bandList").hidden; +}; +$("helpBtn").onclick=()=>{ + $("bandList").hidden=true; + $("quickHelp").hidden=!$("quickHelp").hidden; }; -$("helpBtn").onclick=()=>$("quickHelp").scrollIntoView({behavior:"smooth",block:"nearest"}); +$("closeInspector").onclick=()=>select(-1); window.addEventListener("keydown",e=>{ if(e.target.matches("input,select"))return; if((e.key==="Delete"||e.key==="Backspace")&&selected>=0){ diff --git a/WebUI/index.html b/WebUI/index.html index 69ea9b1..658af7f 100644 --- a/WebUI/index.html +++ b/WebUI/index.html @@ -1,33 +1,49 @@ - + + -ArSonEQ Studio - -
-
ArSonEQPRECISION PARAMETRIC EQUALIZER
-
24-BAND / ZERO LATENCY
-
v0.2 TEST
-
-
-
FREQUENCY RESPONSEHover spectrum for frequency
-
INPUT OUTPUT EQ
+ArSonEQ +
+
+
A◢
ArSonEQ
PARAMETRIC EQ
+
‹24 BANDS · ZERO LATENCY›
+
+
+
+
+ + +
+ SPECTRAL RESPONSE + Double-click to add an EQ band
-
- -
ACTIVE BANDS 0 / 24
-
- -
-
CONNECTING TO AUDIO ENGINEDESIGNED FOR HOST AUTOMATION · 24 FIXED SLOTSARSÓN AUDIO LAB
+
+ + + +
+ + + +
\ No newline at end of file diff --git a/WebUI/smoke.test.cjs b/WebUI/smoke.test.cjs index fc7ff43..c63da62 100644 --- a/WebUI/smoke.test.cjs +++ b/WebUI/smoke.test.cjs @@ -61,11 +61,25 @@ assert.ok(element("bandCount").textContent.includes("1 / 24"),"host band snapsho handlers["eq-spectrum"]({pre:Array(224).fill(-80),post:Array(224).fill(-75)}); element("eqCanvas").dispatch("pointerdown",{button:0,pointerId:1,clientX:452,clientY:133}); assert.ok(find("begin").length,"host gesture starts on drag"); +assert.equal(element("inspector").hidden,false,"inspector appears only when a band is selected"); +assert.ok(element("inspector").style.left.endsWith("px"),"floating inspector positioned near selected node"); element("eqCanvas").dispatch("pointermove",{pointerId:1,clientX:500,clientY:170}); element("eqCanvas").dispatch("pointerup",{pointerId:1}); assert.ok(find("end").length,"host gesture ends after drag"); assert.ok(find("edit").some(x=>x.field==="freq"),"drag automates frequency"); element("eqCanvas").dispatch("dblclick",{clientX:100,clientY:300}); assert.ok(find("add").length,"double click empty graph creates band"); +element("closeInspector").onclick(); +assert.equal(element("inspector").hidden,true,"close inspector frees entire graph"); +element("bandsBtn").onclick(); +assert.equal(element("bandList").hidden,false,"band list opens only when asked"); +element("helpBtn").onclick(); +assert.equal(element("bandList").hidden,true,"help and band menus are mutually exclusive"); +assert.equal(element("quickHelp").hidden,false,"help popover opens on demand"); +const markup=fs.readFileSync("WebUI/index.html","utf8"); +const style=fs.readFileSync("WebUI/style.css","utf8"); +assert.ok(markup.includes('class="graph-wrap"') && !markup.includes('