From fe941fe7c7ef8dd4100e71313570fb2137b07211 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 04:38:28 +0700 Subject: [PATCH 01/35] Build zero-latency compressor core, VST3 host adapter and compact editor --- .github/workflows/build.yml | 44 +++++++++ AGENTS.md | 11 +++ CMakeLists.txt | 52 +++++++++++ README.md | 59 +++++++++++- docs/ARD.md | 29 ++++++ docs/HANDOFF.md | 11 +++ docs/PRD.md | 16 ++++ docs/VALIDATION.md | 11 +++ engine/Compressor.cpp | 79 ++++++++++++++++ engine/Compressor.h | 33 +++++++ engine/MeterQueue.h | 27 ++++++ engine/Parameters.h | 54 +++++++++++ plugin/Editor.cpp | 176 ++++++++++++++++++++++++++++++++++++ plugin/Editor.h | 41 +++++++++ plugin/Processor.cpp | 73 +++++++++++++++ plugin/Processor.h | 35 +++++++ tests/Benchmark.cpp | 13 +++ tests/EngineTests.cpp | 94 +++++++++++++++++++ tests/PluginSmoke.cpp | 21 +++++ 19 files changed, 878 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 AGENTS.md create mode 100644 CMakeLists.txt create mode 100644 docs/ARD.md create mode 100644 docs/HANDOFF.md create mode 100644 docs/PRD.md create mode 100644 docs/VALIDATION.md create mode 100644 engine/Compressor.cpp create mode 100644 engine/Compressor.h create mode 100644 engine/MeterQueue.h create mode 100644 engine/Parameters.h create mode 100644 plugin/Editor.cpp create mode 100644 plugin/Editor.h create mode 100644 plugin/Processor.cpp create mode 100644 plugin/Processor.h create mode 100644 tests/Benchmark.cpp create mode 100644 tests/EngineTests.cpp create mode 100644 tests/PluginSmoke.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..560ef6e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: Validate and build +on: + pull_request: + paths: ['engine/**', 'plugin/**', 'tests/**', 'CMakeLists.txt', '.github/workflows/**'] + workflow_dispatch: +permissions: + contents: read +concurrency: + group: arson-comp-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + engine-safety: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: cmake -S . -B build -DARSON_BUILD_PLUGIN=OFF -DARSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug + - run: cmake --build build --parallel 2 + - run: ctest --test-dir build --output-on-failure + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: build/_deps/juce-src + key: juce-8.0.12-29396c22-windows + - run: cmake -S . -B build -A x64 -DCMAKE_BUILD_TYPE=Release + - run: cmake --build build --config Release --parallel 4 + - run: ctest --test-dir build -C Release --output-on-failure + - name: Plugin state and editor smoke + shell: pwsh + run: | + New-Item -ItemType Directory -Force artifacts + & ./build/plugin_smoke_artefacts/Release/plugin_smoke.exe "$pwd/artifacts/ArSonComp-preview.png" + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + & ./build/Release/engine_bench.exe | Tee-Object artifacts/benchmark.txt + - uses: actions/upload-artifact@v4 + with: + name: ArSonComp-Windows-x64-TestBuild + path: | + build/ArSonComp_artefacts/Release/VST3/ArSonComp.vst3 + build/ArSonComp_artefacts/Release/Standalone/ArSonComp.exe + artifacts/* + retention-days: 14 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e82b518 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,11 @@ +# ArSonComp engineering contract + +- Build a live compressor, not an audio editor. Keep the GUI compact, legible and visually calm. Avoid bulky cards, giant fonts and decorative controls. +- Engine must remain framework independent. Audio thread owns DSP state; no allocation, mutex, file/network I/O or dependency on a worker finishing in process/setParameters. +- One canonical parameter table in engine/Parameters.h. Stable IDs must not be renamed after release. Sanitize outside the inner sample loop. +- Do not add a worker for synchronous audio. Add workers only for demonstrably expensive non-audio tasks, with bounded queues, cancellation and joined lifetime. +- Preserve zero additional latency in the live path. Do not silently introduce lookahead or oversampling. +- Telemetry must be bounded and may drop visual data; never stall audio. GUI changes must not alter DSP results. +- Use RAII and bounded containers. Avoid fast-math, speculative approximation or SIMD unless profiling and numerical tests support it. +- Run meaningful DSP/host tests, inspect GUI renders at minimum/default size, and document unverified hardware behavior. Never claim proprietary Pro-C parity without matched-input audio comparisons. +- Group meaningful changes before CI. Do not dispatch repetitive builds or commit generated binaries/build directories. diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..73ace30 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.22) +project(ArSonComp VERSION 0.1.0 LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +option(ARSON_BUILD_PLUGIN "Build VST3 and standalone" ON) +option(ARSON_SANITIZE "Enable address/undefined sanitizers for engine tests" OFF) +add_library(arson_engine STATIC engine/Compressor.cpp) +set_target_properties(arson_engine PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(arson_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/engine) +if(MSVC) + target_compile_options(arson_engine PRIVATE /W4) +else() + target_compile_options(arson_engine PRIVATE -Wall -Wextra -Wpedantic) +endif() +if(ARSON_SANITIZE AND NOT MSVC) + target_compile_options(arson_engine PUBLIC -fsanitize=address,undefined -fno-omit-frame-pointer) + target_link_options(arson_engine PUBLIC -fsanitize=address,undefined) +endif() +include(CTest) +if(BUILD_TESTING) + find_package(Threads REQUIRED) + add_executable(engine_tests tests/EngineTests.cpp) + target_link_libraries(engine_tests PRIVATE arson_engine Threads::Threads) + add_test(NAME engine_contract COMMAND engine_tests) + add_executable(engine_bench tests/Benchmark.cpp) + target_link_libraries(engine_bench PRIVATE arson_engine) +endif() +if(ARSON_BUILD_PLUGIN) + if(DEFINED JUCE_SOURCE_DIR) + 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 29396c22c93392d6738e021b83196283d6e4d850) + FetchContent_MakeAvailable(JUCE) + endif() + juce_add_plugin(ArSonComp COMPANY_NAME "ArSon Audio" BUNDLE_ID "com.arsonaudio.comp" + PLUGIN_MANUFACTURER_CODE ArSn PLUGIN_CODE ArCp FORMATS VST3 Standalone + PRODUCT_NAME "ArSonComp" IS_SYNTH FALSE NEEDS_MIDI_INPUT FALSE NEEDS_MIDI_OUTPUT FALSE + IS_MIDI_EFFECT FALSE EDITOR_WANTS_KEYBOARD_FOCUS FALSE COPY_PLUGIN_AFTER_BUILD FALSE + VST3_CATEGORIES Fx Dynamics) + target_sources(ArSonComp PRIVATE plugin/Processor.cpp plugin/Editor.cpp) + target_compile_definitions(ArSonComp PUBLIC JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 + JUCE_VST3_CAN_REPLACE_VST2=0 JUCE_DISPLAY_SPLASH_SCREEN=0) + target_link_libraries(ArSonComp PRIVATE arson_engine juce::juce_audio_utils + PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_lto_flags) + if(BUILD_TESTING) + juce_add_console_app(plugin_smoke PRODUCT_NAME "ArSonComp smoke") + target_sources(plugin_smoke PRIVATE tests/PluginSmoke.cpp) + target_link_libraries(plugin_smoke PRIVATE ArSonComp arson_engine juce::juce_audio_utils) + endif() +endif() diff --git a/README.md b/README.md index 38d9870..9a481fa 100644 --- a/README.md +++ b/README.md @@ -1 +1,58 @@ -# arson-comp \ No newline at end of file +# ArSonComp + +A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standalone, zero added algorithmic latency. The interface prioritizes transfer curve, input/output history and gain reduction, with familiar compressor controls and an original ArSon visual identity. + +**Status: initial engineering test build, not claimed to match FabFilter's proprietary algorithms or sound.** + +## Implemented + +- Peak and 10 ms RMS detection, threshold, ratio, continuously joined soft knee, range, attack, hold and release. +- Optional envelope-dependent auto release; stereo link from independent channels to maximum-linked detection. +- Internal/external mono/stereo sidechain, high-pass/low-pass detector filters and listen. +- Input/makeup gain, dry/wet parallel compression, smoothed bypass, six factory starting points and A/B comparison. +- Stable automation IDs and versioned state recall. Mono and stereo layouts. +- Separate engine without JUCE, locks, heap allocation, I/O, worker dependencies or delay lines in processing. +- Bounded SPSC telemetry at 100 Hz; editor coalesces updates at 30 Hz, caches static grid, and repaints only the display during metering. + +Zero latency means **0 additional samples from this plugin**, not zero audio-interface/host buffering. Fast attacks can distort low-frequency material; no lookahead means transients can pass. It is a compressor, not a brickwall limiter. The current model is feed-forward, without oversampling, saturation or linear-phase filtering. + +## Build + +CMake 3.22+, C++17, JUCE pinned to commit `29396c22c93392d6738e021b83196283d6e4d850` (8.0.12). + +```sh +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build --config Release --parallel 4 +ctest --test-dir build -C Release --output-on-failure +``` + +Windows: Visual Studio 2022 or newer with C++ desktop tools; add `-A x64` when configuring. Outputs are under `build/ArSonComp_artefacts/Release/{VST3,Standalone}`. Install the **entire** `ArSonComp.vst3` bundle into your VST3 directory, then rescan your host. For standalone, choose the audio device in its audio settings. The initial Windows build uses JUCE's standard device backends; ASIO is not enabled or claimed. + +Linux prerequisites: `pkg-config libasound2-dev libx11-dev libxext-dev libxinerama-dev libxrandr-dev libxcursor-dev libfreetype6-dev libfontconfig1-dev libgl1-mesa-dev`. A display (or Xvfb) is required for the editor smoke test. + +Use `-DJUCE_SOURCE_DIR=/path/to/JUCE` to reuse a local checkout. For fast engine-only development: + +```sh +cmake -S . -B build-core -DARSON_BUILD_PLUGIN=OFF -DCMAKE_BUILD_TYPE=Release +cmake --build build-core --parallel 2 +ctest --test-dir build-core --output-on-failure +./build-core/engine_bench +``` + +Use `-DARSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug` on GCC/Clang for ASan/UBSan. Do not enable fast-math: non-finite input handling depends on IEEE semantics. + +## Live workflow + +1. Insert on a mono/stereo channel; start with Default or a vocal preset. +2. Set threshold for the desired gain reduction. Set ratio, attack and release by ear. +3. Use SC high-pass to reduce bass-triggered pumping. End stops bypass each SC filter. +4. Enable External SC only after routing a detector signal in your host. An unconnected external bus receives silence. +5. Use Listen SC to audition the detector, then turn it off. Match output loudness with Makeup before comparing A/B. + +Double-click knobs to reset; click values to type. Presets do not overwrite external sidechain, listen or bypass. A/B swaps all parameters; it is an editor-session comparison, not a second saved host program. + +## Verification and scope + +See [architecture](docs/ARD.md), [requirements](docs/PRD.md), [validation](docs/VALIDATION.md) and [handoff](docs/HANDOFF.md). CI runs on relevant PR changes or manual dispatch, cancels superseded builds, caches JUCE source and uploads one Windows VST3/standalone test artifact. Documentation-only changes do not trigger builds. + +Repository license remains AGPL-3.0. JUCE has its own AGPL/commercial terms; see its pinned source license. FabFilter names identify workflow references only; no FabFilter code, assets or algorithm claims are included. diff --git a/docs/ARD.md b/docs/ARD.md new file mode 100644 index 0000000..46a7a41 --- /dev/null +++ b/docs/ARD.md @@ -0,0 +1,29 @@ +# Architecture + +## Ownership and scheduling + +`engine/` is a C++17 static library; `plugin/Processor` adapts host buses, parameters and state; `plugin/Editor` owns presentation. DSP lifetime is independent of editor lifetime. No worker is needed for this bounded, causal processing workload. + +The processor caches APVTS atomic pointers once, then snapshots parameters once per block. Parameters are clamped/canonicalized; expensive time/filter coefficients only change when their parameter changes. Input/makeup dB conversion occurs at control updates and linear gain ramps run in audio. Five-millisecond ramps protect continuous gain/curve/mix and boolean transitions. Attack/release coefficient updates preserve the current envelope. Sidechain filter coefficients update at block boundaries; rapid cutoff automation during Listen SC still needs listening validation. + +Signal flow: input trim → detector tap → optional detector HP/LP → Peak/RMS blend → channel linking → soft-knee static reduction → attack/hold/release envelope → gain application → parallel mix → SC listen crossfade → bypass crossfade. Dry/wet paths share the same sample index. Bypass returns original input after its short transition. Non-finite input is replaced with silence; input magnitudes beyond ±32 are bounded for numerical containment. + +RMS detector uses a 10 ms exponential energy estimate. Attack/release are 63.2% time constants in the dB reduction domain. Auto release blends base and 4× slower release coefficients according to existing reduction. This is an explicit independent design, not a recreation of FabFilter's undisclosed program-dependent models. The first-order detector HP/LP are bypassed at 20 Hz / 20 kHz endpoints. Stereo linking blends each detector toward the maximum channel level. + +## Data exchange + +A fixed 512-slot SPSC queue transfers 10 ms maxima (input, output, reduction). Acquire/release publication protects non-atomic slots; read/write indices occupy distinct cache lines. Audio drops frames if full. There is exactly one editor consumer. Editor drains at most 512 frames per 30 Hz tick, updates its fixed 400-frame history and coalesces meter repaint. Reopening discards a bounded stale backlog. Static display grid is rebuilt on resize, not on audio or every timer tick. + +APVTS parameter atomics are independent, so bulk preset/state changes can be observed across adjacent audio blocks; five-millisecond ramps limit transition artifacts. They are not claimed to be a transactional sample-accurate preset switch. Host automation is block-rate in this implementation. State XML serialization is outside processBlock. Schema 1 rejects unknown root/schema and restores finite, clamped known values. + +RAII owns GUI attachments and buffers. Timer is stopped before editor teardown. No process-global mutable DSP state. Audio never accesses editor objects. Memory use does not grow with session duration. + +## Reference decisions + +- FabFilter Pro-C 2 manual: https://www.fabfilter.com/downloads/pdf/help/ffproc2-manual.pdf — workflow references for dynamics/time controls, sidechain, metering, lookahead and oversampling. Lookahead/oversampling intentionally absent from zero-latency live path. +- JUCE APVTS documentation: https://docs.juce.com/master/classjuce_1_1AudioProcessorValueTreeState.html — raw atomic parameter reads and state/attachment separation. +- JUCE source pinned at 8.0.12: https://github.com/juce-framework/JUCE/tree/29396c22c93392d6738e021b83196283d6e4d850 — build reproducibility, not an assertion this is the newest release. + +## Deferred, not represented as working + +Pro-C-specific styles, mid/side compression, frequency-dependent linking, auto makeup, lookahead/offline quality mode, oversampling, scalable vector accessibility polish, user preset files, ASIO standalone integration and measured proprietary sound matching. Future modes must declare latency and pass block/automation tests separately. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md new file mode 100644 index 0000000..73b674c --- /dev/null +++ b/docs/HANDOFF.md @@ -0,0 +1,11 @@ +# Handoff + +Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canonical parameter table, not UI strings. The current milestone delivers a complete first compressor path and UI with explicit release gates; it is not the final parity milestone. + +1. Confirm CI artifacts and inspect minimum/default-size GUI renders. Fix functional defects before adding styles. +2. Run pluginval and two-host Windows tests (including ArSonMiX when available). Capture automation, sidechain and project-reload behavior. +3. Listen and measure release/hold/filter transitions, bypass clicks and low-frequency distortion. Add regression cases for actual findings. +4. Profile with GUI open/closed and many instances at 32/64/128 samples. Optimize only measured hotspots. +5. Work toward Pro-C workflow/quality with documented independent models; never add fake style labels mapped to indistinguishable algorithms. + +Keep builds grouped: one relevant-PR workflow with Linux safety and one Windows artifact. No gratuitous matrix or repeated manual runs. diff --git a/docs/PRD.md b/docs/PRD.md new file mode 100644 index 0000000..80a92e3 --- /dev/null +++ b/docs/PRD.md @@ -0,0 +1,16 @@ +# Product requirements + +ArSonComp is a lightweight live vocal, karaoke, podcast and mix-bus compressor, delivered as VST3 and standalone. The engine should also be reusable in ArSonMiX without GUI dependencies. Pro-C is the workflow/quality reference, not a basis for asserting sonic identity. + +## Initial acceptance + +- Mono/stereo host processing, optional mono/stereo external sidechain, zero added sample delay. +- Useful dynamics controls, bounded range, soft knee, Peak/RMS, stereo link and filtered detector audition. +- Dominant transfer/history display; separate IN/GR/OUT meters; compact knobs and dark readable menus. +- Presets with actual parameter values, A/B, host automation and state restoration. +- No heap allocation/lock/wait in DSP; bounded metering and independent GUI lifetime. +- DSP correctness tests, allocation guard, sanitizers, measured throughput, plugin state/editor smoke and Windows artifacts. + +## Release gate after initial build + +Listen with vocals, music, transients and low-frequency tones. Compare loudness-matched Pro-C references at identical settings, documenting differences. Verify in at least two Windows VST3 hosts, including external sidechain, bypass automation, save/reload, 32/64/128 sample buffers and editor close/reopen. Run pluginval, long-duration stress, and physical-device latency/dropout measurements. No statement of full Pro-C parity or production readiness before these gates. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md new file mode 100644 index 0000000..05f4e14 --- /dev/null +++ b/docs/VALIDATION.md @@ -0,0 +1,11 @@ +# Validation record + +Initial implementation, 2026-10-31. + +Local GCC 13.3 Release engine tests pass: static ratio and knee curves, monotonicity/continuity/range, attack time constants at 44.1/48/96/192 kHz, steady reduction, zero-delay unity impulse, bypass and dry transparency, arbitrary-block partition equivalence, external mono sidechain to stereo, linked/unlinked channels, disconnected sidechain, non-finite containment, zero allocations over 10,000 parameter-update/process blocks, bounded queue saturation and 100,000-frame threaded SPSC order. + +ASan/UBSan engine run passes with `ASAN_OPTIONS=detect_leaks=0`. LeakSanitizer cannot enumerate `/proc/.../task` in this local execution environment; full leak checking is delegated to the Linux CI job, not reported as locally passed. + +Local Release throughput example: ~94.9 ns/stereo frame (~0.456% of one 48 kHz real-time core budget), RMS + auto release + high-pass sidechain, 128-sample blocks, sustained sinusoidal input. This is a shared-environment microbenchmark, not a worst-case deadline guarantee, a Windows result or a comparison against Pro-C. Re-run `engine_bench` on the target machine. + +Pending until evidence is recorded: full JUCE build, editor visual inspection, Windows host/pluginval/hardware tests, listening comparison, leak-check CI. No tested production-ready or Pro-C sonic-parity claim. diff --git a/engine/Compressor.cpp b/engine/Compressor.cpp new file mode 100644 index 0000000..0fde0db --- /dev/null +++ b/engine/Compressor.cpp @@ -0,0 +1,79 @@ +#include "Compressor.h" +namespace arson { +namespace { +float clean(float x) noexcept { return std::isfinite(x) ? std::clamp(x,-32.0f,32.0f) : 0.0f; } +float flush(float x) noexcept { return std::abs(x)<1.0e-20f ? 0.0f : x; } +} +void Compressor::prepare(double rate,const Parameters& initial) noexcept { + fs=std::isfinite(rate) ? std::clamp(rate,8000.0,384000.0) : 48000; + rampLength=std::max(1,static_cast(fs*0.005)); + meterPeriod=std::max(1,static_cast(fs*0.01)); + hpState={}; lpState={}; rms={}; envelope={}; holdRemaining={}; meter={}; meterCount=0; + rmsCoeff=static_cast(std::exp(-1.0/(0.01*fs))); + p=initial; p.sanitize(); + for(std::size_t i=0;i(std::exp(-1000.0/(next[Attack]*fs))); + if(next[Release]!=p[Release]) { + releaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*fs))); + slowReleaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*4.0*fs))); + } + if(next[Highpass]!=p[Highpass]) hpCoeff=static_cast(std::exp(-6.28318530718*next[Highpass]/fs)); + if(next[Lowpass]!=p[Lowpass]) lpCoeff=static_cast(std::exp(-6.28318530718*std::min(next[Lowpass],fs*0.45)/fs)); + holdSamples=static_cast(next[Hold]*0.001*fs); + for(std::size_t i=0;i2 || samples<=0) return; + const bool external=p[External]>0.5f; + for(int n=0;n v{}; + for(std::size_t i=0;i0) ? clean(sc[std::min(c,scChannels-1)][n]) : 0.0f) : dry[c]; + hpState[c]=flush(hpCoeff*hpState[c]+(1-hpCoeff)*x); + if(p[Highpass]>20.01f) x-=hpState[c]; + lpState[c]=flush(lpCoeff*lpState[c]+(1-lpCoeff)*x); + if(p[Lowpass]<19999.0f) x=lpState[c]; + listen[c]=x; + rms[c]=flush(rmsCoeff*rms[c]+(1-rmsCoeff)*x*x); + // Crossfade detector modes to avoid a discontinuity on automation. + detected[c]=std::abs(x)+(std::sqrt(rms[c])-std::abs(x))*v[Detector]; + } + const float linked=std::max(detected[0],detected[channels-1]); + for(int c=0;cenv) { env=target+attackCoeff*(env-target); holdRemaining[c]=holdSamples; } + else if(holdRemaining[c]>0) --holdRemaining[c]; + else { + const float adaptive=std::clamp(env/24.0f,0.0f,1.0f)*v[AutoRelease]; + const float coeff=releaseCoeff+(slowReleaseCoeff-releaseCoeff)*adaptive; + env=target+coeff*(env-target); + } + env=flush(env); + const float wet=dry[c]*dbToGain(-env)*makeupGain; + float out=dry[c]+(wet-dry[c])*(v[Mix]*0.01f); + out+=(listen[c]-out)*v[Listen]; + out=v[Bypass]>=1.0f ? original[c] : out+(original[c]-out)*v[Bypass]; + audio[c][n]=out; + meter.input=std::max(meter.input,std::abs(dry[c])); + meter.output=std::max(meter.output,std::abs(out)); + meter.reduction=std::max(meter.reduction,env*(1-v[Bypass])); + } + if(++meterCount>=meterPeriod) { + if(meters) meters->push(meter); + meter={}; meterCount=0; + } + } +} +} diff --git a/engine/Compressor.h b/engine/Compressor.h new file mode 100644 index 0000000..e347e39 --- /dev/null +++ b/engine/Compressor.h @@ -0,0 +1,33 @@ +#pragma once +#include "Parameters.h" +#include "MeterQueue.h" +namespace arson { +// Framework-free, audio-thread-owned state. Planar mono/stereo, arbitrary block size. +class Compressor { +public: + void prepare(double sampleRate, const Parameters& initial=Parameters{}) noexcept; + void setParameters(Parameters parameters) noexcept; + void process(float* const* audio, int channels, int samples, + const float* const* sidechain=nullptr, int sidechainChannels=0, + MeterQueue* meters=nullptr) noexcept; + static constexpr int latencySamples() noexcept { return 0; } +private: + struct Ramp { + float current=0,target=0,step=0; int remaining=0; + void reset(float x) noexcept { current=target=x; remaining=0; step=0; } + void set(float x,int length) noexcept { + if(x==target) return; + target=x; remaining=length; step=(target-current)/static_cast(length); + } + float next() noexcept { if(remaining>0 && --remaining==0) current=target; else if(remaining>0) current+=step; return current; } + }; + Parameters p; + std::array smooth{}; + std::array hpState{}, lpState{}, rms{}, envelope{}; + std::array holdRemaining{}; + double fs=48000; + float attackCoeff=0,releaseCoeff=0,slowReleaseCoeff=0,rmsCoeff=0,hpCoeff=0,lpCoeff=0; + int rampLength=240, meterPeriod=480, meterCount=0,holdSamples=0; + MeterFrame meter{}; +}; +} diff --git a/engine/MeterQueue.h b/engine/MeterQueue.h new file mode 100644 index 0000000..ee2f0ba --- /dev/null +++ b/engine/MeterQueue.h @@ -0,0 +1,27 @@ +#pragma once +#include +#include +#include +namespace arson { +struct MeterFrame { float input=0, output=0, reduction=0; }; +// One audio producer, one editor consumer. Full queue drops visualization only. +class MeterQueue { +public: + static_assert(std::atomic::is_always_lock_free); + bool push(MeterFrame frame) noexcept { + const auto w=write.load(std::memory_order_relaxed), next=(w+1)%capacity; + if (next==read.load(std::memory_order_acquire)) return false; + frames[w]=frame; write.store(next,std::memory_order_release); return true; + } + bool pop(MeterFrame& frame) noexcept { + const auto r=read.load(std::memory_order_relaxed); + if (r==write.load(std::memory_order_acquire)) return false; + frame=frames[r]; read.store((r+1)%capacity,std::memory_order_release); return true; + } + static constexpr std::uint32_t capacity=512; +private: + std::array frames{}; + alignas(64) std::atomic write{0}; + alignas(64) std::atomic read{0}; +}; +} diff --git a/engine/Parameters.h b/engine/Parameters.h new file mode 100644 index 0000000..abc331b --- /dev/null +++ b/engine/Parameters.h @@ -0,0 +1,54 @@ +#pragma once +#include +#include +#include +#include + +namespace arson { +enum Param : std::size_t { Threshold, Ratio, Attack, Release, Knee, Range, Hold, + Makeup, Mix, Input, Link, Highpass, Lowpass, Detector, AutoRelease, External, Listen, Bypass, Count }; +struct Spec { const char* id; const char* name; const char* unit; float min, max, initial, skew; }; +inline constexpr std::array specs {{ + {"threshold", "Threshold", " dB", -60, 0, -18, 1}, + {"ratio", "Ratio", ":1", 1, 20, 4, 0.45f}, + {"attack", "Attack", " ms", 0.05f, 250, 10, 0.3f}, + {"release", "Release", " ms", 10, 2000, 150, 0.35f}, + {"knee", "Knee", " dB", 0, 48, 6, 1}, + {"range", "Range", " dB", 0, 60, 36, 1}, + {"hold", "Hold", " ms", 0, 500, 0, 0.5f}, + {"makeup", "Makeup", " dB", -24, 24, 0, 1}, + {"mix", "Mix", " %", 0, 100, 100, 1}, + {"input", "Input", " dB", -24, 24, 0, 1}, + {"link", "Stereo link", " %", 0, 100, 100, 1}, + {"highpass", "SC high-pass", " Hz", 20, 1000, 20, 0.35f}, + {"lowpass", "SC low-pass", " Hz", 1000, 20000, 20000, 0.4f}, + {"detector", "Detector", "", 0, 1, 0, 1}, + {"autoRelease", "Auto release", "", 0, 1, 0, 1}, + {"external", "External SC", "", 0, 1, 0, 1}, + {"listen", "SC listen", "", 0, 1, 0, 1}, + {"bypass", "Bypass", "", 0, 1, 0, 1} +}}; +struct Parameters { + std::array value{}; + Parameters() noexcept { for (std::size_t i=0; i=Detector) v=std::round(v); + } + } +}; +inline float gainToDb(float gain) noexcept { return 20.0f*std::log10(std::max(gain,1.0e-6f)); } +inline float dbToGain(float db) noexcept { return std::exp(db*0.1151292546497023f); } +// Positive gain reduction; C1-continuous at both soft-knee boundaries. +inline float reduction(float db,float threshold,float ratio,float knee,float range) noexcept { + const float x=db-threshold, slope=1.0f-1.0f/ratio; + float gr=0; + if (knee<=0) gr=std::max(0.0f,x)*slope; + else if (x>=knee*0.5f) gr=x*slope; + else if (x>-knee*0.5f) { const float t=x+knee*0.5f; gr=slope*t*t/(2*knee); } + return std::min(gr,range); +} +} diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp new file mode 100644 index 0000000..113b5ac --- /dev/null +++ b/plugin/Editor.cpp @@ -0,0 +1,176 @@ +#include "Editor.h" +namespace { +const juce::Colour bg{0xff171a1f},panel{0xff101318},line{0xff303740},text{0xffd4dbe1},muted{0xff89939f},cyan{0xff59c9dc},gold{0xffe4b65e}; +} +CompLook::CompLook() { + setColour(juce::Slider::textBoxTextColourId,text); + setColour(juce::Slider::textBoxBackgroundColourId,juce::Colours::transparentBlack); + setColour(juce::Slider::textBoxOutlineColourId,juce::Colours::transparentBlack); + setColour(juce::ComboBox::backgroundColourId,juce::Colour{0xff252b33}); + setColour(juce::ComboBox::textColourId,text); setColour(juce::ComboBox::outlineColourId,line); + setColour(juce::PopupMenu::backgroundColourId,bg); setColour(juce::PopupMenu::textColourId,text); + setColour(juce::PopupMenu::highlightedBackgroundColourId,juce::Colour{0xff34505c}); + setColour(juce::TextButton::buttonColourId,juce::Colour{0xff252b33}); + setColour(juce::TextButton::textColourOffId,text); + setColour(juce::ToggleButton::textColourId,text); setColour(juce::ToggleButton::tickColourId,cyan); + setColour(juce::Label::textColourId,muted); +} +void CompLook::drawRotarySlider(juce::Graphics& g,int x,int y,int w,int h,float pos,float start,float end,juce::Slider&) { + const auto bounds=juce::Rectangle(static_cast(x),static_cast(y),static_cast(w),static_cast(h)).reduced(6); + const float r=std::min(bounds.getWidth(),bounds.getHeight())*0.5f,cx=bounds.getCentreX(),cy=bounds.getCentreY(); + juce::Path track,active; + track.addCentredArc(cx,cy,r,r,0,start,end,true); + active.addCentredArc(cx,cy,r,r,0,start,start+pos*(end-start),true); + g.setColour(line); g.strokePath(track,juce::PathStrokeType(2.5f)); + g.setColour(cyan); g.strokePath(active,juce::PathStrokeType(2.5f)); + g.setColour(juce::Colour{0xff262d35}); g.fillEllipse(cx-r+5,cy-r+5,2*r-10,2*r-10); + const float a=start+pos*(end-start); + g.setColour(text); g.drawLine(cx+std::sin(a)*(r*0.45f),cy-std::cos(a)*(r*0.45f),cx+std::sin(a)*(r*0.75f),cy-std::cos(a)*(r*0.75f),2); +} +Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.snapshot()) { + setLookAndFeel(&look); setOpaque(true); + for(std::size_t i=0;i(p.state,s.id,k); + } + presets.addItemList({"Default","Vocal · gentle","Vocal · level","Mix bus · glue","Drums · punch","Podcast · steady"},1); + presets.setSelectedId(1,juce::dontSendNotification); presets.onChange=[this]{applyPreset(presets.getSelectedId());}; + presets.setTooltip("Factory starting points. Adjust threshold to your input level."); addAndMakeVisible(presets); + detector.addItemList({"Peak","RMS"},1); addAndMakeVisible(detector); + detectorAttachment=std::make_unique(p.state,"detector",detector); + detector.setTooltip("Peak responds to transients. RMS follows energy over 10 ms without delaying audio."); + juce::ToggleButton* toggles[]{&autoRelease,&external,&listen,&bypass}; + const char* ids[]{"autoRelease","external","listen","bypass"}; + for(int i=0;i<4;++i) { addAndMakeVisible(*toggles[i]); buttons[static_cast(i)]=std::make_unique(p.state,ids[i],*toggles[i]); } + external.setTooltip("Uses the host sidechain bus. If unconnected, detector receives silence."); + listen.setTooltip("Audition the filtered detector signal. Turn off for normal output."); + compare.setTooltip("Swap the current settings with the alternate A/B snapshot."); + compare.onClick=[this] { const auto current=processor.snapshot(); for(std::size_t i=0;ibeginChangeGesture(); param->setValueNotifyingHost(param->convertTo0to1(value)); param->endChangeGesture(); + } +} +void Editor::applyPreset(int id) { + if(id<1) return; + arson::Parameters p; + if(id==2) { p.value[arson::Ratio]=2.5f;p.value[arson::Attack]=15;p.value[arson::Release]=180;p.value[arson::Knee]=12; } + if(id==3) { p.value[arson::Threshold]=-24;p.value[arson::Ratio]=3;p.value[arson::Detector]=1;p.value[arson::AutoRelease]=1;p.value[arson::Highpass]=100; } + if(id==4) { p.value[arson::Ratio]=2;p.value[arson::Attack]=30;p.value[arson::Release]=250;p.value[arson::Knee]=12;p.value[arson::Range]=6;p.value[arson::Highpass]=80; } + if(id==5) { p.value[arson::Ratio]=5;p.value[arson::Attack]=25;p.value[arson::Release]=80;p.value[arson::Knee]=3;p.value[arson::Mix]=75; } + if(id==6) { p.value[arson::Threshold]=-24;p.value[arson::Ratio]=4;p.value[arson::Attack]=5;p.value[arson::Release]=180;p.value[arson::Knee]=12;p.value[arson::Highpass]=100;p.value[arson::AutoRelease]=1; } + presetSnapshot=p; + for(std::size_t i=0;i primary{arson::Threshold,arson::Ratio,arson::Attack,arson::Release,arson::Knee,arson::Range,arson::Makeup,arson::Mix}; + for(std::size_t j=0;j(j)*width; + labels[i].setBounds(x,y,width,18); knobs[i].setBounds(x+6,y+18,width-12,88); + } + const int bottom=y+121, small=(getWidth()-300)/5; + const std::array secondary{arson::Input,arson::Hold,arson::Link,arson::Highpass,arson::Lowpass}; + for(std::size_t j=0;j(j)*small; + labels[i].setBounds(x,bottom,small,16); knobs[i].setBounds(x+12,bottom+16,small-24,72); + } + const int x=getWidth()-260; + detector.setBounds(x,bottom+5,98,25); autoRelease.setBounds(x+106,bottom+5,130,25); + external.setBounds(x,bottom+41,120,25); listen.setBounds(x+126,bottom+41,110,25); + grid=juce::Image(juce::Image::RGB,display.getWidth(),display.getHeight(),true); + juce::Graphics g(grid); g.fillAll(panel); g.setFont(juce::FontOptions(11)); + for(int db=0;db>=-60;db-=12) { + const float yy=26+static_cast(-db)/60*(display.getHeight()-52); + g.setColour(line.withAlpha(0.55f)); g.drawHorizontalLine(static_cast(yy),200.0f,static_cast(display.getWidth()-140)); + g.setColour(muted);g.drawText(juce::String(db),display.getWidth()-140,static_cast(yy)-7,28,14,juce::Justification::centredRight); + } +} +void Editor::timerCallback() { + if(!isShowing()) return; + if(presets.getSelectedId()>0) { + const auto current=processor.snapshot(); + for(std::size_t i=0;i0.001f) { + presets.setSelectedId(0,juce::dontSendNotification); presets.setText("Custom",juce::dontSendNotification); break; + } + } + arson::MeterFrame frame; float in=0,out=0,reduction=0; int received=0; + // Fixed upper bound; coalesce meters to one UI update, retain 100 Hz trace history. + while(received(arson::MeterQueue::capacity) && processor.meters.pop(frame)) { + history[head]=frame;head=(head+1)%history.size();++received; + in=std::max(in,frame.input);out=std::max(out,frame.output);reduction=std::max(reduction,frame.reduction); + } + inputDb=std::max(arson::gainToDb(in),inputDb-1.2f); outputDb=std::max(arson::gainToDb(out),outputDb-1.2f); gr=std::max(reduction,gr-0.8f); + repaint(display); +} +void Editor::paint(juce::Graphics& g) { + g.fillAll(bg);g.setColour(text);g.setFont(juce::FontOptions(19));g.drawText("ArSonComp",22,16,170,27,juce::Justification::centredLeft); + g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("LIVE COMPRESSOR",170,18,150,24,juce::Justification::centredLeft); + g.drawImageAt(grid,display.getX(),display.getY());drawDisplay(g); + g.setColour(line);g.drawHorizontalLine(display.getBottom()+133,20.0f,static_cast(getWidth()-20)); + g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("0 samples latency · No lookahead · Native processing",22,getHeight()-25,400,18,juce::Justification::centredLeft); + g.drawText("Double-click to reset / Click value to type",getWidth()-310,getHeight()-25,288,18,juce::Justification::centredRight); +} +void Editor::drawDisplay(juce::Graphics& g) { + juce::Graphics::ScopedSaveState save(g);g.reduceClipRegion(display);g.setOrigin(display.getPosition()); + const float h=static_cast(display.getHeight()),w=static_cast(display.getWidth()); + const auto p=processor.snapshot(); + g.setFont(juce::FontOptions(11));g.setColour(muted);g.drawText("TRANSFER",16,10,150,18,juce::Justification::centredLeft); + const juce::Rectangle curve{18,42,154,h-78}; + const auto cy=[&](float db){return curve.getBottom()-juce::jlimit(0.0f,1.0f,(db+60)/60)*curve.getHeight();}; + g.setColour(line);g.drawRect(curve);g.drawLine(curve.getX(),curve.getBottom(),curve.getRight(),curve.getY()); + juce::Path transfer; + for(int i=0;i<=154;++i) { + const float db=-60+60.0f*i/154,red=arson::reduction(db,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range]); + const float yy=cy(db-red);if(i==0)transfer.startNewSubPath(curve.getX()+i,yy);else transfer.lineTo(curve.getX()+i,yy); + } + g.setColour(gold);g.strokePath(transfer,juce::PathStrokeType(2)); + const float dotX=curve.getX()+juce::jlimit(0.0f,1.0f,(inputDb+60)/60)*curve.getWidth(); + const float dotY=cy(inputDb-arson::reduction(inputDb,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range])); + g.fillEllipse(dotX-3,dotY-3,6,6); + g.setColour(muted);g.drawText("−60 Input dB 0",14,static_cast(h)-28,168,18,juce::Justification::centred); + const float left=200,right=w-148,top=26,bottom=h-26; + const auto y=[&](float level){return bottom-juce::jlimit(0.0f,1.0f,(level+60)/60)*(bottom-top);}; + juce::Path input,output,reduction; + for(std::size_t i=0;i(i)/(history.size()-1); + const float a=y(arson::gainToDb(f.input)),b=y(arson::gainToDb(f.output)),c=top+std::min(f.reduction/36.0f,1.0f)*(bottom-top); + if(i==0) { input.startNewSubPath(x,a);output.startNewSubPath(x,b);reduction.startNewSubPath(x,c); } + else { input.lineTo(x,a);output.lineTo(x,b);reduction.lineTo(x,c); } + } + g.setColour(muted.withAlpha(0.5f));g.strokePath(input,juce::PathStrokeType(1)); + g.setColour(cyan);g.strokePath(output,juce::PathStrokeType(1.4f)); + g.setColour(gold);g.strokePath(reduction,juce::PathStrokeType(1.5f)); + g.setColour(gold.withAlpha(0.35f));g.drawHorizontalLine(static_cast(y(p[arson::Threshold])),left,right); + g.setColour(muted);g.drawText("IN",202,5,30,18,juce::Justification::left);g.setColour(cyan);g.drawText("OUT",238,5,40,18,juce::Justification::left); + g.setColour(gold);g.drawText("GR 0–36 dB",285,5,110,18,juce::Justification::left); + const float values[]{inputDb,gr,outputDb};const char* names[]{"IN","GR","OUT"}; + for(int i=0;i<3;++i) { + const int x=static_cast(w)-106+i*35; + g.setColour(muted);g.drawText(names[i],x-4,8,34,18,juce::Justification::centred); + g.setColour(line);g.fillRect(static_cast(x+7),36.0f,9.0f,h-76); + const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36) : juce::jlimit(0.0f,1.0f,(values[i]+60)/60); + const float bar=(h-76)*amount;g.setColour(i==1 ? gold : cyan); + g.fillRect(static_cast(x+7),i==1 ? 36.0f : h-40-bar,9.0f,bar); + g.setColour(text);g.drawText(values[i]<-99 ? "−∞" : juce::String(values[i],1),x-8,static_cast(h)-30,42,18,juce::Justification::centred); + } + if(p[arson::Listen]>0.5f || p[arson::Bypass]>0.5f) { + g.setColour(gold);g.drawText(p[arson::Bypass]>0.5f ? "BYPASSED" : "SIDECHAIN LISTEN",static_cast(left),static_cast(h)-23,250,18,juce::Justification::left); + } +} diff --git a/plugin/Editor.h b/plugin/Editor.h new file mode 100644 index 0000000..3184c36 --- /dev/null +++ b/plugin/Editor.h @@ -0,0 +1,41 @@ +#pragma once +#include "Processor.h" +#include +class CompLook final : public juce::LookAndFeel_V4 { +public: + CompLook(); + void drawRotarySlider(juce::Graphics&,int,int,int,int,float,float,float,juce::Slider&) override; +}; +class Editor final : public juce::AudioProcessorEditor, private juce::Timer { +public: + explicit Editor(Processor&); + ~Editor() override; + void paint(juce::Graphics&) override; + void resized() override; +private: + void timerCallback() override; + void applyPreset(int); + void setValue(std::size_t,float); + void drawDisplay(juce::Graphics&); + Processor& processor; + CompLook look; + juce::TooltipWindow tooltip{this,650}; + std::array knobs; + std::array labels; + using SliderAttachment=juce::AudioProcessorValueTreeState::SliderAttachment; + using ButtonAttachment=juce::AudioProcessorValueTreeState::ButtonAttachment; + std::array,arson::Detector> attachments; + juce::ComboBox presets,detector; + juce::TextButton compare{"A / B"}; + juce::ToggleButton autoRelease{"Auto release"},external{"External SC"},listen{"Listen SC"},bypass{"Bypass"}; + std::array,4> buttons; + std::unique_ptr detectorAttachment; + arson::Parameters alternate, presetSnapshot; + bool alternateActive=false; + std::array history{}; + std::size_t head=0; + float inputDb=-120,outputDb=-120,gr=0; + juce::Rectangle display; + juce::Image grid; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Editor) +}; diff --git a/plugin/Processor.cpp b/plugin/Processor.cpp new file mode 100644 index 0000000..affde38 --- /dev/null +++ b/plugin/Processor.cpp @@ -0,0 +1,73 @@ +#include "Processor.h" +#include "Editor.h" +juce::AudioProcessorValueTreeState::ParameterLayout Processor::layout() { + juce::AudioProcessorValueTreeState::ParameterLayout result; + for(std::size_t i=0;i(id,s.name,juce::StringArray{"Peak","RMS"},0)); + else if(i>arson::Detector) result.add(std::make_unique(id,s.name,s.initial>0.5f)); + else result.add(std::make_unique(id,s.name, + juce::NormalisableRange{s.min,s.max,0.0f,s.skew},s.initial, + juce::AudioParameterFloatAttributes{}.withLabel(s.unit))); + } + return result; +} +Processor::Processor() : AudioProcessor(BusesProperties() + .withInput("Input",juce::AudioChannelSet::stereo(),true) + .withInput("Sidechain",juce::AudioChannelSet::stereo(),false) + .withOutput("Output",juce::AudioChannelSet::stereo(),true)), + state(*this,nullptr,"ArSonCompState",layout()) { + static_assert(std::atomic::is_always_lock_free); + for(std::size_t i=0;iload(std::memory_order_relaxed); + return p; +} +void Processor::prepareToPlay(double rate,int) { engine.prepare(rate,snapshot()); setLatencySamples(0); } +bool Processor::isBusesLayoutSupported(const BusesLayout& b) const { + const auto main=b.getMainInputChannelSet(); + if(main!=b.getMainOutputChannelSet() || (main!=juce::AudioChannelSet::mono() && main!=juce::AudioChannelSet::stereo())) return false; + const auto side=b.getChannelSet(true,1); + return side.isDisabled() || side==juce::AudioChannelSet::mono() || side==juce::AudioChannelSet::stereo(); +} +void Processor::run(juce::AudioBuffer& buffer,bool hostBypass) { + juce::ScopedNoDenormals noDenormals; + auto p=snapshot(); if(hostBypass) p.value[arson::Bypass]=1; + engine.setParameters(p); + auto main=getBusBuffer(buffer,false,0); + auto side=getBusBuffer(buffer,true,1); + engine.process(main.getArrayOfWritePointers(),main.getNumChannels(),main.getNumSamples(), + side.getArrayOfReadPointers(),side.getNumChannels(),&meters); +} +void Processor::processBlock(juce::AudioBuffer& b,juce::MidiBuffer&) { run(b,false); } +void Processor::processBlockBypassed(juce::AudioBuffer& b,juce::MidiBuffer&) { run(b,true); } +juce::AudioProcessorParameter* Processor::getBypassParameter() const { return state.getParameter("bypass"); } +juce::AudioProcessorEditor* Processor::createEditor() { return new Editor(*this); } +void Processor::getStateInformation(juce::MemoryBlock& dest) { + auto copy=state.copyState(); copy.setProperty("schema",1,nullptr); + if(auto xml=copy.createXml()) copyXmlToBinary(*xml,dest); +} +void Processor::setStateInformation(const void* data,int size) { + if(size<=0 || size>1024*1024) return; + if(auto xml=getXmlFromBinary(data,size)) { + auto incoming=juce::ValueTree::fromXml(*xml); + if(!incoming.hasType("ArSonCompState") || static_cast(incoming.getProperty("schema",1))!=1) return; + // Rebuild known parameter values; reject unknown IDs and non-finite payloads. + auto safe=state.copyState(); + for(int i=0;i(source.getProperty("value")); + if(std::isfinite(value)) child.setProperty("value",std::clamp(value,arson::specs[j].min,arson::specs[j].max),nullptr); + } + } + state.replaceState(safe); + } +} +juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new Processor(); } diff --git a/plugin/Processor.h b/plugin/Processor.h new file mode 100644 index 0000000..3f6704b --- /dev/null +++ b/plugin/Processor.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include "Compressor.h" +class Processor final : public juce::AudioProcessor { +public: + Processor(); + void prepareToPlay(double,int) override; + void releaseResources() override {} + bool isBusesLayoutSupported(const BusesLayout&) const override; + void processBlock(juce::AudioBuffer&,juce::MidiBuffer&) override; + void processBlockBypassed(juce::AudioBuffer&,juce::MidiBuffer&) override; + juce::AudioProcessorParameter* getBypassParameter() const override; + juce::AudioProcessorEditor* createEditor() override; + bool hasEditor() const override { return true; } + const juce::String getName() const override { return "ArSonComp"; } + bool acceptsMidi() const override { return false; } + bool producesMidi() const override { return false; } + double getTailLengthSeconds() const override { return 0; } + int getNumPrograms() override { return 1; } + int getCurrentProgram() override { return 0; } + void setCurrentProgram(int) override {} + const juce::String getProgramName(int) override { return "Default"; } + void changeProgramName(int,const juce::String&) override {} + void getStateInformation(juce::MemoryBlock&) override; + void setStateInformation(const void*,int) override; + arson::Parameters snapshot() const noexcept; + juce::AudioProcessorValueTreeState state; + arson::MeterQueue meters; +private: + static juce::AudioProcessorValueTreeState::ParameterLayout layout(); + void run(juce::AudioBuffer&,bool hostBypass); + std::array*,arson::Count> raw{}; + arson::Compressor engine; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Processor) +}; diff --git a/tests/Benchmark.cpp b/tests/Benchmark.cpp new file mode 100644 index 0000000..dc7380e --- /dev/null +++ b/tests/Benchmark.cpp @@ -0,0 +1,13 @@ +#include "Compressor.h" +#include +#include +int main() { + constexpr int block=128,iterations=100000;float left[block],right[block],source[block]; + for(int i=0;i(std::chrono::steady_clock::now()-start).count(); + std::cout<<"Stereo RMS, auto-release, HP sidechain, 48 kHz / 128 samples\n"< +#include +#include +#include +#include +#include +#include +std::atomic allocations{0}; +void* operator new(std::size_t n) { allocations.fetch_add(1); if(auto* p=std::malloc(n ? n : 1)) return p; throw std::bad_alloc{}; } +void* operator new[](std::size_t n) { return ::operator new(n); } +void operator delete(void* p) noexcept { std::free(p); } +void operator delete[](void* p) noexcept { std::free(p); } +void operator delete(void* p,std::size_t) noexcept { std::free(p); } +void operator delete[](void* p,std::size_t) noexcept { std::free(p); } +int checks=0; +void require(bool ok,const char* message) { ++checks;if(!ok) {std::cerr<<"FAIL: "<=previous-1e-5f && gr>=0 && gr<=36,"monotonic bounded curve");previous=gr; + } + for(float boundary : {-20-knee/2,-20+knee/2}) require(std::abs(reduction(boundary-0.0001f,-20,4,knee,36)-reduction(boundary+0.0001f,-20,4,knee,36))<0.001f,"knee continuity"); + } + for(double rate : {44100.0,48000.0,96000.0,192000.0}) { + Compressor c; Parameters p;p.value[Threshold]=-20;p.value[Knee]=0;p.value[Attack]=10; + c.prepare(rate,p);const int samples=static_cast(rate*0.01); + std::vector data(static_cast(samples),1);float* ptr[]{data.data()}; + c.process(ptr,1,samples); + require(near(-gainToDb(data.back()),15*(1-std::exp(-1.0f)),0.02f),"attack time constant across sample rates"); + data.assign(static_cast(rate),1);ptr[0]=data.data();c.process(ptr,1,static_cast(data.size())); + require(near(-gainToDb(data.back()),15,0.02f),"steady compression"); + } + { + Compressor c;Parameters p;p.value[Ratio]=1;c.prepare(48000,p); + float a[]{1,0,0,0},b[]{0.5f,0,0,0};float* ptr[]{a,b};c.process(ptr,2,4); + require(a[0]==1 && b[0]==0.5f && a[1]==0,"impulse no sample delay and unity ratio"); + } + { + Compressor c; Parameters p;p.value[Bypass]=1;p.value[Input]=12;p.value[Makeup]=12;c.prepare(48000,p); + float a[]{0.123f,-0.4f,0,0.9f};float* ptr[]{a};c.process(ptr,1,4); + require(near(a[0],0.123f)&&near(a[1],-0.4f)&&near(a[3],0.9f),"bypass ignores input and makeup"); + p.value[Bypass]=0;p.value[Input]=0;p.value[Mix]=0;c.prepare(48000,p); + float b[]{0.123f,-0.4f};ptr[0]=b;c.process(ptr,1,2);require(b[0]==0.123f && b[1]==-0.4f,"dry mix transparency"); + } + { + constexpr int count=8192;std::vector whole(count),split(count); + for(int i=0;i a(count,0.05f),b(count,0.025f),side(count,1); + float* ptr[]{a.data(),b.data()};const float* sc[]{side.data()};Compressor c;Parameters p;p.value[External]=1;p.value[Threshold]=-20;p.value[Knee]=0;c.prepare(48000,p); + c.process(ptr,2,count,sc,1); + require(near(a.back()/0.05f,dbToGain(-15),0.001f),"external mono sidechain drives stereo"); + require(near(a.back(),2*b.back()),"stereo image preserved at full link"); + c.prepare(48000,p);a.assign(count,0.05f);b.assign(count,0.025f);c.process(ptr,2,count); + require(near(a.back(),0.05f),"disconnected external sidechain is silent"); + p.value[External]=0;p.value[Link]=0;c.prepare(48000,p);a.assign(count,1);b.assign(count,0.01f);c.process(ptr,2,count); + require(near(b.back(),0.01f),"unlinked low channel uncompressed"); + } + { + Compressor c;Parameters p;for(auto& v:p.value)v=std::numeric_limits::quiet_NaN();c.prepare(0,p); + float a[]{std::numeric_limits::infinity(),std::numeric_limits::quiet_NaN(),1e-38f,1};float* ptr[]{a};c.process(ptr,1,4); + for(auto v:a)require(std::isfinite(v),"invalid input contained"); + c.process(nullptr,2,128);c.process(ptr,0,0); + } + { + Compressor c;c.prepare(48000);Parameters p;MeterQueue q;float a[128]{};float* ptr[]{a}; + const auto before=allocations.load(); + for(int block=0;block<10000;++block) {p.value[Threshold]=-10-static_cast(block%40);c.setParameters(p);c.process(ptr,1,128,nullptr,0,&q);} + require(allocations.load()==before,"no allocation in process or parameter updates"); + MeterFrame f;int count=0;while(q.pop(f))++count;require(count==511,"bounded telemetry drops on saturation"); + } + { + MeterQueue queue;constexpr int count=100000;std::atomic good{true}; + std::thread producer([&]{for(int i=0;i(i),0,0}))std::this_thread::yield();}); + std::thread consumer([&]{for(int i=0;i(i))good=false;}}); + producer.join();consumer.join();require(good,"SPSC publication order"); + } + std::cout<<"PASS: "< +#include +int main(int argc,char** argv) { + juce::ScopedJuceInitialiser_GUI gui; + Processor processor;processor.prepareToPlay(48000,128); + if(processor.getLatencySamples()!=0) return 1; + auto* parameter=processor.state.getParameter("threshold");parameter->setValueNotifyingHost(parameter->convertTo0to1(-27)); + juce::MemoryBlock state;processor.getStateInformation(state);parameter->setValueNotifyingHost(parameter->convertTo0to1(-5));processor.setStateInformation(state.getData(),static_cast(state.getSize())); + if(std::abs(processor.snapshot()[arson::Threshold]+27)>0.01f)return 2; + juce::AudioBuffer buffer(2,128);juce::MidiBuffer midi; + for(int j=0;j<1000;++j) {buffer.clear();buffer.setSample(0,0,0.5f);processor.processBlock(buffer,midi);} + for(int iteration=0;iteration<8;++iteration) { + std::unique_ptr editor(processor.createEditor()); + editor->setSize(iteration%2 ? 860 : 960,iteration%2 ? 570 : 600); + auto image=editor->createComponentSnapshot(editor->getLocalBounds()); + if(image.isNull())return 3; + if(iteration==0 && argc>1) {juce::File file(juce::String::fromUTF8(argv[1]));file.deleteFile();auto stream=file.createOutputStream();if(!stream || !juce::PNGImageFormat{}.writeImageToStream(image,*stream))return 4;} + } + processor.releaseResources();std::cout<<"PASS: state round-trip, audio, zero latency, editor resize/reopen/render\n"; +} From a2c45ce8ea938229d7cabcf1ee4ff17088b8f1ed Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 04:39:54 +0700 Subject: [PATCH 02/35] Use product executable name and exercise live editor telemetry in smoke test --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 2 +- tests/PluginSmoke.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 560ef6e..9c73673 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: shell: pwsh run: | New-Item -ItemType Directory -Force artifacts - & ./build/plugin_smoke_artefacts/Release/plugin_smoke.exe "$pwd/artifacts/ArSonComp-preview.png" + & ./build/plugin_smoke_artefacts/Release/ArSonCompSmoke.exe "$pwd/artifacts/ArSonComp-preview.png" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } & ./build/Release/engine_bench.exe | Tee-Object artifacts/benchmark.txt - uses: actions/upload-artifact@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 73ace30..79b6b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ if(ARSON_BUILD_PLUGIN) target_link_libraries(ArSonComp PRIVATE arson_engine juce::juce_audio_utils PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_lto_flags) if(BUILD_TESTING) - juce_add_console_app(plugin_smoke PRODUCT_NAME "ArSonComp smoke") + juce_add_console_app(plugin_smoke PRODUCT_NAME "ArSonCompSmoke") target_sources(plugin_smoke PRIVATE tests/PluginSmoke.cpp) target_link_libraries(plugin_smoke PRIVATE ArSonComp arson_engine juce::juce_audio_utils) endif() diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index b897168..8c13d1c 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -13,6 +13,19 @@ int main(int argc,char** argv) { for(int iteration=0;iteration<8;++iteration) { std::unique_ptr editor(processor.createEditor()); editor->setSize(iteration%2 ? 860 : 960,iteration%2 ? 570 : 600); + editor->addToDesktop(0); editor->setVisible(true); + for(int j=0;j<1500;++j) { + for(int i=0;i<128;++i) { + const float level=0.15f+0.6f*(0.5f+0.5f*std::sin(j*0.013f)); + const float sample=level*std::sin((j*128+i)*0.057f); + buffer.setSample(0,i,sample);buffer.setSample(1,i,sample*0.8f); + } + processor.processBlock(buffer,midi); + } + if(iteration==0) { + juce::Timer::callAfterDelay(120,[]{juce::MessageManager::getInstance()->stopDispatchLoop();}); + juce::MessageManager::getInstance()->runDispatchLoop(); + } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3; if(iteration==0 && argc>1) {juce::File file(juce::String::fromUTF8(argv[1]));file.deleteFile();auto stream=file.createOutputStream();if(!stream || !juce::PNGImageFormat{}.writeImageToStream(image,*stream))return 4;} From b6a4b8621a47bf33fea6ac7a5d274d32eac03c05 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 04:47:19 +0700 Subject: [PATCH 03/35] Run editor smoke by CMake target and verify release timing --- .github/workflows/build.yml | 5 ++--- CMakeLists.txt | 14 ++++++++++++-- docs/VALIDATION.md | 8 +++++--- tests/EngineTests.cpp | 11 +++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c73673..1e24c51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,12 +27,10 @@ jobs: - run: cmake -S . -B build -A x64 -DCMAKE_BUILD_TYPE=Release - run: cmake --build build --config Release --parallel 4 - run: ctest --test-dir build -C Release --output-on-failure - - name: Plugin state and editor smoke + - name: Measure engine throughput shell: pwsh run: | New-Item -ItemType Directory -Force artifacts - & ./build/plugin_smoke_artefacts/Release/ArSonCompSmoke.exe "$pwd/artifacts/ArSonComp-preview.png" - if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } & ./build/Release/engine_bench.exe | Tee-Object artifacts/benchmark.txt - uses: actions/upload-artifact@v4 with: @@ -41,4 +39,5 @@ jobs: build/ArSonComp_artefacts/Release/VST3/ArSonComp.vst3 build/ArSonComp_artefacts/Release/Standalone/ArSonComp.exe artifacts/* + build/ArSonComp-preview.png retention-days: 14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 79b6b44..a38b120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,13 @@ if(ARSON_BUILD_PLUGIN) else() include(FetchContent) FetchContent_Declare(JUCE GIT_REPOSITORY https://github.com/juce-framework/JUCE.git - GIT_TAG 29396c22c93392d6738e021b83196283d6e4d850) + GIT_TAG 8.0.12 GIT_SHALLOW TRUE) FetchContent_MakeAvailable(JUCE) + execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY "${juce_SOURCE_DIR}" + OUTPUT_VARIABLE JUCE_CHECKED_SHA OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY) + if(NOT JUCE_CHECKED_SHA STREQUAL "29396c22c93392d6738e021b83196283d6e4d850") + message(FATAL_ERROR "JUCE tag does not match the audited commit") + endif() endif() juce_add_plugin(ArSonComp COMPANY_NAME "ArSon Audio" BUNDLE_ID "com.arsonaudio.comp" PLUGIN_MANUFACTURER_CODE ArSn PLUGIN_CODE ArCp FORMATS VST3 Standalone @@ -40,13 +45,18 @@ if(ARSON_BUILD_PLUGIN) IS_MIDI_EFFECT FALSE EDITOR_WANTS_KEYBOARD_FOCUS FALSE COPY_PLUGIN_AFTER_BUILD FALSE VST3_CATEGORIES Fx Dynamics) target_sources(ArSonComp PRIVATE plugin/Processor.cpp plugin/Editor.cpp) + if(MSVC) + target_compile_options(ArSonComp PRIVATE /utf-8) + endif() target_compile_definitions(ArSonComp PUBLIC JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 - JUCE_VST3_CAN_REPLACE_VST2=0 JUCE_DISPLAY_SPLASH_SCREEN=0) + JUCE_VST3_CAN_REPLACE_VST2=0) target_link_libraries(ArSonComp PRIVATE arson_engine juce::juce_audio_utils PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_lto_flags) if(BUILD_TESTING) juce_add_console_app(plugin_smoke PRODUCT_NAME "ArSonCompSmoke") target_sources(plugin_smoke PRIVATE tests/PluginSmoke.cpp) target_link_libraries(plugin_smoke PRIVATE ArSonComp arson_engine juce::juce_audio_utils) + add_test(NAME plugin_state_editor COMMAND plugin_smoke "${CMAKE_BINARY_DIR}/ArSonComp-preview.png") + set_tests_properties(plugin_state_editor PROPERTIES TIMEOUT 30) endif() endif() diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 05f4e14..a2649f5 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -2,10 +2,12 @@ Initial implementation, 2026-10-31. -Local GCC 13.3 Release engine tests pass: static ratio and knee curves, monotonicity/continuity/range, attack time constants at 44.1/48/96/192 kHz, steady reduction, zero-delay unity impulse, bypass and dry transparency, arbitrary-block partition equivalence, external mono sidechain to stereo, linked/unlinked channels, disconnected sidechain, non-finite containment, zero allocations over 10,000 parameter-update/process blocks, bounded queue saturation and 100,000-frame threaded SPSC order. +Local GCC 13.3 Release engine tests pass: static ratio and knee curves, monotonicity/continuity/range, attack time constants at 44.1/48/96/192 kHz, release time constant, hold duration and adaptive recovery, steady reduction, zero-delay unity impulse, bypass and dry transparency, arbitrary-block partition equivalence, external mono sidechain to stereo, linked/unlinked channels, disconnected sidechain, non-finite containment, zero allocations over 10,000 parameter-update/process blocks, bounded queue saturation and 100,000-frame threaded SPSC order. -ASan/UBSan engine run passes with `ASAN_OPTIONS=detect_leaks=0`. LeakSanitizer cannot enumerate `/proc/.../task` in this local execution environment; full leak checking is delegated to the Linux CI job, not reported as locally passed. +ASan/UBSan engine run passes with `ASAN_OPTIONS=detect_leaks=0`. LeakSanitizer cannot enumerate `/proc/.../task` in this local execution environment; full leak checking passed in the Linux CI job. It is not reported as locally passed. Local Release throughput example: ~94.9 ns/stereo frame (~0.456% of one 48 kHz real-time core budget), RMS + auto release + high-pass sidechain, 128-sample blocks, sustained sinusoidal input. This is a shared-environment microbenchmark, not a worst-case deadline guarantee, a Windows result or a comparison against Pro-C. Re-run `engine_bench` on the target machine. -Pending until evidence is recorded: full JUCE build, editor visual inspection, Windows host/pluginval/hardware tests, listening comparison, leak-check CI. No tested production-ready or Pro-C sonic-parity claim. +Windows MSVC Release VST3 and standalone compilation and engine tests passed in CI run 41132714813. The GUI-smoke script used an incorrect executable name; the correction registers the executable as a CTest target, avoiding hard-coded paths. + +Pending until evidence is recorded: editor lifecycle/state test and visual inspection, Windows host/pluginval/hardware tests, listening comparison, leak-check CI. No tested production-ready or Pro-C sonic-parity claim. diff --git a/tests/EngineTests.cpp b/tests/EngineTests.cpp index f970232..b68c193 100644 --- a/tests/EngineTests.cpp +++ b/tests/EngineTests.cpp @@ -90,5 +90,16 @@ int main() { std::thread consumer([&]{for(int i=0;i(i))good=false;}}); producer.join();consumer.join();require(good,"SPSC publication order"); } + { + const auto releaseAt150ms=[](bool automatic,float hold) { + Compressor c;Parameters p;p.value[Threshold]=-20;p.value[Knee]=0;p.value[Hold]=hold;p.value[AutoRelease]=automatic ? 1.0f : 0.0f;c.prepare(48000,p); + std::vector data(48000,1.0f);float* ptr[]{data.data()};c.process(ptr,1,48000); + std::fill(data.begin(),data.end(),0.1f);c.process(ptr,1,7200);return -gainToDb(data[7199]/0.1f); + }; + const auto normal=releaseAt150ms(false,0); + require(near(normal,15*std::exp(-1.0f),0.02f),"release time constant"); + require(near(releaseAt150ms(false,50),15*std::exp(-2.0f/3),0.02f),"hold delays release by 50 ms"); + require(releaseAt150ms(true,0)>normal,"adaptive release extends recovery"); + } std::cout<<"PASS: "< Date: Sat, 31 Oct 2026 04:57:50 +0700 Subject: [PATCH 04/35] Correct Windows label encoding and parameter display precision --- .github/workflows/build.yml | 2 +- plugin/Editor.cpp | 24 ++++++++++++++++++------ plugin/Editor.h | 1 + plugin/Processor.cpp | 7 ++++++- tests/PluginSmoke.cpp | 7 ++++++- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e24c51..b97361d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,5 +39,5 @@ jobs: build/ArSonComp_artefacts/Release/VST3/ArSonComp.vst3 build/ArSonComp_artefacts/Release/Standalone/ArSonComp.exe artifacts/* - build/ArSonComp-preview.png + build/ArSonComp-preview*.png retention-days: 14 diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index 113b5ac..995bace 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -15,6 +15,17 @@ CompLook::CompLook() { setColour(juce::ToggleButton::textColourId,text); setColour(juce::ToggleButton::tickColourId,cyan); setColour(juce::Label::textColourId,muted); } +juce::Label* CompLook::createSliderTextBox(juce::Slider& slider) { + auto* label=juce::LookAndFeel_V4::createSliderTextBox(slider); + label->setFont(juce::FontOptions(12)); + label->setColour(juce::Label::outlineColourId,juce::Colours::transparentBlack); + label->setColour(juce::Label::textColourId,text); + label->setColour(juce::TextEditor::backgroundColourId,panel); + label->setColour(juce::TextEditor::textColourId,text); + label->setColour(juce::TextEditor::outlineColourId,line); + label->setColour(juce::TextEditor::focusedOutlineColourId,cyan); + return label; +} void CompLook::drawRotarySlider(juce::Graphics& g,int x,int y,int w,int h,float pos,float start,float end,juce::Slider&) { const auto bounds=juce::Rectangle(static_cast(x),static_cast(y),static_cast(w),static_cast(h)).reduced(6); const float r=std::min(bounds.getWidth(),bounds.getHeight())*0.5f,cx=bounds.getCentreX(),cy=bounds.getCentreY(); @@ -31,17 +42,18 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn setLookAndFeel(&look); setOpaque(true); for(std::size_t i=0;i(p.state,s.id,k); } - presets.addItemList({"Default","Vocal · gentle","Vocal · level","Mix bus · glue","Drums · punch","Podcast · steady"},1); + presets.addItemList({"Default","Vocal | gentle","Vocal | level","Mix bus | glue","Drums | punch","Podcast | steady"},1); presets.setSelectedId(1,juce::dontSendNotification); presets.onChange=[this]{applyPreset(presets.getSelectedId());}; presets.setTooltip("Factory starting points. Adjust threshold to your input level."); addAndMakeVisible(presets); detector.addItemList({"Peak","RMS"},1); addAndMakeVisible(detector); @@ -124,7 +136,7 @@ void Editor::paint(juce::Graphics& g) { g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("LIVE COMPRESSOR",170,18,150,24,juce::Justification::centredLeft); g.drawImageAt(grid,display.getX(),display.getY());drawDisplay(g); g.setColour(line);g.drawHorizontalLine(display.getBottom()+133,20.0f,static_cast(getWidth()-20)); - g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("0 samples latency · No lookahead · Native processing",22,getHeight()-25,400,18,juce::Justification::centredLeft); + g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("0 samples latency | No lookahead | Native processing",22,getHeight()-25,400,18,juce::Justification::centredLeft); g.drawText("Double-click to reset / Click value to type",getWidth()-310,getHeight()-25,288,18,juce::Justification::centredRight); } void Editor::drawDisplay(juce::Graphics& g) { @@ -144,7 +156,7 @@ void Editor::drawDisplay(juce::Graphics& g) { const float dotX=curve.getX()+juce::jlimit(0.0f,1.0f,(inputDb+60)/60)*curve.getWidth(); const float dotY=cy(inputDb-arson::reduction(inputDb,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range])); g.fillEllipse(dotX-3,dotY-3,6,6); - g.setColour(muted);g.drawText("−60 Input dB 0",14,static_cast(h)-28,168,18,juce::Justification::centred); + g.setColour(muted);g.drawText("-60 Input dB 0",14,static_cast(h)-28,168,18,juce::Justification::centred); const float left=200,right=w-148,top=26,bottom=h-26; const auto y=[&](float level){return bottom-juce::jlimit(0.0f,1.0f,(level+60)/60)*(bottom-top);}; juce::Path input,output,reduction; @@ -159,7 +171,7 @@ void Editor::drawDisplay(juce::Graphics& g) { g.setColour(gold);g.strokePath(reduction,juce::PathStrokeType(1.5f)); g.setColour(gold.withAlpha(0.35f));g.drawHorizontalLine(static_cast(y(p[arson::Threshold])),left,right); g.setColour(muted);g.drawText("IN",202,5,30,18,juce::Justification::left);g.setColour(cyan);g.drawText("OUT",238,5,40,18,juce::Justification::left); - g.setColour(gold);g.drawText("GR 0–36 dB",285,5,110,18,juce::Justification::left); + g.setColour(gold);g.drawText("GR 0-36 dB",285,5,110,18,juce::Justification::left); const float values[]{inputDb,gr,outputDb};const char* names[]{"IN","GR","OUT"}; for(int i=0;i<3;++i) { const int x=static_cast(w)-106+i*35; @@ -168,7 +180,7 @@ void Editor::drawDisplay(juce::Graphics& g) { const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36) : juce::jlimit(0.0f,1.0f,(values[i]+60)/60); const float bar=(h-76)*amount;g.setColour(i==1 ? gold : cyan); g.fillRect(static_cast(x+7),i==1 ? 36.0f : h-40-bar,9.0f,bar); - g.setColour(text);g.drawText(values[i]<-99 ? "−∞" : juce::String(values[i],1),x-8,static_cast(h)-30,42,18,juce::Justification::centred); + g.setColour(text);g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1),x-8,static_cast(h)-30,42,18,juce::Justification::centred); } if(p[arson::Listen]>0.5f || p[arson::Bypass]>0.5f) { g.setColour(gold);g.drawText(p[arson::Bypass]>0.5f ? "BYPASSED" : "SIDECHAIN LISTEN",static_cast(left),static_cast(h)-23,250,18,juce::Justification::left); diff --git a/plugin/Editor.h b/plugin/Editor.h index 3184c36..4bdbf44 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -4,6 +4,7 @@ class CompLook final : public juce::LookAndFeel_V4 { public: CompLook(); + juce::Label* createSliderTextBox(juce::Slider&) override; void drawRotarySlider(juce::Graphics&,int,int,int,int,float,float,float,juce::Slider&) override; }; class Editor final : public juce::AudioProcessorEditor, private juce::Timer { diff --git a/plugin/Processor.cpp b/plugin/Processor.cpp index affde38..b9b3eab 100644 --- a/plugin/Processor.cpp +++ b/plugin/Processor.cpp @@ -8,7 +8,12 @@ juce::AudioProcessorValueTreeState::ParameterLayout Processor::layout() { else if(i>arson::Detector) result.add(std::make_unique(id,s.name,s.initial>0.5f)); else result.add(std::make_unique(id,s.name, juce::NormalisableRange{s.min,s.max,0.0f,s.skew},s.initial, - juce::AudioParameterFloatAttributes{}.withLabel(s.unit))); + juce::AudioParameterFloatAttributes{}.withLabel(s.unit).withStringFromValueFunction( + [i](float value,int) { + if(i==arson::Highpass || i==arson::Lowpass) return juce::String(juce::roundToInt(value)); + const int decimals=(i==arson::Ratio || (i==arson::Attack && value<10)) ? 2 : 1; + return juce::String(value,decimals); + }))); } return result; } diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 8c13d1c..6c2937b 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -6,6 +6,9 @@ int main(int argc,char** argv) { Processor processor;processor.prepareToPlay(48000,128); if(processor.getLatencySamples()!=0) return 1; auto* parameter=processor.state.getParameter("threshold");parameter->setValueNotifyingHost(parameter->convertTo0to1(-27)); + if(parameter->getText(parameter->convertTo0to1(-27),32)!="-27.0")return 5; + auto* frequency=processor.state.getParameter("lowpass"); + if(frequency->getText(frequency->convertTo0to1(20000),32)!="20000")return 6; juce::MemoryBlock state;processor.getStateInformation(state);parameter->setValueNotifyingHost(parameter->convertTo0to1(-5));processor.setStateInformation(state.getData(),static_cast(state.getSize())); if(std::abs(processor.snapshot()[arson::Threshold]+27)>0.01f)return 2; juce::AudioBuffer buffer(2,128);juce::MidiBuffer midi; @@ -28,7 +31,9 @@ int main(int argc,char** argv) { } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3; - if(iteration==0 && argc>1) {juce::File file(juce::String::fromUTF8(argv[1]));file.deleteFile();auto stream=file.createOutputStream();if(!stream || !juce::PNGImageFormat{}.writeImageToStream(image,*stream))return 4;} + if(iteration<2 && argc>1) {juce::File file(juce::String::fromUTF8(argv[1])); + if(iteration==1)file=file.getSiblingFile(file.getFileNameWithoutExtension()+"-minimum.png"); + file.deleteFile();auto stream=file.createOutputStream();if(!stream || !juce::PNGImageFormat{}.writeImageToStream(image,*stream))return 4;} } processor.releaseResources();std::cout<<"PASS: state round-trip, audio, zero latency, editor resize/reopen/render\n"; } From 97551d225ff4102e5fd2185e967e81311fe4002a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 05:11:10 +0700 Subject: [PATCH 05/35] Harden live sidechain filter and detector transitions with sample-ramped coefficients --- docs/HANDOFF.md | 2 +- engine/Compressor.cpp | 34 ++++++++++++++++++++++++---------- engine/Compressor.h | 4 +++- tests/EngineTests.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 73b674c..337156a 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -4,7 +4,7 @@ Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canon 1. Confirm CI artifacts and inspect minimum/default-size GUI renders. Fix functional defects before adding styles. 2. Run pluginval and two-host Windows tests (including ArSonMiX when available). Capture automation, sidechain and project-reload behavior. -3. Listen and measure release/hold/filter transitions, bypass clicks and low-frequency distortion. Add regression cases for actual findings. +3. Filter cutoff/endpoint activation and internal/external detector source now crossfade for 5 ms with regression probes; confirm perceptual quality in a host. Listen and measure release/hold transitions, bypass clicks and low-frequency distortion. Add regression cases for actual findings. 4. Profile with GUI open/closed and many instances at 32/64/128 samples. Optimize only measured hotspots. 5. Work toward Pro-C workflow/quality with documented independent models; never add fake style labels mapped to indistinguishable algorithms. diff --git a/engine/Compressor.cpp b/engine/Compressor.cpp index 0fde0db..bf8a9a6 100644 --- a/engine/Compressor.cpp +++ b/engine/Compressor.cpp @@ -3,6 +3,14 @@ namespace arson { namespace { float clean(float x) noexcept { return std::isfinite(x) ? std::clamp(x,-32.0f,32.0f) : 0.0f; } float flush(float x) noexcept { return std::abs(x)<1.0e-20f ? 0.0f : x; } +// Coefficients are calculated on control updates, not in the sample loop. +// Existing parameter ramps carry the one-pole coefficient for the two filters. +float rampTarget(std::size_t index,float value,double fs) noexcept { + if(index==Input || index==Makeup) return dbToGain(value); + if(index==Highpass) return static_cast(std::exp(-6.28318530718*value/fs)); + if(index==Lowpass) return static_cast(std::exp(-6.28318530718*std::min(value,fs*0.45)/fs)); + return value; +} } void Compressor::prepare(double rate,const Parameters& initial) noexcept { fs=std::isfinite(rate) ? std::clamp(rate,8000.0,384000.0) : 48000; @@ -11,9 +19,13 @@ void Compressor::prepare(double rate,const Parameters& initial) noexcept { hpState={}; lpState={}; rms={}; envelope={}; holdRemaining={}; meter={}; meterCount=0; rmsCoeff=static_cast(std::exp(-1.0/(0.01*fs))); p=initial; p.sanitize(); - for(std::size_t i=0;i20.01f ? 1.0f : 0.0f); + filterWet[1].reset(p[Lowpass]<19999.0f ? 1.0f : 0.0f); + attackCoeff=static_cast(std::exp(-1000.0/(p[Attack]*fs))); + releaseCoeff=static_cast(std::exp(-1000.0/(p[Release]*fs))); + slowReleaseCoeff=static_cast(std::exp(-1000.0/(p[Release]*4.0*fs))); + holdSamples=static_cast(p[Hold]*0.001*fs); } void Compressor::setParameters(Parameters next) noexcept { next.sanitize(); @@ -22,27 +34,29 @@ void Compressor::setParameters(Parameters next) noexcept { releaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*fs))); slowReleaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*4.0*fs))); } - if(next[Highpass]!=p[Highpass]) hpCoeff=static_cast(std::exp(-6.28318530718*next[Highpass]/fs)); - if(next[Lowpass]!=p[Lowpass]) lpCoeff=static_cast(std::exp(-6.28318530718*std::min(next[Lowpass],fs*0.45)/fs)); holdSamples=static_cast(next[Hold]*0.001*fs); - for(std::size_t i=0;i20.01f ? 1.0f : 0.0f,rampLength); + filterWet[1].set(next[Lowpass]<19999.0f ? 1.0f : 0.0f,rampLength); p=next; } void Compressor::process(float* const* audio,int channels,int samples,const float* const* sc,int scChannels,MeterQueue* meters) noexcept { if(!audio || channels<1 || channels>2 || samples<=0) return; - const bool external=p[External]>0.5f; for(int n=0;n v{}; for(std::size_t i=0;i0) ? clean(sc[std::min(c,scChannels-1)][n]) : 0.0f) : dry[c]; + const float side=(sc && scChannels>0) ? clean(sc[std::min(c,scChannels-1)][n]) : 0.0f; + float x=dry[c]+(side-dry[c])*v[External]; hpState[c]=flush(hpCoeff*hpState[c]+(1-hpCoeff)*x); - if(p[Highpass]>20.01f) x-=hpState[c]; + x-=hpWet*hpState[c]; lpState[c]=flush(lpCoeff*lpState[c]+(1-lpCoeff)*x); - if(p[Lowpass]<19999.0f) x=lpState[c]; + x+=(lpState[c]-x)*lpWet; listen[c]=x; rms[c]=flush(rmsCoeff*rms[c]+(1-rmsCoeff)*x*x); // Crossfade detector modes to avoid a discontinuity on automation. diff --git a/engine/Compressor.h b/engine/Compressor.h index e347e39..b7f5bf6 100644 --- a/engine/Compressor.h +++ b/engine/Compressor.h @@ -23,10 +23,12 @@ class Compressor { }; Parameters p; std::array smooth{}; + // Filter on/off is blended separately from cutoff coefficients to avoid endpoint steps. + std::array filterWet{}; std::array hpState{}, lpState{}, rms{}, envelope{}; std::array holdRemaining{}; double fs=48000; - float attackCoeff=0,releaseCoeff=0,slowReleaseCoeff=0,rmsCoeff=0,hpCoeff=0,lpCoeff=0; + float attackCoeff=0,releaseCoeff=0,slowReleaseCoeff=0,rmsCoeff=0; int rampLength=240, meterPeriod=480, meterCount=0,holdSamples=0; MeterFrame meter{}; }; diff --git a/tests/EngineTests.cpp b/tests/EngineTests.cpp index b68c193..43fb73f 100644 --- a/tests/EngineTests.cpp +++ b/tests/EngineTests.cpp @@ -71,6 +71,38 @@ int main() { p.value[External]=0;p.value[Link]=0;c.prepare(48000,p);a.assign(count,1);b.assign(count,0.01f);c.process(ptr,2,count); require(near(b.back(),0.01f),"unlinked low channel uncompressed"); } + { + // Live filter endpoint and source changes must not create one-sample + // steps in Listen SC. Compare the same waveform against an untouched + // engine rather than comparing unrelated consecutive waveform samples. + const auto transitionStep=[](Param control,float target) { + constexpr int n=4096; + Parameters p;p.value[Listen]=1; + Compressor changed,reference;changed.prepare(48000,p);reference.prepare(48000,p); + std::vector a(n),b(n),side(n,-0.25f); + for(int i=0;i audio(1024,0.25f),side(1024,-0.25f); + float* ap[]{audio.data()};const float* sp[]{side.data()}; + c.process(ap,1,1024,sp,1); + p.value[External]=1;c.setParameters(p); + std::fill(audio.begin(),audio.end(),0.25f); + c.process(ap,1,1024,sp,1); + require(near(audio.back(),-0.25f,0.001f),"sidechain source reaches requested signal after ramp"); + } { Compressor c;Parameters p;for(auto& v:p.value)v=std::numeric_limits::quiet_NaN();c.prepare(0,p); float a[]{std::numeric_limits::infinity(),std::numeric_limits::quiet_NaN(),1e-38f,1};float* ptr[]{a};c.process(ptr,1,4); From 7413442a8257ea1f7cb41b700fc35ab6f9f1e961 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 05:26:05 +0700 Subject: [PATCH 06/35] Milestone: three causal compressor models and premium live dynamics UI --- README.md | 6 +- docs/ARD.md | 6 +- docs/HANDOFF.md | 2 +- docs/PRD.md | 4 +- engine/Compressor.cpp | 21 +++- engine/Compressor.h | 2 +- engine/Parameters.h | 5 +- plugin/Editor.cpp | 241 ++++++++++++++++++++++++++++++------------ plugin/Editor.h | 4 +- plugin/Processor.cpp | 3 +- tests/EngineTests.cpp | 26 +++++ tests/PluginSmoke.cpp | 4 + 12 files changed, 237 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 9a481fa..671f6f1 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standalone, zero added algorithmic latency. The interface prioritizes transfer curve, input/output history and gain reduction, with familiar compressor controls and an original ArSon visual identity. -**Status: initial engineering test build, not claimed to match FabFilter's proprietary algorithms or sound.** +**Status: engineering test build with three original compression models and a redesigned graphical interface, not claimed to match FabFilter's proprietary algorithms or sound.** ## Implemented -- Peak and 10 ms RMS detection, threshold, ratio, continuously joined soft knee, range, attack, hold and release. +- Three causal models: Clean feed-forward, Feedback topology, and Smooth dual-envelope response. Peak and 10 ms RMS detection, threshold, ratio, continuously joined soft knee, range, attack, hold and release. - Optional envelope-dependent auto release; stereo link from independent channels to maximum-linked detection. - Internal/external mono/stereo sidechain, high-pass/low-pass detector filters and listen. - Input/makeup gain, dry/wet parallel compression, smoothed bypass, six factory starting points and A/B comparison. -- Stable automation IDs and versioned state recall. Mono and stereo layouts. +- Stable automation IDs and versioned state recall. New model `style` appended without renaming previous parameters. Mono and stereo layouts. - Separate engine without JUCE, locks, heap allocation, I/O, worker dependencies or delay lines in processing. - Bounded SPSC telemetry at 100 Hz; editor coalesces updates at 30 Hz, caches static grid, and repaints only the display during metering. diff --git a/docs/ARD.md b/docs/ARD.md index 46a7a41..e7d3021 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -8,6 +8,10 @@ The processor caches APVTS atomic pointers once, then snapshots parameters once Signal flow: input trim → detector tap → optional detector HP/LP → Peak/RMS blend → channel linking → soft-knee static reduction → attack/hold/release envelope → gain application → parallel mix → SC listen crossfade → bypass crossfade. Dry/wet paths share the same sample index. Bypass returns original input after its short transition. Non-finite input is replaced with silence; input magnitudes beyond ±32 are bounded for numerical containment. +The three independent zero-added-latency models are Clean (feed-forward), Feedback (causal detector sensing prior actual pre-makeup attenuation), and Smooth (a second attack/release pole cascaded with the first). All modes process one shared audio path; a 5 ms model ramp blends their behavior without triple-rendering. The stable model parameter ID `style` is appended to the schema. Existing hosts using the original parameter IDs preserve them. These models are original algorithms, not claimed clones of proprietary compression styles. + +GUI design: a compact 1040x680 (minimum 920x620) slate/amber/cyan interface, a 229px-wide transfer graph with animated operating point, 4-second bounded dynamics history, three meters, smaller legible control knobs and a model selector. Static grid is cached on resize; timed metering repaints only the display. UI draws are never called from the audio callback. + RMS detector uses a 10 ms exponential energy estimate. Attack/release are 63.2% time constants in the dB reduction domain. Auto release blends base and 4× slower release coefficients according to existing reduction. This is an explicit independent design, not a recreation of FabFilter's undisclosed program-dependent models. The first-order detector HP/LP are bypassed at 20 Hz / 20 kHz endpoints. Stereo linking blends each detector toward the maximum channel level. ## Data exchange @@ -20,7 +24,7 @@ RAII owns GUI attachments and buffers. Timer is stopped before editor teardown. ## Reference decisions -- FabFilter Pro-C 2 manual: https://www.fabfilter.com/downloads/pdf/help/ffproc2-manual.pdf — workflow references for dynamics/time controls, sidechain, metering, lookahead and oversampling. Lookahead/oversampling intentionally absent from zero-latency live path. +- FabFilter Pro-C 3 help (2026): https://www.fabfilter.com/help/pro-c — reference for model differentiation, large level/transfer metering, compact controls, and live audio workflow. Original UI design and independent compressor models are mandatory. No FabFilter assets, algorithms or branding are used. Lookahead/oversampling are intentionally absent from the live zero-latency path. - JUCE APVTS documentation: https://docs.juce.com/master/classjuce_1_1AudioProcessorValueTreeState.html — raw atomic parameter reads and state/attachment separation. - JUCE source pinned at 8.0.12: https://github.com/juce-framework/JUCE/tree/29396c22c93392d6738e021b83196283d6e4d850 — build reproducibility, not an assertion this is the newest release. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 337156a..d7ae2eb 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -2,7 +2,7 @@ Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canonical parameter table, not UI strings. The current milestone delivers a complete first compressor path and UI with explicit release gates; it is not the final parity milestone. -1. Confirm CI artifacts and inspect minimum/default-size GUI renders. Fix functional defects before adding styles. +1. This milestone adds three distinct causal models (Clean feed-forward, Feedback, Smooth dual-pole) and a redesigned meter/transfer-centric GUI, without adding samples of latency. Confirm the new CI artifact and visually inspect minimum/default-size GUI PNGs. Review labels, overlap and readability in real Windows scaling. 2. Run pluginval and two-host Windows tests (including ArSonMiX when available). Capture automation, sidechain and project-reload behavior. 3. Filter cutoff/endpoint activation and internal/external detector source now crossfade for 5 ms with regression probes; confirm perceptual quality in a host. Listen and measure release/hold transitions, bypass clicks and low-frequency distortion. Add regression cases for actual findings. 4. Profile with GUI open/closed and many instances at 32/64/128 samples. Optimize only measured hotspots. diff --git a/docs/PRD.md b/docs/PRD.md index 80a92e3..1ae166a 100644 --- a/docs/PRD.md +++ b/docs/PRD.md @@ -5,8 +5,8 @@ ArSonComp is a lightweight live vocal, karaoke, podcast and mix-bus compressor, ## Initial acceptance - Mono/stereo host processing, optional mono/stereo external sidechain, zero added sample delay. -- Useful dynamics controls, bounded range, soft knee, Peak/RMS, stereo link and filtered detector audition. -- Dominant transfer/history display; separate IN/GR/OUT meters; compact knobs and dark readable menus. +- Useful dynamics controls, bounded range, soft knee, Peak/RMS, stereo link and filtered detector audition. Three genuinely different causal models with retained stable IDs and zero sample lookahead. +- Dominant transfer/history display; separate IN/GR/OUT meters; compact, legible knobs, premium dark palette and usable model selector. Verify at minimum/default window sizes. - Presets with actual parameter values, A/B, host automation and state restoration. - No heap allocation/lock/wait in DSP; bounded metering and independent GUI lifetime. - DSP correctness tests, allocation guard, sanitizers, measured throughput, plugin state/editor smoke and Windows artifacts. diff --git a/engine/Compressor.cpp b/engine/Compressor.cpp index bf8a9a6..e9694c9 100644 --- a/engine/Compressor.cpp +++ b/engine/Compressor.cpp @@ -16,7 +16,7 @@ void Compressor::prepare(double rate,const Parameters& initial) noexcept { fs=std::isfinite(rate) ? std::clamp(rate,8000.0,384000.0) : 48000; rampLength=std::max(1,static_cast(fs*0.005)); meterPeriod=std::max(1,static_cast(fs*0.01)); - hpState={}; lpState={}; rms={}; envelope={}; holdRemaining={}; meter={}; meterCount=0; + hpState={}; lpState={}; rms={}; envelope={}; smoothEnvelope={}; previousGain={1.0f,1.0f}; holdRemaining={}; meter={}; meterCount=0; rmsCoeff=static_cast(std::exp(-1.0/(0.01*fs))); p=initial; p.sanitize(); for(std::size_t i=0;i0) ? clean(sc[std::min(c,scChannels-1)][n]) : 0.0f; - float x=dry[c]+(side-dry[c])*v[External]; + const float internal=dry[c]*(1.0f-feedbackWeight*(1.0f-previousGain[c])); + float x=internal+(side-internal)*v[External]; hpState[c]=flush(hpCoeff*hpState[c]+(1-hpCoeff)*x); x-=hpWet*hpState[c]; lpState[c]=flush(lpCoeff*lpState[c]+(1-lpCoeff)*x); @@ -75,14 +80,22 @@ void Compressor::process(float* const* audio,int channels,int samples,const floa env=target+coeff*(env-target); } env=flush(env); - const float wet=dry[c]*dbToGain(-env)*makeupGain; + // Distinct cascaded reduction pole, active only in Smooth mode. + if(smoothWeight>0.0f) { + const float coeff=env>smoothEnvelope[c] ? attackCoeff : releaseCoeff; + smoothEnvelope[c]=flush(env+coeff*(smoothEnvelope[c]-env)); + } else smoothEnvelope[c]=env; + const float effectiveEnv=env+(smoothEnvelope[c]-env)*smoothWeight; + const float attenuation=dbToGain(-effectiveEnv); + previousGain[c]=attenuation; + const float wet=dry[c]*attenuation*makeupGain; float out=dry[c]+(wet-dry[c])*(v[Mix]*0.01f); out+=(listen[c]-out)*v[Listen]; out=v[Bypass]>=1.0f ? original[c] : out+(original[c]-out)*v[Bypass]; audio[c][n]=out; meter.input=std::max(meter.input,std::abs(dry[c])); meter.output=std::max(meter.output,std::abs(out)); - meter.reduction=std::max(meter.reduction,env*(1-v[Bypass])); + meter.reduction=std::max(meter.reduction,effectiveEnv*(1-v[Bypass])); } if(++meterCount>=meterPeriod) { if(meters) meters->push(meter); diff --git a/engine/Compressor.h b/engine/Compressor.h index b7f5bf6..004b2cd 100644 --- a/engine/Compressor.h +++ b/engine/Compressor.h @@ -25,7 +25,7 @@ class Compressor { std::array smooth{}; // Filter on/off is blended separately from cutoff coefficients to avoid endpoint steps. std::array filterWet{}; - std::array hpState{}, lpState{}, rms{}, envelope{}; + std::array hpState{}, lpState{}, rms{}, envelope{}, smoothEnvelope{}, previousGain{1.0f,1.0f}; std::array holdRemaining{}; double fs=48000; float attackCoeff=0,releaseCoeff=0,slowReleaseCoeff=0,rmsCoeff=0; diff --git a/engine/Parameters.h b/engine/Parameters.h index abc331b..b67c5fb 100644 --- a/engine/Parameters.h +++ b/engine/Parameters.h @@ -6,7 +6,7 @@ namespace arson { enum Param : std::size_t { Threshold, Ratio, Attack, Release, Knee, Range, Hold, - Makeup, Mix, Input, Link, Highpass, Lowpass, Detector, AutoRelease, External, Listen, Bypass, Count }; + Makeup, Mix, Input, Link, Highpass, Lowpass, Detector, AutoRelease, External, Listen, Bypass, Style, Count }; struct Spec { const char* id; const char* name; const char* unit; float min, max, initial, skew; }; inline constexpr std::array specs {{ {"threshold", "Threshold", " dB", -60, 0, -18, 1}, @@ -26,7 +26,8 @@ inline constexpr std::array specs {{ {"autoRelease", "Auto release", "", 0, 1, 0, 1}, {"external", "External SC", "", 0, 1, 0, 1}, {"listen", "SC listen", "", 0, 1, 0, 1}, - {"bypass", "Bypass", "", 0, 1, 0, 1} + {"bypass", "Bypass", "", 0, 1, 0, 1}, + {"style", "Compression model", "", 0, 2, 0, 1} }}; struct Parameters { std::array value{}; diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index 995bace..1f274e7 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -1,6 +1,6 @@ #include "Editor.h" namespace { -const juce::Colour bg{0xff171a1f},panel{0xff101318},line{0xff303740},text{0xffd4dbe1},muted{0xff89939f},cyan{0xff59c9dc},gold{0xffe4b65e}; +const juce::Colour bg{0xff11151b},panel{0xff161c24},line{0xff303b49},text{0xffe4eaf2},muted{0xff9aa7b8},cyan{0xff4edbd4},gold{0xffffc270}; } CompLook::CompLook() { setColour(juce::Slider::textBoxTextColourId,text); @@ -27,17 +27,30 @@ juce::Label* CompLook::createSliderTextBox(juce::Slider& slider) { return label; } void CompLook::drawRotarySlider(juce::Graphics& g,int x,int y,int w,int h,float pos,float start,float end,juce::Slider&) { - const auto bounds=juce::Rectangle(static_cast(x),static_cast(y),static_cast(w),static_cast(h)).reduced(6); - const float r=std::min(bounds.getWidth(),bounds.getHeight())*0.5f,cx=bounds.getCentreX(),cy=bounds.getCentreY(); + const auto bounds=juce::Rectangle(static_cast(x),static_cast(y), + static_cast(w),static_cast(h)).reduced(9.0f); + const float r=std::min(bounds.getWidth(),bounds.getHeight())*0.5f; + const float cx=bounds.getCentreX(),cy=bounds.getCentreY(); + g.setColour(juce::Colour{0xff202a35}); + g.fillEllipse(cx-r+3,cy-r+3,2*r-6,2*r-6); + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff3a4652},cx-r,cy-r, + juce::Colour{0xff121820},cx+r,cy+r,false)); + g.fillEllipse(cx-r+7,cy-r+7,2*r-14,2*r-14); juce::Path track,active; track.addCentredArc(cx,cy,r,r,0,start,end,true); active.addCentredArc(cx,cy,r,r,0,start,start+pos*(end-start),true); - g.setColour(line); g.strokePath(track,juce::PathStrokeType(2.5f)); - g.setColour(cyan); g.strokePath(active,juce::PathStrokeType(2.5f)); - g.setColour(juce::Colour{0xff262d35}); g.fillEllipse(cx-r+5,cy-r+5,2*r-10,2*r-10); - const float a=start+pos*(end-start); - g.setColour(text); g.drawLine(cx+std::sin(a)*(r*0.45f),cy-std::cos(a)*(r*0.45f),cx+std::sin(a)*(r*0.75f),cy-std::cos(a)*(r*0.75f),2); + g.setColour(juce::Colour{0xff485361}); + g.strokePath(track,juce::PathStrokeType(3.2f)); + g.setColour(gold); + g.strokePath(active,juce::PathStrokeType(3.2f)); + const float angle=start+pos*(end-start); + g.setColour(text); + g.drawLine(cx+std::sin(angle)*r*0.35f,cy-std::cos(angle)*r*0.35f, + cx+std::sin(angle)*r*0.73f,cy-std::cos(angle)*r*0.73f,2.1f); + g.setColour(juce::Colour{0xff8c9bac}); + g.fillEllipse(cx-1.6f,cy-1.6f,3.2f,3.2f); } + Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.snapshot()) { setLookAndFeel(&look); setOpaque(true); for(std::size_t i=0;i(p.state,s.id,k); } + style.addItemList({"Clean - feedforward","Feedback - classic","Smooth - dual envelope"},1); + style.setTooltip("Genuinely different DSP models: causal feed-forward, feedback, and dual-envelope."); + addAndMakeVisible(style); + styleAttachment=std::make_unique(p.state,"style",style); presets.addItemList({"Default","Vocal | gentle","Vocal | level","Mix bus | glue","Drums | punch","Podcast | steady"},1); presets.setSelectedId(1,juce::dontSendNotification); presets.onChange=[this]{applyPreset(presets.getSelectedId());}; presets.setTooltip("Factory starting points. Adjust threshold to your input level."); addAndMakeVisible(presets); @@ -69,7 +86,7 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn addAndMakeVisible(compare); arson::MeterFrame discard; for(std::uint32_t i=0;i primary{arson::Threshold,arson::Ratio,arson::Attack,arson::Release,arson::Knee,arson::Range,arson::Makeup,arson::Mix}; + const int w=getWidth(),h=getHeight(); + style.setBounds(270,25,154,29); + presets.setBounds(w-426,25,200,29); + compare.setBounds(w-213,25,69,29); + bypass.setBounds(w-135,25,113,29); + display={18,66,w-36,h-326}; + const int y=display.getBottom()+14,knobWidth=(w-40)/8; + const std::array primary{arson::Threshold,arson::Ratio,arson::Attack, + arson::Release,arson::Knee,arson::Range,arson::Makeup,arson::Mix}; for(std::size_t j=0;j(j)*width; - labels[i].setBounds(x,y,width,18); knobs[i].setBounds(x+6,y+18,width-12,88); + const auto i=primary[j];const int x=20+static_cast(j)*knobWidth; + labels[i].setBounds(x,y,knobWidth,18); + knobs[i].setBounds(x+5,y+17,knobWidth-10,89); } - const int bottom=y+121, small=(getWidth()-300)/5; - const std::array secondary{arson::Input,arson::Hold,arson::Link,arson::Highpass,arson::Lowpass}; + const int bottom=y+118,small=(w-300)/5; + const std::array secondary{arson::Input,arson::Hold,arson::Link, + arson::Highpass,arson::Lowpass}; for(std::size_t j=0;j(j)*small; - labels[i].setBounds(x,bottom,small,16); knobs[i].setBounds(x+12,bottom+16,small-24,72); + const auto i=secondary[j];const int x=20+static_cast(j)*small; + labels[i].setBounds(x,bottom,small,18); + knobs[i].setBounds(x+7,bottom+17,small-14,77); } - const int x=getWidth()-260; - detector.setBounds(x,bottom+5,98,25); autoRelease.setBounds(x+106,bottom+5,130,25); - external.setBounds(x,bottom+41,120,25); listen.setBounds(x+126,bottom+41,110,25); + const int x=w-272; + detector.setBounds(x,bottom+7,103,26); + autoRelease.setBounds(x+110,bottom+7,146,26); + external.setBounds(x,bottom+43,125,26); + listen.setBounds(x+135,bottom+43,120,26); grid=juce::Image(juce::Image::RGB,display.getWidth(),display.getHeight(),true); - juce::Graphics g(grid); g.fillAll(panel); g.setFont(juce::FontOptions(11)); + juce::Graphics g(grid); + g.fillAll(panel); + const int graphLeft=290,graphRight=display.getWidth()-132; + const float top=32.0f,bottomY=static_cast(display.getHeight()-35); for(int db=0;db>=-60;db-=12) { - const float yy=26+static_cast(-db)/60*(display.getHeight()-52); - g.setColour(line.withAlpha(0.55f)); g.drawHorizontalLine(static_cast(yy),200.0f,static_cast(display.getWidth()-140)); - g.setColour(muted);g.drawText(juce::String(db),display.getWidth()-140,static_cast(yy)-7,28,14,juce::Justification::centredRight); + const float yy=bottomY-static_cast(db+60)/60.0f*(bottomY-top); + g.setColour(line.withAlpha(0.50f)); + g.drawHorizontalLine(static_cast(yy),static_cast(graphLeft),static_cast(graphRight)); + g.setColour(muted.withAlpha(0.65f));g.setFont(juce::FontOptions(10)); + g.drawText(juce::String(db),graphRight+3,static_cast(yy)-8,23,16,juce::Justification::centred); } + for(int i=1;i<8;++i) { + const float xx=static_cast(graphLeft)+(graphRight-graphLeft)*i/8.0f; + g.setColour(line.withAlpha(0.32f));g.drawVerticalLine(static_cast(xx),top,bottomY); + } + g.setColour(line);g.drawVerticalLine(272,16.0f,static_cast(display.getHeight()-16)); + g.drawVerticalLine(display.getWidth()-124,16.0f,static_cast(display.getHeight()-16)); } + void Editor::timerCallback() { if(!isShowing()) return; if(presets.getSelectedId()>0) { @@ -132,57 +171,119 @@ void Editor::timerCallback() { repaint(display); } void Editor::paint(juce::Graphics& g) { - g.fillAll(bg);g.setColour(text);g.setFont(juce::FontOptions(19));g.drawText("ArSonComp",22,16,170,27,juce::Justification::centredLeft); - g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("LIVE COMPRESSOR",170,18,150,24,juce::Justification::centredLeft); - g.drawImageAt(grid,display.getX(),display.getY());drawDisplay(g); - g.setColour(line);g.drawHorizontalLine(display.getBottom()+133,20.0f,static_cast(getWidth()-20)); - g.setColour(muted);g.setFont(juce::FontOptions(11));g.drawText("0 samples latency | No lookahead | Native processing",22,getHeight()-25,400,18,juce::Justification::centredLeft); - g.drawText("Double-click to reset / Click value to type",getWidth()-310,getHeight()-25,288,18,juce::Justification::centredRight); + g.fillAll(bg); + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff212a35},0.0f,0.0f,bg,0.0f,64.0f,false)); + g.fillRect(0,0,getWidth(),65); + g.setColour(text);g.setFont(juce::FontOptions(21)); + g.drawText("ArSonComp",21,13,190,29,juce::Justification::centredLeft); + g.setColour(gold);g.fillRoundedRectangle(23.0f,48.0f,53.0f,2.0f,1.0f); + g.setColour(muted);g.setFont(juce::FontOptions(10)); + g.drawText("LIVE DYNAMICS",88,44,145,14,juce::Justification::centredLeft); + g.drawText("MODEL",271,8,146,15,juce::Justification::left); + g.drawText("FACTORY PRESET",getWidth()-425,8,194,15,juce::Justification::left); + if(grid.isValid())g.drawImageAt(grid,display.getX(),display.getY()); + g.setColour(line);g.drawRoundedRectangle(display.toFloat(),6.0f,1.0f); + drawDisplay(g); + g.setColour(line.withAlpha(0.75f)); + g.drawHorizontalLine(display.getBottom()+123,20.0f,static_cast(getWidth()-20)); + g.setColour(muted);g.setFont(juce::FontOptions(10.5f)); + g.drawText("0 SAMPLES ADDED | REAL-TIME DSP | VST3",20,getHeight()-25,455,17,juce::Justification::left); + g.drawText("Drag controls / double-click reset / type exact values", + getWidth()-420,getHeight()-25,400,17,juce::Justification::centredRight); } + void Editor::drawDisplay(juce::Graphics& g) { - juce::Graphics::ScopedSaveState save(g);g.reduceClipRegion(display);g.setOrigin(display.getPosition()); - const float h=static_cast(display.getHeight()),w=static_cast(display.getWidth()); + juce::Graphics::ScopedSaveState save(g); + g.reduceClipRegion(display); + g.setOrigin(display.getPosition()); + const float h=static_cast(display.getHeight()); + const float w=static_cast(display.getWidth()); const auto p=processor.snapshot(); - g.setFont(juce::FontOptions(11));g.setColour(muted);g.drawText("TRANSFER",16,10,150,18,juce::Justification::centredLeft); - const juce::Rectangle curve{18,42,154,h-78}; - const auto cy=[&](float db){return curve.getBottom()-juce::jlimit(0.0f,1.0f,(db+60)/60)*curve.getHeight();}; - g.setColour(line);g.drawRect(curve);g.drawLine(curve.getX(),curve.getBottom(),curve.getRight(),curve.getY()); + const float top=32.0f,bottom=h-35.0f; + g.setFont(juce::FontOptions(11.0f)); + g.setColour(muted);g.drawText("COMPRESSION CURVE",23,10,235,18,juce::Justification::left); + g.drawText("DYNAMICS | 4s",291,10,230,18,juce::Justification::left); + + const juce::Rectangle curve{26.0f,top,229.0f,bottom-top}; + const auto yCurve=[&](float db) { + return curve.getBottom()-juce::jlimit(0.0f,1.0f,(db+60.0f)/60.0f)*curve.getHeight(); + }; + g.setColour(line.withAlpha(0.75f));g.drawRect(curve,1.0f); + g.setColour(muted.withAlpha(0.30f)); + g.drawLine(curve.getX(),curve.getBottom(),curve.getRight(),curve.getY(),1.0f); + const float tx=curve.getX()+juce::jlimit(0.0f,1.0f,(p[arson::Threshold]+60)/60.0f)*curve.getWidth(); + g.setColour(gold.withAlpha(0.30f));g.drawVerticalLine(static_cast(tx),top,bottom); juce::Path transfer; - for(int i=0;i<=154;++i) { - const float db=-60+60.0f*i/154,red=arson::reduction(db,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range]); - const float yy=cy(db-red);if(i==0)transfer.startNewSubPath(curve.getX()+i,yy);else transfer.lineTo(curve.getX()+i,yy); + for(int i=0;i<=229;++i) { + const float db=-60.0f+60.0f*i/229.0f; + const float gain=arson::reduction(db,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range]); + const float yy=yCurve(db-gain); + if(i==0)transfer.startNewSubPath(curve.getX(),yy); + else transfer.lineTo(curve.getX()+i,yy); } - g.setColour(gold);g.strokePath(transfer,juce::PathStrokeType(2)); + g.setColour(gold.withAlpha(0.18f));g.strokePath(transfer,juce::PathStrokeType(5.0f)); + g.setColour(gold);g.strokePath(transfer,juce::PathStrokeType(1.9f)); const float dotX=curve.getX()+juce::jlimit(0.0f,1.0f,(inputDb+60)/60)*curve.getWidth(); - const float dotY=cy(inputDb-arson::reduction(inputDb,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range])); - g.fillEllipse(dotX-3,dotY-3,6,6); - g.setColour(muted);g.drawText("-60 Input dB 0",14,static_cast(h)-28,168,18,juce::Justification::centred); - const float left=200,right=w-148,top=26,bottom=h-26; - const auto y=[&](float level){return bottom-juce::jlimit(0.0f,1.0f,(level+60)/60)*(bottom-top);}; - juce::Path input,output,reduction; + const float dotY=yCurve(inputDb-arson::reduction(inputDb,p[arson::Threshold], + p[arson::Ratio],p[arson::Knee],p[arson::Range])); + g.setColour(gold.withAlpha(0.25f));g.fillEllipse(dotX-6,dotY-6,12,12); + g.setColour(juce::Colours::white);g.fillEllipse(dotX-2.2f,dotY-2.2f,4.4f,4.4f); + g.setColour(muted);g.setFont(juce::FontOptions(10.0f)); + g.drawText("-60 dB",24,static_cast(h)-29,65,17,juce::Justification::left); + g.drawText("0 dB",190,static_cast(h)-29,65,17,juce::Justification::right); + + // GUI drains a fixed 400-frame telemetry history; no audio-thread graphics. + const float left=290,right=w-132; + const auto levelY=[&](float db) { + return bottom-juce::jlimit(0.0f,1.0f,(db+60.0f)/60.0f)*(bottom-top); + }; + juce::Path inPath,outPath,grPath,grFill; for(std::size_t i=0;i(i)/(history.size()-1); - const float a=y(arson::gainToDb(f.input)),b=y(arson::gainToDb(f.output)),c=top+std::min(f.reduction/36.0f,1.0f)*(bottom-top); - if(i==0) { input.startNewSubPath(x,a);output.startNewSubPath(x,b);reduction.startNewSubPath(x,c); } - else { input.lineTo(x,a);output.lineTo(x,b);reduction.lineTo(x,c); } + const auto& f=history[(head+i)%history.size()]; + const float xx=left+(right-left)*static_cast(i)/(history.size()-1); + const float iy=levelY(arson::gainToDb(f.input)); + const float oy=levelY(arson::gainToDb(f.output)); + const float ry=top+juce::jlimit(0.0f,1.0f,f.reduction/36.0f)*(bottom-top); + if(i==0) { + inPath.startNewSubPath(xx,iy);outPath.startNewSubPath(xx,oy); + grPath.startNewSubPath(xx,ry); + grFill.startNewSubPath(xx,top);grFill.lineTo(xx,ry); + } else { + inPath.lineTo(xx,iy);outPath.lineTo(xx,oy); + grPath.lineTo(xx,ry);grFill.lineTo(xx,ry); + } } - g.setColour(muted.withAlpha(0.5f));g.strokePath(input,juce::PathStrokeType(1)); - g.setColour(cyan);g.strokePath(output,juce::PathStrokeType(1.4f)); - g.setColour(gold);g.strokePath(reduction,juce::PathStrokeType(1.5f)); - g.setColour(gold.withAlpha(0.35f));g.drawHorizontalLine(static_cast(y(p[arson::Threshold])),left,right); - g.setColour(muted);g.drawText("IN",202,5,30,18,juce::Justification::left);g.setColour(cyan);g.drawText("OUT",238,5,40,18,juce::Justification::left); - g.setColour(gold);g.drawText("GR 0-36 dB",285,5,110,18,juce::Justification::left); + grFill.lineTo(right,top);grFill.closeSubPath(); + g.setGradientFill(juce::ColourGradient(gold.withAlpha(0.16f),left,top, + gold.withAlpha(0.0f),left,bottom,false)); + g.fillPath(grFill); + g.setColour(muted.withAlpha(0.48f));g.strokePath(inPath,juce::PathStrokeType(1.05f)); + g.setColour(cyan.withAlpha(0.93f));g.strokePath(outPath,juce::PathStrokeType(1.55f)); + g.setColour(gold);g.strokePath(grPath,juce::PathStrokeType(1.55f)); + g.setColour(gold.withAlpha(0.33f)); + g.drawHorizontalLine(static_cast(levelY(p[arson::Threshold])),left,right); + g.setFont(juce::FontOptions(10.5f)); + g.setColour(muted);g.drawText("IN",static_cast(left),static_cast(h)-28,36,17,juce::Justification::left); + g.setColour(cyan);g.drawText("OUT",static_cast(left)+38,static_cast(h)-28,48,17,juce::Justification::left); + g.setColour(gold);g.drawText("GR",static_cast(left)+93,static_cast(h)-28,38,17,juce::Justification::left); const float values[]{inputDb,gr,outputDb};const char* names[]{"IN","GR","OUT"}; for(int i=0;i<3;++i) { - const int x=static_cast(w)-106+i*35; - g.setColour(muted);g.drawText(names[i],x-4,8,34,18,juce::Justification::centred); - g.setColour(line);g.fillRect(static_cast(x+7),36.0f,9.0f,h-76); - const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36) : juce::jlimit(0.0f,1.0f,(values[i]+60)/60); - const float bar=(h-76)*amount;g.setColour(i==1 ? gold : cyan); - g.fillRect(static_cast(x+7),i==1 ? 36.0f : h-40-bar,9.0f,bar); - g.setColour(text);g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1),x-8,static_cast(h)-30,42,18,juce::Justification::centred); + const float x=w-116.0f+static_cast(i)*37.0f; + g.setColour(muted);g.drawText(names[i],static_cast(x)-3,8,31,18,juce::Justification::centred); + g.setColour(juce::Colour{0xff26313c});g.fillRoundedRectangle(x+7,top,10,bottom-top,3); + const float fraction=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36.0f) + : juce::jlimit(0.0f,1.0f,(values[i]+60.0f)/60.0f); + const float filled=(bottom-top)*fraction; + g.setColour(i==1 ? gold : cyan); + if(filled>0)g.fillRoundedRectangle(x+7,(i==1 ? top : bottom-filled),10,filled,3.0f); + g.setColour(text);g.setFont(juce::FontOptions(10.0f)); + g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1), + static_cast(x)-6,static_cast(h)-29,39,18,juce::Justification::centred); } if(p[arson::Listen]>0.5f || p[arson::Bypass]>0.5f) { - g.setColour(gold);g.drawText(p[arson::Bypass]>0.5f ? "BYPASSED" : "SIDECHAIN LISTEN",static_cast(left),static_cast(h)-23,250,18,juce::Justification::left); + g.setColour(gold);g.setFont(juce::FontOptions(11.0f)); + g.drawText(p[arson::Bypass]>0.5f ? "BYPASSED" : "SIDECHAIN MONITOR", + static_cast(left)+125,8,210,18,juce::Justification::left); } } + diff --git a/plugin/Editor.h b/plugin/Editor.h index 4bdbf44..fbf495a 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -26,11 +26,11 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { using SliderAttachment=juce::AudioProcessorValueTreeState::SliderAttachment; using ButtonAttachment=juce::AudioProcessorValueTreeState::ButtonAttachment; std::array,arson::Detector> attachments; - juce::ComboBox presets,detector; + juce::ComboBox presets,detector,style; juce::TextButton compare{"A / B"}; juce::ToggleButton autoRelease{"Auto release"},external{"External SC"},listen{"Listen SC"},bypass{"Bypass"}; std::array,4> buttons; - std::unique_ptr detectorAttachment; + std::unique_ptr detectorAttachment,styleAttachment; arson::Parameters alternate, presetSnapshot; bool alternateActive=false; std::array history{}; diff --git a/plugin/Processor.cpp b/plugin/Processor.cpp index b9b3eab..06301f3 100644 --- a/plugin/Processor.cpp +++ b/plugin/Processor.cpp @@ -4,7 +4,8 @@ juce::AudioProcessorValueTreeState::ParameterLayout Processor::layout() { juce::AudioProcessorValueTreeState::ParameterLayout result; for(std::size_t i=0;i(id,s.name,juce::StringArray{"Peak","RMS"},0)); + if(i==arson::Style) result.add(std::make_unique(id,s.name,juce::StringArray{"Clean","Feedback","Smooth"},0)); + else if(i==arson::Detector) result.add(std::make_unique(id,s.name,juce::StringArray{"Peak","RMS"},0)); else if(i>arson::Detector) result.add(std::make_unique(id,s.name,s.initial>0.5f)); else result.add(std::make_unique(id,s.name, juce::NormalisableRange{s.min,s.max,0.0f,s.skew},s.initial, diff --git a/tests/EngineTests.cpp b/tests/EngineTests.cpp index 43fb73f..6c20629 100644 --- a/tests/EngineTests.cpp +++ b/tests/EngineTests.cpp @@ -103,6 +103,32 @@ int main() { c.process(ap,1,1024,sp,1); require(near(audio.back(),-0.25f,0.001f),"sidechain source reaches requested signal after ramp"); } + { + // Three model topologies must produce measurably different transients. + const auto sampleAt=[](int model,int length) { + Parameters p;p.value[Style]=static_cast(model); + p.value[Threshold]=-24;p.value[Ratio]=8;p.value[Attack]=10; + p.value[Release]=250;p.value[Knee]=0; + Compressor c;c.prepare(48000,p); + std::vector a(static_cast(length),1.0f); + float* ptr[]{a.data()};c.process(ptr,1,length);return a.back(); + }; + const float clean=sampleAt(0,480),feedback=sampleAt(1,480),smooth=sampleAt(2,480); + require(feedback>clean+0.02f,"feedback differs from feedforward"); + require(smooth>clean+0.02f,"dual-pole differs from feedforward"); + for(float model : {0.0f,1.0f,2.0f}) { + Parameters p;p.value[Style]=model;p.value[Threshold]=-25; + Compressor a,b;a.prepare(48000,p);b.prepare(48000,p); + std::vector whole(4096),split(4096); + for(int i=0;i<4096;++i)whole[i]=split[i]=0.7f*std::sin(i*0.14f); + float* one[]{whole.data()};a.process(one,1,4096); + for(int offset=0;offset<4096;) { + const int n=std::min(43,4096-offset); + float* part[]{split.data()+offset};b.process(part,1,n);offset+=n; + } + require(whole==split,"style block partition invariance"); + } + } { Compressor c;Parameters p;for(auto& v:p.value)v=std::numeric_limits::quiet_NaN();c.prepare(0,p); float a[]{std::numeric_limits::infinity(),std::numeric_limits::quiet_NaN(),1e-38f,1};float* ptr[]{a};c.process(ptr,1,4); diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 6c2937b..3580db2 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -9,8 +9,12 @@ int main(int argc,char** argv) { if(parameter->getText(parameter->convertTo0to1(-27),32)!="-27.0")return 5; auto* frequency=processor.state.getParameter("lowpass"); if(frequency->getText(frequency->convertTo0to1(20000),32)!="20000")return 6; + auto* model=processor.state.getParameter("style"); + if(!model || model->getNumSteps()!=3)return 7; + model->setValueNotifyingHost(model->convertTo0to1(2)); juce::MemoryBlock state;processor.getStateInformation(state);parameter->setValueNotifyingHost(parameter->convertTo0to1(-5));processor.setStateInformation(state.getData(),static_cast(state.getSize())); if(std::abs(processor.snapshot()[arson::Threshold]+27)>0.01f)return 2; + if(std::abs(processor.snapshot()[arson::Style]-2.0f)>0.01f)return 8; juce::AudioBuffer buffer(2,128);juce::MidiBuffer midi; for(int j=0;j<1000;++j) {buffer.clear();buffer.setSample(0,0,0.5f);processor.processBlock(buffer,midi);} for(int iteration=0;iteration<8;++iteration) { From c829ecb32c508694d9781a7f95c002f856ef7000 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 05:36:38 +0700 Subject: [PATCH 07/35] Milestone: live DSP control coalescing, interactive threshold, vintage compact metering and stress tests --- README.md | 4 +- docs/ARD.md | 6 +-- docs/HANDOFF.md | 2 +- docs/VALIDATION.md | 6 +++ engine/Compressor.cpp | 21 ++++++-- plugin/Editor.cpp | 117 +++++++++++++++++++++++++++++++++++++----- plugin/Editor.h | 8 ++- tests/Benchmark.cpp | 50 +++++++++++++++--- tests/EngineTests.cpp | 35 +++++++++++++ tests/PluginSmoke.cpp | 21 +++++++- 10 files changed, 238 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 671f6f1..a4d8901 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standa - Stable automation IDs and versioned state recall. New model `style` appended without renaming previous parameters. Mono and stereo layouts. - Separate engine without JUCE, locks, heap allocation, I/O, worker dependencies or delay lines in processing. - Bounded SPSC telemetry at 100 Hz; editor coalesces updates at 30 Hz, caches static grid, and repaints only the display during metering. +- UI supports a warm graphite/brass/teal vintage theme, direct threshold-marker dragging, and a 380 px compact view without extra DSP work. +- Host parameters are diffed once per block; unchanged input/makeup/filter parameters do not trigger redundant coefficient or exponent recalculation. Peak detection skips RMS square root while its RMS state remains warm. Zero latency means **0 additional samples from this plugin**, not zero audio-interface/host buffering. Fast attacks can distort low-frequency material; no lookahead means transients can pass. It is a compressor, not a brickwall limiter. The current model is feed-forward, without oversampling, saturation or linear-phase filtering. @@ -49,7 +51,7 @@ Use `-DARSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug` on GCC/Clang for ASan/UBSan. 4. Enable External SC only after routing a detector signal in your host. An unconnected external bus receives silence. 5. Use Listen SC to audition the detector, then turn it off. Match output loudness with Makeup before comparing A/B. -Double-click knobs to reset; click values to type. Presets do not overwrite external sidechain, listen or bypass. A/B swaps all parameters; it is an editor-session comparison, not a second saved host program. +Double-click knobs to reset; click values to type. The gold marker in the transfer display can also be dragged to automate Threshold with a single host gesture. MINI switches to a compact, hardware-inspired layout (FULL restores the previous size); this is a GUI-only choice that does not alter audio or latency. Presets do not overwrite external sidechain, listen or bypass. A/B swaps all parameters; it is an editor-session comparison, not a second saved host program. ## Verification and scope diff --git a/docs/ARD.md b/docs/ARD.md index e7d3021..e95a2db 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -4,7 +4,7 @@ `engine/` is a C++17 static library; `plugin/Processor` adapts host buses, parameters and state; `plugin/Editor` owns presentation. DSP lifetime is independent of editor lifetime. No worker is needed for this bounded, causal processing workload. -The processor caches APVTS atomic pointers once, then snapshots parameters once per block. Parameters are clamped/canonicalized; expensive time/filter coefficients only change when their parameter changes. Input/makeup dB conversion occurs at control updates and linear gain ramps run in audio. Five-millisecond ramps protect continuous gain/curve/mix and boolean transitions. Attack/release coefficient updates preserve the current envelope. Sidechain filter coefficients update at block boundaries; rapid cutoff automation during Listen SC still needs listening validation. +The processor caches APVTS atomic pointers once, then snapshots parameters once per block. Snapshot comparisons happen before coefficient/linear gain conversions, eliminating `exp` work for unchanged host values. The Peak path keeps RMS state updated but skips an unnecessary `sqrt`; detector transitions still crossfade over 5 ms. Parameters are clamped/canonicalized; expensive time/filter coefficients only change when their parameter changes. Input/makeup dB conversion occurs at control updates and linear gain ramps run in audio. Five-millisecond ramps protect continuous gain/curve/mix and boolean transitions. Attack/release coefficient updates preserve the current envelope. Sidechain filter coefficients update at block boundaries; rapid cutoff automation during Listen SC still needs listening validation. Signal flow: input trim → detector tap → optional detector HP/LP → Peak/RMS blend → channel linking → soft-knee static reduction → attack/hold/release envelope → gain application → parallel mix → SC listen crossfade → bypass crossfade. Dry/wet paths share the same sample index. Bypass returns original input after its short transition. Non-finite input is replaced with silence; input magnitudes beyond ±32 are bounded for numerical containment. @@ -16,7 +16,7 @@ RMS detector uses a 10 ms exponential energy estimate. Attack/release are 63.2% ## Data exchange -A fixed 512-slot SPSC queue transfers 10 ms maxima (input, output, reduction). Acquire/release publication protects non-atomic slots; read/write indices occupy distinct cache lines. Audio drops frames if full. There is exactly one editor consumer. Editor drains at most 512 frames per 30 Hz tick, updates its fixed 400-frame history and coalesces meter repaint. Reopening discards a bounded stale backlog. Static display grid is rebuilt on resize, not on audio or every timer tick. +A fixed 512-slot SPSC queue transfers 10 ms maxima (input, output, reduction). Acquire/release publication protects non-atomic slots; read/write indices occupy distinct cache lines. Audio drops frames if full. There is exactly one editor consumer. Editor drains at most 512 frames per 30 Hz tick, updates its fixed 400-frame history and coalesces meter repaint. The editor also supports an original compact hardware-inspired layout (380 px tall, no graph allocations) and direct transfer-marker threshold gestures with one `beginChangeGesture`/`endChangeGesture` pair per drag; teardown ends any unfinished gesture. Reopening discards a bounded stale backlog. Static display grid is rebuilt on resize, not on audio or every timer tick. APVTS parameter atomics are independent, so bulk preset/state changes can be observed across adjacent audio blocks; five-millisecond ramps limit transition artifacts. They are not claimed to be a transactional sample-accurate preset switch. Host automation is block-rate in this implementation. State XML serialization is outside processBlock. Schema 1 rejects unknown root/schema and restores finite, clamped known values. @@ -24,7 +24,7 @@ RAII owns GUI attachments and buffers. Timer is stopped before editor teardown. ## Reference decisions -- FabFilter Pro-C 3 help (2026): https://www.fabfilter.com/help/pro-c — reference for model differentiation, large level/transfer metering, compact controls, and live audio workflow. Original UI design and independent compressor models are mandatory. No FabFilter assets, algorithms or branding are used. Lookahead/oversampling are intentionally absent from the live zero-latency path. +- FabFilter Pro-C 3 help (2026): https://www.fabfilter.com/help/pro-c — reference for model differentiation, large level/transfer metering, compact controls, and live audio workflow. Official detailed UI evidence: https://www.fabfilter.com/help/pro-c/using/displays and https://www.fabfilter.com/help/pro-c/using/overview . Latency design: https://www.fabfilter.com/help/pro-c/using/oversampling (zero-latency requires lookahead and oversampling Off). Original UI design and independent compressor models are mandatory. No FabFilter assets, algorithms or branding are used. Lookahead/oversampling are intentionally absent from the live zero-latency path. - JUCE APVTS documentation: https://docs.juce.com/master/classjuce_1_1AudioProcessorValueTreeState.html — raw atomic parameter reads and state/attachment separation. - JUCE source pinned at 8.0.12: https://github.com/juce-framework/JUCE/tree/29396c22c93392d6738e021b83196283d6e4d850 — build reproducibility, not an assertion this is the newest release. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index d7ae2eb..577b01f 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -2,7 +2,7 @@ Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canonical parameter table, not UI strings. The current milestone delivers a complete first compressor path and UI with explicit release gates; it is not the final parity milestone. -1. This milestone adds three distinct causal models (Clean feed-forward, Feedback, Smooth dual-pole) and a redesigned meter/transfer-centric GUI, without adding samples of latency. Confirm the new CI artifact and visually inspect minimum/default-size GUI PNGs. Review labels, overlap and readability in real Windows scaling. +1. This milestone adds three distinct causal models (Clean feed-forward, Feedback, Smooth dual-pole) and a redesigned meter/transfer-centric GUI, without adding samples of latency. Next batch optimizes unchanged host snapshots and Peak RMS meter CPU, adds direct transfer-marker threshold editing with one automation gesture and a fully reflowed 380 px vintage compact GUI. Smoke screenshots now cover default, minimum and compact sizes; visually inspect all three in Windows artifacts. Confirm the new CI artifact and visually inspect minimum/default-size GUI PNGs. Review labels, overlap and readability in real Windows scaling. 2. Run pluginval and two-host Windows tests (including ArSonMiX when available). Capture automation, sidechain and project-reload behavior. 3. Filter cutoff/endpoint activation and internal/external detector source now crossfade for 5 ms with regression probes; confirm perceptual quality in a host. Listen and measure release/hold transitions, bypass clicks and low-frequency distortion. Add regression cases for actual findings. 4. Profile with GUI open/closed and many instances at 32/64/128 samples. Optimize only measured hotspots. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index a2649f5..fe1c6c9 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -11,3 +11,9 @@ Local Release throughput example: ~94.9 ns/stereo frame (~0.456% of one 48 kHz r Windows MSVC Release VST3 and standalone compilation and engine tests passed in CI run 41132714813. The GUI-smoke script used an incorrect executable name; the correction registers the executable as a CTest target, avoiding hard-coded paths. Pending until evidence is recorded: editor lifecycle/state test and visual inspection, Windows host/pluginval/hardware tests, listening comparison, leak-check CI. No tested production-ready or Pro-C sonic-parity claim. + +## Control-path and GUI milestone (2026-10-31, pending CI) + +Source changes: avoid control-rate exponent evaluations for unchanged APVTS values; skip RMS square root on Peak-only samples without freezing the RMS state; preserve automation smoothing and arbitrary-block equivalence. Additional tests cover repeated no-op snapshots, rapid style/detector/filter/bypass/mix automation with no allocation, valid output, three-style 64-sample host-snapshot benchmarks and exact-sized 1040x680 / 920x620 editor snapshots plus 380px compact capture. The threshold line uses one begin/end host gesture per drag, including early editor teardown. No new DSP latency, worker or audio-thread lock. + +Current results must be recorded from the CI run for the commit which introduces this section, not inherited from prior runs. GUI captures are functional smoke evidence only until visually reviewed. Pluginval, long-running host stress, listening and Pro-C 3 comparison still pending. References: https://www.fabfilter.com/help/pro-c/using/overview ; https://www.fabfilter.com/help/pro-c/using/displays ; https://www.fabfilter.com/help/pro-c/using/oversampling . diff --git a/engine/Compressor.cpp b/engine/Compressor.cpp index e9694c9..2bb0c5f 100644 --- a/engine/Compressor.cpp +++ b/engine/Compressor.cpp @@ -34,10 +34,16 @@ void Compressor::setParameters(Parameters next) noexcept { releaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*fs))); slowReleaseCoeff=static_cast(std::exp(-1000.0/(next[Release]*4.0*fs))); } - holdSamples=static_cast(next[Hold]*0.001*fs); - for(std::size_t i=0;i20.01f ? 1.0f : 0.0f,rampLength); - filterWet[1].set(next[Lowpass]<19999.0f ? 1.0f : 0.0f,rampLength); + // Host snapshots arrive every audio block, usually without parameter + // changes. Coalesce all target calculations; avoid exp() when idle. + if(next[Hold]!=p[Hold]) holdSamples=static_cast(next[Hold]*0.001*fs); + for(std::size_t i=0;i20.01f ? 1.0f : 0.0f,rampLength); + if(next[Lowpass]!=p[Lowpass]) + filterWet[1].set(next[Lowpass]<19999.0f ? 1.0f : 0.0f,rampLength); p=next; } void Compressor::process(float* const* audio,int channels,int samples,const float* const* sc,int scChannels,MeterQueue* meters) noexcept { @@ -65,7 +71,12 @@ void Compressor::process(float* const* audio,int channels,int samples,const floa listen[c]=x; rms[c]=flush(rmsCoeff*rms[c]+(1-rmsCoeff)*x*x); // Crossfade detector modes to avoid a discontinuity on automation. - detected[c]=std::abs(x)+(std::sqrt(rms[c])-std::abs(x))*v[Detector]; + const float absLevel=std::abs(x); + const float rmsMix=v[Detector]; + // Maintain RMS state when inactive for click-free detector + // switching, but skip sqrt() for the common Peak-only mode. + detected[c]=rmsMix<=0.0f ? absLevel + : absLevel+(std::sqrt(rms[c])-absLevel)*rmsMix; } const float linked=std::max(detected[0],detected[channels-1]); for(int c=0;cendChangeGesture(); + setLookAndFeel(nullptr); +} void Editor::setValue(std::size_t i,float value) { if(auto* param=processor.state.getParameter(arson::specs[i].id)) { param->beginChangeGesture(); param->setValueNotifyingHost(param->convertTo0to1(value)); param->endChangeGesture(); @@ -107,12 +131,14 @@ void Editor::applyPreset(int id) { } void Editor::resized() { const int w=getWidth(),h=getHeight(); + compact.setBounds(213,26,50,27); style.setBounds(270,25,154,29); presets.setBounds(w-426,25,200,29); compare.setBounds(w-213,25,69,29); bypass.setBounds(w-135,25,113,29); - display={18,66,w-36,h-326}; - const int y=display.getBottom()+14,knobWidth=(w-40)/8; + display=compactMode ? juce::Rectangle{} : juce::Rectangle{18,66,w-36,h-326}; + const int y=compactMode ? 71 : display.getBottom()+14; + const int knobWidth=(w-40)/8; const std::array primary{arson::Threshold,arson::Ratio,arson::Attack, arson::Release,arson::Knee,arson::Range,arson::Makeup,arson::Mix}; for(std::size_t j=0;j(getWidth()-20)); + g.drawHorizontalLine(compactMode ? 296 : display.getBottom()+123, + 20.0f,static_cast(getWidth()-20)); + if(compactMode) { + // Compact mode retains essential performance metering rather than + // becoming a knob-only view. No cached graph is allocated. + const float values[]{inputDb,gr,outputDb}; + const char* names[]{"IN","GR","OUT"}; + const int section=(getWidth()-40)/3; + for(int i=0;i<3;++i) { + const float x=20.0f+static_cast(i*section); + g.setColour(muted);g.setFont(juce::FontOptions(11)); + g.drawText(names[i],static_cast(x),309,34,20,juce::Justification::left); + const float bx=x+43.0f,bw=static_cast(section-105); + g.setColour(line);g.fillRoundedRectangle(bx,314.0f,bw,7.0f,2.0f); + const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36.0f) + : juce::jlimit(0.0f,1.0f,(values[i]+60.0f)/60.0f); + g.setColour(i==1 ? gold : cyan); + if(amount>0.0f)g.fillRoundedRectangle(bx,314.0f,bw*amount,7.0f,2.0f); + g.setColour(text);g.setFont(juce::FontOptions(11)); + g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1), + static_cast(x)+section-55,307,48,23,juce::Justification::centredRight); + } + } g.setColour(muted);g.setFont(juce::FontOptions(10.5f)); g.drawText("0 SAMPLES ADDED | REAL-TIME DSP | VST3",20,getHeight()-25,455,17,juce::Justification::left); g.drawText("Drag controls / double-click reset / type exact values", @@ -201,7 +253,7 @@ void Editor::drawDisplay(juce::Graphics& g) { const auto p=processor.snapshot(); const float top=32.0f,bottom=h-35.0f; g.setFont(juce::FontOptions(11.0f)); - g.setColour(muted);g.drawText("COMPRESSION CURVE",23,10,235,18,juce::Justification::left); + g.setColour(muted);g.drawText("TRANSFER | DRAG GOLD MARKER",23,10,250,18,juce::Justification::left); g.drawText("DYNAMICS | 4s",291,10,230,18,juce::Justification::left); const juce::Rectangle curve{26.0f,top,229.0f,bottom-top}; @@ -286,4 +338,45 @@ void Editor::drawDisplay(juce::Graphics& g) { static_cast(left)+125,8,210,18,juce::Justification::left); } } - + +// Dragging the gold transfer marker is a real host-automatable control. +// One host gesture covers the entire mouse interaction. +void Editor::mouseDown(const juce::MouseEvent& event) { + if(compactMode || !display.contains(event.getPosition())) return; + const auto local=event.getPosition()-display.getPosition(); + if(local.x<26 || local.x>255 || local.y<32 || local.y>display.getHeight()-35) return; + const float markerX=26.0f+ + juce::jlimit(0.0f,1.0f,(processor.snapshot()[arson::Threshold]+60.0f)/60.0f)*229.0f; + if(std::abs(static_cast(local.x)-markerX)>14.0f) return; + if(auto* p=processor.state.getParameter("threshold")) { + p->beginChangeGesture(); + thresholdDragging=true; + mouseDrag(event); + } +} +void Editor::mouseDrag(const juce::MouseEvent& event) { + if(!thresholdDragging) return; + const float x=static_cast(event.getPosition().x-display.getX()); + const float threshold=-60.0f+60.0f*juce::jlimit(0.0f,1.0f,(x-26.0f)/229.0f); + if(auto* p=processor.state.getParameter("threshold")) + p->setValueNotifyingHost(p->convertTo0to1(threshold)); + repaint(display); +} +void Editor::mouseUp(const juce::MouseEvent&) { + if(!thresholdDragging) return; + thresholdDragging=false; + if(auto* p=processor.state.getParameter("threshold")) p->endChangeGesture(); + setMouseCursor(juce::MouseCursor::NormalCursor); +} +void Editor::mouseMove(const juce::MouseEvent& event) { + if(compactMode || !display.contains(event.getPosition())) { + setMouseCursor(juce::MouseCursor::NormalCursor);return; + } + const auto local=event.getPosition()-display.getPosition(); + const float markerX=26.0f+ + juce::jlimit(0.0f,1.0f,(processor.snapshot()[arson::Threshold]+60.0f)/60.0f)*229.0f; + const bool near=local.y>=32 && local.y<=display.getHeight()-35 && + std::abs(static_cast(local.x)-markerX)<=14.0f; + setMouseCursor(near ? juce::MouseCursor::PointingHandCursor + : juce::MouseCursor::NormalCursor); +} diff --git a/plugin/Editor.h b/plugin/Editor.h index fbf495a..ffc0b9e 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -13,6 +13,10 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { ~Editor() override; 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 mouseMove(const juce::MouseEvent&) override; private: void timerCallback() override; void applyPreset(int); @@ -27,12 +31,14 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { using ButtonAttachment=juce::AudioProcessorValueTreeState::ButtonAttachment; std::array,arson::Detector> attachments; juce::ComboBox presets,detector,style; - juce::TextButton compare{"A / B"}; + juce::TextButton compare{"A / B"},compact{"MINI"}; juce::ToggleButton autoRelease{"Auto release"},external{"External SC"},listen{"Listen SC"},bypass{"Bypass"}; std::array,4> buttons; std::unique_ptr detectorAttachment,styleAttachment; arson::Parameters alternate, presetSnapshot; bool alternateActive=false; + bool compactMode=false,thresholdDragging=false; + int expandedWidth=1040,expandedHeight=680; std::array history{}; std::size_t head=0; float inputDb=-120,outputDb=-120,gr=0; diff --git a/tests/Benchmark.cpp b/tests/Benchmark.cpp index dc7380e..d54e34d 100644 --- a/tests/Benchmark.cpp +++ b/tests/Benchmark.cpp @@ -1,13 +1,47 @@ #include "Compressor.h" #include +#include #include + +// Compare the three causal styles under the same 48-kHz host workload. +// Each 64-frame block receives an unchanged parameter snapshot, matching +// how JUCE/APVTS is used during ordinary playback. int main() { - constexpr int block=128,iterations=100000;float left[block],right[block],source[block]; - for(int i=0;i(std::chrono::steady_clock::now()-start).count(); - std::cout<<"Stereo RMS, auto-release, HP sidechain, 48 kHz / 128 samples\n"<(model); + p.value[arson::Detector]=1; + p.value[arson::AutoRelease]=1; + p.value[arson::Highpass]=100; + arson::Compressor c;c.prepare(48000,p); + arson::MeterQueue q; + // Warm up once before timing. + for(int j=0;j<128;++j) { + for(int i=0;i( + std::chrono::steady_clock::now()-start).count(); + const double frames=static_cast(iterations)*block; + checksum+=left[block-1]; + std::cout<<(model==0?"Clean":model==1?"Feedback":"Smooth") + <<" | 48 kHz, stereo, 64 frames/block, RMS/Auto/HP," + <<" host parameter snapshot each block: " + < continuous(4096,0.6f),fragmented(4096,0.6f); + float* cp[]{continuous.data()};a.process(cp,1,4096); + for(int offset=0;offset<4096;offset+=32) { + b.setParameters(p); + float* fp[]{fragmented.data()+offset};b.process(fp,1,32); + } + require(continuous==fragmented,"redundant host snapshots preserve sample ramps"); + + // Continuous automation with all three models, detector modes, + // sidechain filters, bypass and dry/wet must not allocate. + Compressor c;c.prepare(48000); + float left[64]{},right[64]{};float* audio[]{left,right}; + const auto before=allocations.load(); + for(int block=0;block<4000;++block) { + Parameters q; + q.value[Style]=static_cast(block%3); + q.value[Threshold]=-40.0f+static_cast(block%30); + q.value[Highpass]=20.0f+static_cast(block%400); + q.value[Lowpass]=1000.0f+static_cast(block%12000); + q.value[Detector]=static_cast(block%2); + q.value[Mix]=static_cast(block%101); + q.value[Bypass]=static_cast(block%2); + c.setParameters(q); + for(int i=0;i<64;++i) {left[i]=0.4f;right[i]=-0.3f;} + c.process(audio,2,64); + for(int i=0;i<64;++i)require(std::isfinite(left[i])&&std::isfinite(right[i]),"automated output finite"); + } + require(allocations.load()==before,"multi-model automation never allocates"); + } { Compressor c;Parameters p;for(auto& v:p.value)v=std::numeric_limits::quiet_NaN();c.prepare(0,p); float a[]{std::numeric_limits::infinity(),std::numeric_limits::quiet_NaN(),1e-38f,1};float* ptr[]{a};c.process(ptr,1,4); diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 3580db2..5dc53cc 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -19,7 +19,9 @@ int main(int argc,char** argv) { for(int j=0;j<1000;++j) {buffer.clear();buffer.setSample(0,0,0.5f);processor.processBlock(buffer,midi);} for(int iteration=0;iteration<8;++iteration) { std::unique_ptr editor(processor.createEditor()); - editor->setSize(iteration%2 ? 860 : 960,iteration%2 ? 570 : 600); + editor->setSize(iteration%2 ? 920 : 1040,iteration%2 ? 620 : 680); + if(editor->getWidth()!=(iteration%2 ? 920 : 1040) || + editor->getHeight()!=(iteration%2 ? 620 : 680))return 9; editor->addToDesktop(0); editor->setVisible(true); for(int j=0;j<1500;++j) { for(int i=0;i<128;++i) { @@ -33,6 +35,23 @@ int main(int argc,char** argv) { juce::Timer::callAfterDelay(120,[]{juce::MessageManager::getInstance()->stopDispatchLoop();}); juce::MessageManager::getInstance()->runDispatchLoop(); } + // Verify the real MINI/FULL UI transformation on the message thread. + if(iteration==2) { + auto* mini=dynamic_cast(editor->findChildWithID("view.compact")); + if(!mini || !mini->onClick)return 10; + mini->onClick(); + if(editor->getHeight()!=380)return 11; + auto compactImage=editor->createComponentSnapshot(editor->getLocalBounds()); + if(compactImage.isNull() || compactImage.getHeight()!=380)return 12; + if(argc>1) { + juce::File file(juce::String::fromUTF8(argv[1])); + file=file.getSiblingFile(file.getFileNameWithoutExtension()+"-compact.png"); + auto stream=file.createOutputStream(); + if(!stream || !juce::PNGImageFormat{}.writeImageToStream(compactImage,*stream))return 13; + } + mini->onClick(); + if(editor->getHeight()!=680)return 14; + } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3; if(iteration<2 && argc>1) {juce::File file(juce::String::fromUTF8(argv[1])); From f847fa6aba3b74b14cd74c6c26f942307e60cba4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 05:53:02 +0700 Subject: [PATCH 08/35] Milestone: portable user presets, readable compact metering, install-ready Windows CI artifacts --- .github/workflows/build.yml | 28 +++++++++---- README.md | 8 ++-- docs/HANDOFF.md | 2 + docs/WINDOWS-QUICKSTART.md | 30 ++++++++++++++ plugin/Editor.cpp | 80 ++++++++++++++++++++++++++++++------- plugin/Editor.h | 3 +- plugin/PresetIO.h | 25 ++++++++++++ tests/PluginSmoke.cpp | 13 ++++++ 8 files changed, 163 insertions(+), 26 deletions(-) create mode 100644 docs/WINDOWS-QUICKSTART.md create mode 100644 plugin/PresetIO.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b97361d..7409471 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: Validate and build on: pull_request: - paths: ['engine/**', 'plugin/**', 'tests/**', 'CMakeLists.txt', '.github/workflows/**'] + paths: ['engine/**', 'plugin/**', 'tests/**', 'CMakeLists.txt', 'docs/WINDOWS-QUICKSTART.md', '.github/workflows/**'] workflow_dispatch: permissions: contents: read @@ -32,12 +32,26 @@ jobs: run: | New-Item -ItemType Directory -Force artifacts & ./build/Release/engine_bench.exe | Tee-Object artifacts/benchmark.txt + - name: Package install-ready Windows test artifact + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $dest = 'artifacts/ArSonComp-Windows-Test' + New-Item -ItemType Directory -Force "$dest/Plugin", "$dest/Standalone", "$dest/Screenshots" | Out-Null + Copy-Item -Recurse 'build/ArSonComp_artefacts/Release/VST3/ArSonComp.vst3' "$dest/Plugin/" + Copy-Item 'build/ArSonComp_artefacts/Release/Standalone/ArSonComp.exe' "$dest/Standalone/" + Copy-Item 'docs/WINDOWS-QUICKSTART.md' "$dest/START-HERE.md" + Copy-Item 'artifacts/benchmark.txt' "$dest/benchmark.txt" + Copy-Item 'build/ArSonComp-preview*.png' "$dest/Screenshots/" + $files = Get-ChildItem "$dest/Plugin", "$dest/Standalone" -File -Recurse + $files | ForEach-Object { "$((Get-FileHash $_.FullName -Algorithm SHA256).Hash) $($_.FullName.Substring((Resolve-Path $dest).Path.Length + 1))" } | + Set-Content "$dest/SHA256SUMS.txt" -Encoding ascii + "Commit: ${{ github.sha }}" | Set-Content "$dest/BUILD-INFO.txt" -Encoding ascii + "CI: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | + Add-Content "$dest/BUILD-INFO.txt" - uses: actions/upload-artifact@v4 with: - name: ArSonComp-Windows-x64-TestBuild - path: | - build/ArSonComp_artefacts/Release/VST3/ArSonComp.vst3 - build/ArSonComp_artefacts/Release/Standalone/ArSonComp.exe - artifacts/* - build/ArSonComp-preview*.png + name: ArSonComp-Windows-x64-ReadyToTest + path: artifacts/ArSonComp-Windows-Test/ + if-no-files-found: error retention-days: 14 diff --git a/README.md b/README.md index a4d8901..c5724ec 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,14 @@ A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standa - Three causal models: Clean feed-forward, Feedback topology, and Smooth dual-envelope response. Peak and 10 ms RMS detection, threshold, ratio, continuously joined soft knee, range, attack, hold and release. - Optional envelope-dependent auto release; stereo link from independent channels to maximum-linked detection. - Internal/external mono/stereo sidechain, high-pass/low-pass detector filters and listen. -- Input/makeup gain, dry/wet parallel compression, smoothed bypass, six factory starting points and A/B comparison. +- Input/makeup gain, dry/wet parallel compression, smoothed bypass, six factory starting points, A/B comparison, and portable Save/Open .arsoncomp preset files (message-thread-only I/O). - Stable automation IDs and versioned state recall. New model `style` appended without renaming previous parameters. Mono and stereo layouts. - Separate engine without JUCE, locks, heap allocation, I/O, worker dependencies or delay lines in processing. - Bounded SPSC telemetry at 100 Hz; editor coalesces updates at 30 Hz, caches static grid, and repaints only the display during metering. - UI supports a warm graphite/brass/teal vintage theme, direct threshold-marker dragging, and a 380 px compact view without extra DSP work. - Host parameters are diffed once per block; unchanged input/makeup/filter parameters do not trigger redundant coefficient or exponent recalculation. Peak detection skips RMS square root while its RMS state remains warm. -Zero latency means **0 additional samples from this plugin**, not zero audio-interface/host buffering. Fast attacks can distort low-frequency material; no lookahead means transients can pass. It is a compressor, not a brickwall limiter. The current model is feed-forward, without oversampling, saturation or linear-phase filtering. +Zero latency means **0 additional samples from this plugin**, not zero audio-interface/host buffering. Fast attacks can distort low-frequency material; no lookahead means transients can pass. It is a compressor, not a brickwall limiter. The three selectable causal models are Clean feed-forward, Feedback, and Smooth dual-envelope; none uses oversampling, saturation or linear-phase filtering. ## Build @@ -51,10 +51,10 @@ Use `-DARSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug` on GCC/Clang for ASan/UBSan. 4. Enable External SC only after routing a detector signal in your host. An unconnected external bus receives silence. 5. Use Listen SC to audition the detector, then turn it off. Match output loudness with Makeup before comparing A/B. -Double-click knobs to reset; click values to type. The gold marker in the transfer display can also be dragged to automate Threshold with a single host gesture. MINI switches to a compact, hardware-inspired layout (FULL restores the previous size); this is a GUI-only choice that does not alter audio or latency. Presets do not overwrite external sidechain, listen or bypass. A/B swaps all parameters; it is an editor-session comparison, not a second saved host program. +Double-click knobs to reset; click values to type. Use SAVE and OPEN in the header to export/import current .arsoncomp user presets; those actions perform disk I/O only on the GUI thread. The gold marker in the transfer display can also be dragged to automate Threshold with a single host gesture. MINI switches to a compact, hardware-inspired layout (FULL restores the previous size); this is a GUI-only choice that does not alter audio or latency. Presets do not overwrite external sidechain, listen or bypass. A/B swaps all parameters; it is an editor-session comparison, not a second saved host program. ## Verification and scope -See [architecture](docs/ARD.md), [requirements](docs/PRD.md), [validation](docs/VALIDATION.md) and [handoff](docs/HANDOFF.md). CI runs on relevant PR changes or manual dispatch, cancels superseded builds, caches JUCE source and uploads one Windows VST3/standalone test artifact. Documentation-only changes do not trigger builds. +See [architecture](docs/ARD.md), [requirements](docs/PRD.md), [validation](docs/VALIDATION.md) and [handoff](docs/HANDOFF.md). CI runs on relevant PR changes or manual dispatch, cancels superseded builds, caches JUCE source and uploads one installation-ready Windows VST3/standalone test artifact (with screenshots, benchmark, SHA256 checksums and START-HERE instructions). Documentation-only changes do not trigger builds. Repository license remains AGPL-3.0. JUCE has its own AGPL/commercial terms; see its pinned source license. FabFilter names identify workflow references only; no FabFilter code, assets or algorithm claims are included. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 577b01f..4a0c94f 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -8,4 +8,6 @@ Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canon 4. Profile with GUI open/closed and many instances at 32/64/128 samples. Optimize only measured hotspots. 5. Work toward Pro-C workflow/quality with documented independent models; never add fake style labels mapped to indistinguishable algorithms. +The next batch addresses fast real-world testing: a single Windows artifact rooted at Plugin/, Standalone/, Screenshots/, plus SHA256 checksums and a quickstart; SAVE/OPEN provides versioned portable preset XML outside the audio callback, with automated roundtrip testing. MINI meter labels are separated from bars for readability. Verify the new UI Windows artifact before promoting the build. + Keep builds grouped: one relevant-PR workflow with Linux safety and one Windows artifact. No gratuitous matrix or repeated manual runs. diff --git a/docs/WINDOWS-QUICKSTART.md b/docs/WINDOWS-QUICKSTART.md new file mode 100644 index 0000000..bec2a2d --- /dev/null +++ b/docs/WINDOWS-QUICKSTART.md @@ -0,0 +1,30 @@ +# ArSonComp Windows x64 — start here + +**Test build / PR #1 — not a production release.** This artifact is generated from the exact commit recorded in `BUILD-INFO.txt` and is validated by Linux engine tests + Windows build, state/editor smoke and benchmark CI. It has **zero added DSP sample latency**; host buffer, audio interface and driver latency still exist. + +## A. Fastest test: standalone + +Run `Standalone/ArSonComp.exe`. Select the input/output device in the standalone Audio Settings. For monitoring your microphone, enable your input channels and use a low, stable buffer size appropriate to your device. This build does **not** claim ASIO support; host audio-device options vary. + +## B. VST3 test in ArSonMiX or another DAW + +1. Copy the **entire** folder `Plugin/ArSonComp.vst3` to `C:\Program Files\Common Files\VST3\` (administrator permission may be needed). +2. Restart or rescan VST3 in a compatible host. +3. Insert ArSonComp on a track or bus. Start with ratio 2:1–4:1 and lower Threshold until you see approximately 3–6 dB gain reduction. +4. Compare Clean, Feedback and Smooth at matched output loudness. Try MINI/FULL, drag the gold threshold marker, and use SAVE/OPEN for your own `.arsoncomp` preset. +5. Verify external sidechain routing only if your host exposes and connects the sidechain bus. Switch Listen SC off before normal use. + +## C. Quick test checklist + +- Vocal: listen for pumping, sibilance, level consistency and dry/wet behavior. +- Bass: use low frequencies and aggressive attack to check distortion and filter interactions. +- Transients: check drums with attack/hold/release; zero lookahead is not a true-peak limiter. +- UI: switch MINI/FULL; resize to 920x620 and 1040x680; verify labels and metering. +- Project: save, close, reload; confirm host parameters, style, bypass and input/output routing. +- For performance, use multiple instances in your host and compare CPU with plugin editors hidden/visible. + +## Included evidence + +`Screenshots/` has Windows editor smoke captures. `benchmark.txt` is a machine-dependent 48-kHz/64-frame microbenchmark and **not** a DAW dropout guarantee. `SHA256SUMS.txt` contains hashes of the executable plugin payloads. + +FabFilter Pro-C is an independent benchmark for workflow/quality only. No FabFilter code, UI asset or proprietary algorithm is included. diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index cb1e55d..d76af0c 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -1,4 +1,5 @@ #include "Editor.h" +#include "PresetIO.h" namespace { // Restrained original vintage palette: graphite, brushed brass, teal meters. const juce::Colour bg{0xff151715},panel{0xff1b211f},line{0xff3b4841},text{0xffeeeae0},muted{0xffadb6a7},cyan{0xff72cdb5},gold{0xffe4b969}; @@ -7,11 +8,11 @@ CompLook::CompLook() { setColour(juce::Slider::textBoxTextColourId,text); setColour(juce::Slider::textBoxBackgroundColourId,juce::Colours::transparentBlack); setColour(juce::Slider::textBoxOutlineColourId,juce::Colours::transparentBlack); - setColour(juce::ComboBox::backgroundColourId,juce::Colour{0xff252b33}); + setColour(juce::ComboBox::backgroundColourId,juce::Colour{0xff29312c}); setColour(juce::ComboBox::textColourId,text); setColour(juce::ComboBox::outlineColourId,line); setColour(juce::PopupMenu::backgroundColourId,bg); setColour(juce::PopupMenu::textColourId,text); setColour(juce::PopupMenu::highlightedBackgroundColourId,juce::Colour{0xff34505c}); - setColour(juce::TextButton::buttonColourId,juce::Colour{0xff252b33}); + setColour(juce::TextButton::buttonColourId,juce::Colour{0xff29312c}); setColour(juce::TextButton::textColourOffId,text); setColour(juce::ToggleButton::textColourId,text); setColour(juce::ToggleButton::tickColourId,cyan); setColour(juce::Label::textColourId,muted); @@ -85,6 +86,54 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn compare.setTooltip("Swap the current settings with the alternate A/B snapshot."); compare.onClick=[this] { const auto current=processor.snapshot(); for(std::size_t i=0;i( + "Save ArSonComp preset",suggested,"*.arsoncomp"); + juce::Component::SafePointer safe(this); + presetChooser->launchAsync(juce::FileBrowserComponent::saveMode | + juce::FileBrowserComponent::canSelectFiles | + juce::FileBrowserComponent::warnAboutOverwriting,[safe](const juce::FileChooser& chooser) { + if(auto* editor=safe.getComponent()) { + auto file=chooser.getResult(); + if(file==juce::File{}) return; + if(!file.hasFileExtension(".arsoncomp")) file=file.withFileExtension(".arsoncomp"); + if(!arson::preset::save(editor->processor,file)) + juce::AlertWindow::showMessageBoxAsync(juce::MessageBoxIconType::WarningIcon, + "Preset save failed","Could not write the selected preset file."); + } + }); + }; + loadPreset.onClick=[this] { + presetChooser=std::make_unique( + "Open ArSonComp preset",juce::File::getSpecialLocation(juce::File::userDocumentsDirectory), + "*.arsoncomp"); + juce::Component::SafePointer safe(this); + presetChooser->launchAsync(juce::FileBrowserComponent::openMode | + juce::FileBrowserComponent::canSelectFiles,[safe](const juce::FileChooser& chooser) { + if(auto* editor=safe.getComponent()) { + const auto file=chooser.getResult(); + if(file==juce::File{}) return; + if(!arson::preset::load(editor->processor,file)) { + juce::AlertWindow::showMessageBoxAsync(juce::MessageBoxIconType::WarningIcon, + "Preset open failed","Unsupported or damaged .arsoncomp preset."); + return; + } + editor->presetSnapshot=editor->processor.snapshot(); + editor->presets.setSelectedId(0,juce::dontSendNotification); + editor->presets.setText("USER / "+file.getFileNameWithoutExtension(), + juce::dontSendNotification); + editor->repaint(editor->display); + } + }); + }; + addAndMakeVisible(savePreset); + addAndMakeVisible(loadPreset); compact.setComponentID("view.compact"); compact.setTooltip("Toggle compact hardware-style view without losing settings."); compact.onClick=[this] { @@ -107,6 +156,7 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn } Editor::~Editor() { stopTimer(); + presetChooser.reset(); // Close an active host-automation gesture if the editor is destroyed // while a graph drag is in progress. if(thresholdDragging) @@ -133,9 +183,11 @@ void Editor::resized() { const int w=getWidth(),h=getHeight(); compact.setBounds(213,26,50,27); style.setBounds(270,25,154,29); - presets.setBounds(w-426,25,200,29); - compare.setBounds(w-213,25,69,29); - bypass.setBounds(w-135,25,113,29); + presets.setBounds(w-464,25,164,29); + savePreset.setBounds(w-294,25,46,29); + loadPreset.setBounds(w-242,25,46,29); + compare.setBounds(w-190,25,64,29); + bypass.setBounds(w-121,25,101,29); display=compactMode ? juce::Rectangle{} : juce::Rectangle{18,66,w-36,h-326}; const int y=compactMode ? 71 : display.getBottom()+14; const int knobWidth=(w-40)/8; @@ -195,7 +247,7 @@ void Editor::timerCallback() { in=std::max(in,frame.input);out=std::max(out,frame.output);reduction=std::max(reduction,frame.reduction); } inputDb=std::max(arson::gainToDb(in),inputDb-1.2f); outputDb=std::max(arson::gainToDb(out),outputDb-1.2f); gr=std::max(reduction,gr-0.8f); - if(compactMode) repaint(20,301,getWidth()-40,34); + if(compactMode) repaint(20,301,getWidth()-40,44); else repaint(display); } void Editor::paint(juce::Graphics& g) { @@ -208,7 +260,7 @@ void Editor::paint(juce::Graphics& g) { g.setColour(muted);g.setFont(juce::FontOptions(10)); g.drawText("LIVE DYNAMICS",88,44,145,14,juce::Justification::centredLeft); g.drawText("MODEL",271,8,146,15,juce::Justification::left); - g.drawText("FACTORY PRESET",getWidth()-425,8,194,15,juce::Justification::left); + g.drawText("PRESETS",getWidth()-463,8,164,15,juce::Justification::left); if(!compactMode) { if(grid.isValid())g.drawImageAt(grid,display.getX(),display.getY()); g.setColour(line);g.drawRoundedRectangle(display.toFloat(),6.0f,1.0f); @@ -226,16 +278,16 @@ void Editor::paint(juce::Graphics& g) { for(int i=0;i<3;++i) { const float x=20.0f+static_cast(i*section); g.setColour(muted);g.setFont(juce::FontOptions(11)); - g.drawText(names[i],static_cast(x),309,34,20,juce::Justification::left); - const float bx=x+43.0f,bw=static_cast(section-105); - g.setColour(line);g.fillRoundedRectangle(bx,314.0f,bw,7.0f,2.0f); + g.drawText(names[i],static_cast(x)+3,305,55,17,juce::Justification::left); + g.setColour(text);g.setFont(juce::FontOptions(11.5f)); + g.drawText(values[i]<-99 ? "-inf dB" : juce::String(values[i],1)+" dB", + static_cast(x)+section-82,305,76,18,juce::Justification::centredRight); + const float bx=x+3.0f,bw=static_cast(section-15); + g.setColour(line);g.fillRoundedRectangle(bx,331.0f,bw,6.0f,2.0f); const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36.0f) : juce::jlimit(0.0f,1.0f,(values[i]+60.0f)/60.0f); g.setColour(i==1 ? gold : cyan); - if(amount>0.0f)g.fillRoundedRectangle(bx,314.0f,bw*amount,7.0f,2.0f); - g.setColour(text);g.setFont(juce::FontOptions(11)); - g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1), - static_cast(x)+section-55,307,48,23,juce::Justification::centredRight); + if(amount>0.0f)g.fillRoundedRectangle(bx,331.0f,bw*amount,6.0f,2.0f); } } g.setColour(muted);g.setFont(juce::FontOptions(10.5f)); diff --git a/plugin/Editor.h b/plugin/Editor.h index ffc0b9e..f86b1b8 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -31,10 +31,11 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { using ButtonAttachment=juce::AudioProcessorValueTreeState::ButtonAttachment; std::array,arson::Detector> attachments; juce::ComboBox presets,detector,style; - juce::TextButton compare{"A / B"},compact{"MINI"}; + juce::TextButton compare{"A / B"},compact{"MINI"},savePreset{"SAVE"},loadPreset{"OPEN"}; juce::ToggleButton autoRelease{"Auto release"},external{"External SC"},listen{"Listen SC"},bypass{"Bypass"}; std::array,4> buttons; std::unique_ptr detectorAttachment,styleAttachment; + std::unique_ptr presetChooser; arson::Parameters alternate, presetSnapshot; bool alternateActive=false; bool compactMode=false,thresholdDragging=false; diff --git a/plugin/PresetIO.h b/plugin/PresetIO.h new file mode 100644 index 0000000..339640c --- /dev/null +++ b/plugin/PresetIO.h @@ -0,0 +1,25 @@ +#pragma once +#include "Processor.h" +#include + +// UI-thread-only file I/O. Never called from processBlock. +// Use the same versioned host-state schema for project and user preset recall. +namespace arson::preset { +inline bool save(Processor& processor, const juce::File& file) { + juce::MemoryBlock bytes; + processor.getStateInformation(bytes); + auto xml=juce::getXmlFromBinary(bytes.getData(),static_cast(bytes.getSize())); + return xml!=nullptr && file.hasFileExtension(".arsoncomp") && xml->writeTo(file); +} +inline bool load(Processor& processor, const juce::File& file) { + if(!file.existsAsFile() || !file.hasFileExtension(".arsoncomp") + || file.getSize()>1024*1024) return false; + auto xml=juce::XmlDocument::parse(file); + if(!xml || !xml->hasTagName("ArSonCompState") + || xml->getIntAttribute("schema",1)!=1) return false; + juce::MemoryBlock bytes; + juce::copyXmlToBinary(*xml,bytes); + processor.setStateInformation(bytes.getData(),static_cast(bytes.getSize())); + return true; +} +} diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 5dc53cc..2194bec 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -1,4 +1,5 @@ #include "../plugin/Processor.h" +#include "../plugin/PresetIO.h" #include #include int main(int argc,char** argv) { @@ -15,10 +16,22 @@ int main(int argc,char** argv) { juce::MemoryBlock state;processor.getStateInformation(state);parameter->setValueNotifyingHost(parameter->convertTo0to1(-5));processor.setStateInformation(state.getData(),static_cast(state.getSize())); if(std::abs(processor.snapshot()[arson::Threshold]+27)>0.01f)return 2; if(std::abs(processor.snapshot()[arson::Style]-2.0f)>0.01f)return 8; + // Real portable preset export/import roundtrip, including new model ID. + const auto file=juce::File::getSpecialLocation(juce::File::tempDirectory) + .getNonexistentChildFile("ArSonComp-Smoke",".arsoncomp",false); + if(!arson::preset::save(processor,file))return 15; + parameter->setValueNotifyingHost(parameter->convertTo0to1(-7)); + model->setValueNotifyingHost(model->convertTo0to1(0)); + if(!arson::preset::load(processor,file))return 16; + if(std::abs(processor.snapshot()[arson::Threshold]+27)>0.01f || + std::abs(processor.snapshot()[arson::Style]-2.0f)>0.01f)return 17; + file.deleteFile(); juce::AudioBuffer buffer(2,128);juce::MidiBuffer midi; for(int j=0;j<1000;++j) {buffer.clear();buffer.setSample(0,0,0.5f);processor.processBlock(buffer,midi);} for(int iteration=0;iteration<8;++iteration) { std::unique_ptr editor(processor.createEditor()); + if(!editor->findChildWithID("preset.save") || !editor->findChildWithID("preset.load")) + return 18; editor->setSize(iteration%2 ? 920 : 1040,iteration%2 ? 620 : 680); if(editor->getWidth()!=(iteration%2 ? 920 : 1040) || editor->getHeight()!=(iteration%2 ? 620 : 680))return 9; From f63e8c6816b169fd9d61975e25f55520eab6066d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 06:17:29 +0700 Subject: [PATCH 09/35] Milestone: reference-layout compressor GUI, integrated reduction graph and true stereo LED meters; fix preset build --- README.md | 8 +- docs/ARD.md | 4 +- docs/HANDOFF.md | 4 + docs/VALIDATION.md | 4 + docs/WINDOWS-QUICKSTART.md | 4 + engine/Compressor.cpp | 10 +- engine/MeterQueue.h | 8 +- plugin/Editor.cpp | 842 ++++++++++++++++++++++++------------- plugin/Editor.h | 13 + plugin/PresetIO.h | 4 +- tests/EngineTests.cpp | 18 + tests/PluginSmoke.cpp | 16 +- 12 files changed, 625 insertions(+), 310 deletions(-) diff --git a/README.md b/README.md index c5724ec..4b2beac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standalone, zero added algorithmic latency. The interface prioritizes transfer curve, input/output history and gain reduction, with familiar compressor controls and an original ArSon visual identity. -**Status: engineering test build with three original compression models and a redesigned graphical interface, not claimed to match FabFilter's proprietary algorithms or sound.** +**Status: engineering test build; the integrated full-graph reference layout is under Windows CI verification. No claim of exact sonic/feature parity with FabFilter.** ## Implemented @@ -13,7 +13,7 @@ A compact live compressor: framework-independent C++17 DSP, JUCE VST3 and standa - Stable automation IDs and versioned state recall. New model `style` appended without renaming previous parameters. Mono and stereo layouts. - Separate engine without JUCE, locks, heap allocation, I/O, worker dependencies or delay lines in processing. - Bounded SPSC telemetry at 100 Hz; editor coalesces updates at 30 Hz, caches static grid, and repaints only the display during metering. -- UI supports a warm graphite/brass/teal vintage theme, direct threshold-marker dragging, and a 380 px compact view without extra DSP work. +- Full-width integrated compressor graph: responsive input/output/GR history, red transfer curve and dissolving gradient, actual independent stereo LED IN/OUT on the sides, and a distinct GR meter. Dominant Threshold control, red hardware knobs, bottom control strip, and 380px MINI layout. The real threshold marker is draggable via host automation. - Host parameters are diffed once per block; unchanged input/makeup/filter parameters do not trigger redundant coefficient or exponent recalculation. Peak detection skips RMS square root while its RMS state remains warm. Zero latency means **0 additional samples from this plugin**, not zero audio-interface/host buffering. Fast attacks can distort low-frequency material; no lookahead means transients can pass. It is a compressor, not a brickwall limiter. The three selectable causal models are Clean feed-forward, Feedback, and Smooth dual-envelope; none uses oversampling, saturation or linear-phase filtering. @@ -58,3 +58,7 @@ Double-click knobs to reset; click values to type. Use SAVE and OPEN in the head See [architecture](docs/ARD.md), [requirements](docs/PRD.md), [validation](docs/VALIDATION.md) and [handoff](docs/HANDOFF.md). CI runs on relevant PR changes or manual dispatch, cancels superseded builds, caches JUCE source and uploads one installation-ready Windows VST3/standalone test artifact (with screenshots, benchmark, SHA256 checksums and START-HERE instructions). Documentation-only changes do not trigger builds. Repository license remains AGPL-3.0. JUCE has its own AGPL/commercial terms; see its pinned source license. FabFilter names identify workflow references only; no FabFilter code, assets or algorithm claims are included. + +## GUI visual reference and acceptance + +The newly redesigned UI uses the user-supplied ArSonComp mockup as a layout acceptance target: integrated upper graph, side meters, red glow and premium hardware controls. No bitmap UI assets, lookahead, worker waits or added algorithmic sample delay. The static graph background builds only on resize and the transfer curve is cached until threshold/ratio/knee/range or width changes. Windows test screenshots must show default 1120x760, minimum 960x670 and MINI 380px. A prior Windows CI build of the portable-preset milestone failed to compile due to incorrectly qualified JUCE XML helper methods; the new milestone fixes these to public AudioProcessor static methods. diff --git a/docs/ARD.md b/docs/ARD.md index e95a2db..6534277 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -10,13 +10,13 @@ Signal flow: input trim → detector tap → optional detector HP/LP → Peak/RM The three independent zero-added-latency models are Clean (feed-forward), Feedback (causal detector sensing prior actual pre-makeup attenuation), and Smooth (a second attack/release pole cascaded with the first). All modes process one shared audio path; a 5 ms model ramp blends their behavior without triple-rendering. The stable model parameter ID `style` is appended to the schema. Existing hosts using the original parameter IDs preserve them. These models are original algorithms, not claimed clones of proprietary compression styles. -GUI design: a compact 1040x680 (minimum 920x620) slate/amber/cyan interface, a 229px-wide transfer graph with animated operating point, 4-second bounded dynamics history, three meters, smaller legible control knobs and a model selector. Static grid is cached on resize; timed metering repaints only the display. UI draws are never called from the audio callback. +GUI reference-layout milestone: one large integrated graph in the upper panel combines a real transfer curve (red glowing line and soft fade), measured 4-second input/output and gain-reduction traces, input stereo LED bars on the left, GR and output stereo bars on the right. Main hardware row: Input, Attack, Release, oversized Threshold, Ratio, Knee, Makeup; bottom strip: Range, Hold, Mix, Link, SC HP/LP, Peak/RMS, AutoRelease, External SC and Listen SC. Header: model, preset, save/open, A/B, bypass and MINI. The supplied mockup dictates composition; UI artwork and code are original JUCE vector rendering. The transfer graph uses input dB horizontally while history is time-based, deliberately independent overlaid information layers. All data traces are measured. No fictional Lookahead knob: zero added algorithmic sample latency is mandatory. Display is default 1120x760, minimum 960x670, MINI 380px high. One cached background rebuilds on resize, the transfer path is cached by threshold/ratio/knee/range/graph width, and the metering draws at 30 Hz on the message thread only; audio never touches GUI. The 100 Hz MeterFrame has independent input/output L/R peaks; side bars are not duplicated aggregate maxima. RMS detector uses a 10 ms exponential energy estimate. Attack/release are 63.2% time constants in the dB reduction domain. Auto release blends base and 4× slower release coefficients according to existing reduction. This is an explicit independent design, not a recreation of FabFilter's undisclosed program-dependent models. The first-order detector HP/LP are bypassed at 20 Hz / 20 kHz endpoints. Stereo linking blends each detector toward the maximum channel level. ## Data exchange -A fixed 512-slot SPSC queue transfers 10 ms maxima (input, output, reduction). Acquire/release publication protects non-atomic slots; read/write indices occupy distinct cache lines. Audio drops frames if full. There is exactly one editor consumer. Editor drains at most 512 frames per 30 Hz tick, updates its fixed 400-frame history and coalesces meter repaint. The editor also supports an original compact hardware-inspired layout (380 px tall, no graph allocations) and direct transfer-marker threshold gestures with one `beginChangeGesture`/`endChangeGesture` pair per drag; teardown ends any unfinished gesture. Reopening discards a bounded stale backlog. Static display grid is rebuilt on resize, not on audio or every timer tick. +A fixed 512-slot SPSC queue transfers 10 ms maxima (input, output, reduction, individual input/output L/R peaks). Acquire/release publication protects non-atomic slots; read/write indices occupy distinct cache lines. Audio drops frames if full. There is exactly one editor consumer. Editor drains at most 512 frames per 30 Hz tick, updates its fixed 400-frame history and coalesces meter repaint. The editor also supports an original compact hardware-inspired layout (380 px tall, no graph allocations) and direct transfer-marker threshold gestures with one `beginChangeGesture`/`endChangeGesture` pair per drag; teardown ends any unfinished gesture. Reopening discards a bounded stale backlog. Static display grid is rebuilt on resize, not on audio or every timer tick. APVTS parameter atomics are independent, so bulk preset/state changes can be observed across adjacent audio blocks; five-millisecond ramps limit transition artifacts. They are not claimed to be a transactional sample-accurate preset switch. Host automation is block-rate in this implementation. State XML serialization is outside processBlock. Schema 1 rejects unknown root/schema and restores finite, clamped known values. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 4a0c94f..b547faa 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -11,3 +11,7 @@ Start with README, AGENTS, PRD, ARD and VALIDATION. Source of truth is the canon The next batch addresses fast real-world testing: a single Windows artifact rooted at Plugin/, Standalone/, Screenshots/, plus SHA256 checksums and a quickstart; SAVE/OPEN provides versioned portable preset XML outside the audio callback, with automated roundtrip testing. MINI meter labels are separated from bars for readability. Verify the new UI Windows artifact before promoting the build. Keep builds grouped: one relevant-PR workflow with Linux safety and one Windows artifact. No gratuitous matrix or repeated manual runs. + +## Current priority: reference visual fidelity + previous build regression + +The supplied red ArSonComp mockup is now the acceptance layout for a full-width integrated transfer/compression graph, side LED meters with true stereo peaks, animated actual GR, red dissolving fill, dominant Threshold knob, and two-row compact controls. Preserve no-lookahead live mode. IMPORTANT: CI for f847fa6 failed because PresetIO.h incorrectly called juce namespace functions getXmlFromBinary/copyXmlToBinary. Correct public API is juce::AudioProcessor::getXmlFromBinary/copyXmlToBinary. Validate Windows compile and the three screenshot variants before claiming milestone completed. Keep one grouped commit/CI and retain Draft until real verification. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index fe1c6c9..1717989 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -17,3 +17,7 @@ Pending until evidence is recorded: editor lifecycle/state test and visual inspe Source changes: avoid control-rate exponent evaluations for unchanged APVTS values; skip RMS square root on Peak-only samples without freezing the RMS state; preserve automation smoothing and arbitrary-block equivalence. Additional tests cover repeated no-op snapshots, rapid style/detector/filter/bypass/mix automation with no allocation, valid output, three-style 64-sample host-snapshot benchmarks and exact-sized 1040x680 / 920x620 editor snapshots plus 380px compact capture. The threshold line uses one begin/end host gesture per drag, including early editor teardown. No new DSP latency, worker or audio-thread lock. Current results must be recorded from the CI run for the commit which introduces this section, not inherited from prior runs. GUI captures are functional smoke evidence only until visually reviewed. Pluginval, long-running host stress, listening and Pro-C 3 comparison still pending. References: https://www.fabfilter.com/help/pro-c/using/overview ; https://www.fabfilter.com/help/pro-c/using/displays ; https://www.fabfilter.com/help/pro-c/using/oversampling . + +## Integrated-graph reference milestone (pending CI) + +Verify default 1120x760, minimum 960x670 and compact 380px Windows screenshot geometry; confirm accurate dark/red gradients, animated reduction/input/output history on a single canvas, red curved transfer law, dominant Threshold knob, stereo IN L/R and OUT L/R LED meters and GR meter. Engine checks 0.2/0.65 independent stereo input/output peaks and preserved aggregate maximum. Preset smoke must pass after correcting public static AudioProcessor XML helpers. No false lookahead knob, no added DSP samples. Host validation and DPI scaling remain release gates; screenshot smoke alone does not prove sonic parity. diff --git a/docs/WINDOWS-QUICKSTART.md b/docs/WINDOWS-QUICKSTART.md index bec2a2d..579a2c4 100644 --- a/docs/WINDOWS-QUICKSTART.md +++ b/docs/WINDOWS-QUICKSTART.md @@ -28,3 +28,7 @@ Run `Standalone/ArSonComp.exe`. Select the input/output device in the standalone `Screenshots/` has Windows editor smoke captures. `benchmark.txt` is a machine-dependent 48-kHz/64-frame microbenchmark and **not** a DAW dropout guarantee. `SHA256SUMS.txt` contains hashes of the executable plugin payloads. FabFilter Pro-C is an independent benchmark for workflow/quality only. No FabFilter code, UI asset or proprietary algorithm is included. + +### New full-graph GUI acceptance + +Check upper central transfer graph, red fading curve and live gain reduction line, left input stereo LED meters, right GR and output stereo LEDs, and enlarged Threshold knob. Check the default/minimum/MINI screenshots from this commit, not a previous ZIP. No lookahead is present in the zero-added-sample live signal path. diff --git a/engine/Compressor.cpp b/engine/Compressor.cpp index 2bb0c5f..6b3670c 100644 --- a/engine/Compressor.cpp +++ b/engine/Compressor.cpp @@ -104,8 +104,14 @@ void Compressor::process(float* const* audio,int channels,int samples,const floa out+=(listen[c]-out)*v[Listen]; out=v[Bypass]>=1.0f ? original[c] : out+(original[c]-out)*v[Bypass]; audio[c][n]=out; - meter.input=std::max(meter.input,std::abs(dry[c])); - meter.output=std::max(meter.output,std::abs(out)); + const float inPeak=std::abs(dry[c]),outPeak=std::abs(out); + meter.channels=channels; + meter.inputChannel[static_cast(c)]= + std::max(meter.inputChannel[static_cast(c)],inPeak); + meter.outputChannel[static_cast(c)]= + std::max(meter.outputChannel[static_cast(c)],outPeak); + meter.input=std::max(meter.input,inPeak); + meter.output=std::max(meter.output,outPeak); meter.reduction=std::max(meter.reduction,effectiveEnv*(1-v[Bypass])); } if(++meterCount>=meterPeriod) { diff --git a/engine/MeterQueue.h b/engine/MeterQueue.h index ee2f0ba..9a44a5d 100644 --- a/engine/MeterQueue.h +++ b/engine/MeterQueue.h @@ -3,7 +3,13 @@ #include #include namespace arson { -struct MeterFrame { float input=0, output=0, reduction=0; }; +struct MeterFrame { + // One producer, one consumer. Stereo peaks are actual per-channel + // values, not two duplicated bars derived from a mono maximum. + float input=0, output=0, reduction=0; + std::array inputChannel{}, outputChannel{}; + int channels=1; +}; // One audio producer, one editor consumer. Full queue drops visualization only. class MeterQueue { public: diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index d76af0c..2f3f08d 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -1,434 +1,682 @@ #include "Editor.h" #include "PresetIO.h" +#include +#include + namespace { -// Restrained original vintage palette: graphite, brushed brass, teal meters. -const juce::Colour bg{0xff151715},panel{0xff1b211f},line{0xff3b4841},text{0xffeeeae0},muted{0xffadb6a7},cyan{0xff72cdb5},gold{0xffe4b969}; +const juce::Colour bg{0xff0c0f11}, top{0xff171b20}, panel{0xff101317}, + line{0xff30353a}, text{0xffe5e8eb}, muted{0xffa2a8ae}, + accent{0xfffa4a58}, accentBright{0xffff6870}, green{0xff70e593}, + yellow{0xffffd661}; + +float clamp01(float x) noexcept { return juce::jlimit(0.0f,1.0f,x); } +float dbFraction(float x) noexcept { return clamp01((x+60.0f)/60.0f); } +float graphY(const juce::Rectangle& p,float db) noexcept { + return p.getBottom()-dbFraction(db)*p.getHeight(); +} +juce::String levelText(float v) { + return v<=-100.0f ? juce::String("-inf") : juce::String(v,1); } +} + +// All painting belongs to JUCE's message thread. No GUI object or +// gradient/path/cache construction is reachable from processBlock. CompLook::CompLook() { setColour(juce::Slider::textBoxTextColourId,text); - setColour(juce::Slider::textBoxBackgroundColourId,juce::Colours::transparentBlack); - setColour(juce::Slider::textBoxOutlineColourId,juce::Colours::transparentBlack); - setColour(juce::ComboBox::backgroundColourId,juce::Colour{0xff29312c}); - setColour(juce::ComboBox::textColourId,text); setColour(juce::ComboBox::outlineColourId,line); - setColour(juce::PopupMenu::backgroundColourId,bg); setColour(juce::PopupMenu::textColourId,text); - setColour(juce::PopupMenu::highlightedBackgroundColourId,juce::Colour{0xff34505c}); - setColour(juce::TextButton::buttonColourId,juce::Colour{0xff29312c}); + setColour(juce::Slider::textBoxBackgroundColourId,juce::Colour{0xff111417}); + setColour(juce::Slider::textBoxOutlineColourId,juce::Colour{0xff31383e}); + setColour(juce::ComboBox::backgroundColourId,juce::Colour{0xff181d22}); + setColour(juce::ComboBox::textColourId,text); + setColour(juce::ComboBox::outlineColourId,juce::Colour{0xff374047}); + setColour(juce::PopupMenu::backgroundColourId,juce::Colour{0xff161b20}); + setColour(juce::PopupMenu::textColourId,text); + setColour(juce::PopupMenu::highlightedBackgroundColourId,juce::Colour{0xff602b32}); + setColour(juce::TextButton::buttonColourId,juce::Colour{0xff1a1f24}); setColour(juce::TextButton::textColourOffId,text); - setColour(juce::ToggleButton::textColourId,text); setColour(juce::ToggleButton::tickColourId,cyan); + setColour(juce::ToggleButton::textColourId,text); + setColour(juce::ToggleButton::tickColourId,accent); setColour(juce::Label::textColourId,muted); } -juce::Label* CompLook::createSliderTextBox(juce::Slider& slider) { - auto* label=juce::LookAndFeel_V4::createSliderTextBox(slider); - label->setFont(juce::FontOptions(12)); - label->setColour(juce::Label::outlineColourId,juce::Colours::transparentBlack); +juce::Label* CompLook::createSliderTextBox(juce::Slider& s) { + auto* label=juce::LookAndFeel_V4::createSliderTextBox(s); + label->setFont(juce::FontOptions(12.0f)); + label->setColour(juce::Label::outlineColourId,juce::Colour{0xff323a40}); label->setColour(juce::Label::textColourId,text); - label->setColour(juce::TextEditor::backgroundColourId,panel); + label->setColour(juce::Label::backgroundColourId,juce::Colour{0xff101419}); + label->setColour(juce::TextEditor::backgroundColourId,juce::Colour{0xff101419}); label->setColour(juce::TextEditor::textColourId,text); label->setColour(juce::TextEditor::outlineColourId,line); - label->setColour(juce::TextEditor::focusedOutlineColourId,cyan); + label->setColour(juce::TextEditor::focusedOutlineColourId,accent); return label; } -void CompLook::drawRotarySlider(juce::Graphics& g,int x,int y,int w,int h,float pos,float start,float end,juce::Slider&) { - const auto bounds=juce::Rectangle(static_cast(x),static_cast(y), - static_cast(w),static_cast(h)).reduced(9.0f); - const float r=std::min(bounds.getWidth(),bounds.getHeight())*0.5f; - const float cx=bounds.getCentreX(),cy=bounds.getCentreY(); - g.setColour(juce::Colour{0xff202a35}); - g.fillEllipse(cx-r+3,cy-r+3,2*r-6,2*r-6); - g.setGradientFill(juce::ColourGradient(juce::Colour{0xff3a4652},cx-r,cy-r, - juce::Colour{0xff121820},cx+r,cy+r,false)); - g.fillEllipse(cx-r+7,cy-r+7,2*r-14,2*r-14); - juce::Path track,active; - track.addCentredArc(cx,cy,r,r,0,start,end,true); - active.addCentredArc(cx,cy,r,r,0,start,start+pos*(end-start),true); - g.setColour(juce::Colour{0xff485361}); - g.strokePath(track,juce::PathStrokeType(3.2f)); - g.setColour(gold); - g.strokePath(active,juce::PathStrokeType(3.2f)); - const float angle=start+pos*(end-start); - g.setColour(text); - g.drawLine(cx+std::sin(angle)*r*0.35f,cy-std::cos(angle)*r*0.35f, - cx+std::sin(angle)*r*0.73f,cy-std::cos(angle)*r*0.73f,2.1f); - g.setColour(juce::Colour{0xff8c9bac}); - g.fillEllipse(cx-1.6f,cy-1.6f,3.2f,3.2f); +void CompLook::drawRotarySlider(juce::Graphics& g,int x,int y,int w,int h, + float pos,float start,float end,juce::Slider& slider) { + const bool primary=slider.getName()=="Threshold"; + const float radiusScale=primary?0.47f:0.36f; + const float r=std::max(12.0f,std::min(static_cast(w)*radiusScale, + static_cast(h)*(primary?0.47f:0.36f))); + const float cx=static_cast(x)+w*0.5f,cy=static_cast(y)+h*0.51f; + g.setColour(juce::Colours::black.withAlpha(0.62f)); + g.fillEllipse(cx-r-3.0f,cy-r-1.0f,2*r+6.0f,2*r+6.0f); + g.setColour(juce::Colour{0xff3e4147}); + g.fillEllipse(cx-r,cy-r,2*r,2*r); + const float ringInset=primary?6.8f:5.0f; + const float rr=r-ringInset; + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff363a40}, + cx-rr*0.65f,cy-rr*0.9f,juce::Colour{0xff0b0e11}, + cx+rr*0.85f,cy+rr*0.95f,true)); + g.fillEllipse(cx-rr,cy-rr,2*rr,2*rr); + g.setColour(juce::Colour{0xff15191d}.withAlpha(0.8f)); + g.drawEllipse(cx-rr+2.0f,cy-rr+2.0f,2*rr-4.0f,2*rr-4.0f,1.2f); + juce::Path inactive,active; + const float arcR=r+1.6f; + inactive.addCentredArc(cx,cy,arcR,arcR,0.0f,start,end,true); + active.addCentredArc(cx,cy,arcR,arcR,0.0f,start,start+clamp01(pos)*(end-start),true); + g.setColour(juce::Colour{0xff43494f}); + g.strokePath(inactive,juce::PathStrokeType(primary?4.8f:4.0f, + juce::PathStrokeType::curved,juce::PathStrokeType::rounded)); + g.setColour(accent); + g.strokePath(active,juce::PathStrokeType(primary?5.4f:4.3f, + juce::PathStrokeType::curved,juce::PathStrokeType::rounded)); + const float theta=start+clamp01(pos)*(end-start); + g.setColour(juce::Colour{0xfffff5f5}); + g.drawLine(cx+std::sin(theta)*rr*0.27f,cy-std::cos(theta)*rr*0.27f, + cx+std::sin(theta)*rr*0.78f,cy-std::cos(theta)*rr*0.78f, + primary?2.7f:2.1f); + g.setColour(juce::Colour{0xff6d7278}); + g.fillEllipse(cx-1.5f,cy-1.5f,3.0f,3.0f); +} +void CompLook::drawLinearSlider(juce::Graphics& g,int x,int y,int w,int h, + float pos,float,float, + const juce::Slider::SliderStyle,juce::Slider&) { + const float left=static_cast(x)+9, right=static_cast(x+w)-9; + const float cy=static_cast(y)+h*0.51f; + g.setColour(juce::Colour{0xff3d444a}); + g.fillRoundedRectangle(left,cy-3,right-left,6,3); + g.setColour(juce::Colour{0xffe33c49}); + const float end=juce::jlimit(left,right,pos); + if(end>left)g.fillRoundedRectangle(left,cy-3,end-left,6,3); + g.setColour(juce::Colour{0xffff7380}); + g.fillEllipse(end-5.0f,cy-5.0f,10.0f,10.0f); +} + +void CompLook::drawToggleButton(juce::Graphics& g,juce::ToggleButton& button, + bool highlighted,bool down) { + if(button.getButtonText()!="Bypass") { + juce::LookAndFeel_V4::drawToggleButton(g,button,highlighted,down); + return; + } + const bool on=button.getToggleState(); + const auto box=button.getLocalBounds().toFloat().reduced(2.0f); + g.setColour(on?juce::Colour{0xff3d2027}:juce::Colour{0xff1b2026}); + g.fillRoundedRectangle(box,5.0f); + g.setColour(on?accent.withAlpha(0.8f):line); + g.drawRoundedRectangle(box,5.0f,0.9f); + const float cx=box.getX()+19.0f,cy=box.getCentreY(); + juce::Path ring; + ring.addCentredArc(cx,cy,9.5f,9.5f,0.0f,0.63f,5.65f,true); + g.setColour(on?accentBright:muted); + g.strokePath(ring,juce::PathStrokeType(2.2f)); + g.drawLine(cx,cy-13.0f,cx,cy-1.0f,2.2f); + g.setColour(on?accentBright:text); + g.setFont(juce::FontOptions(11.0f)); + g.drawText(on?"BYPASS":"ACTIVE",33,0,box.getWidth()-35, + button.getHeight(),juce::Justification::centredLeft); } Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.snapshot()) { - setLookAndFeel(&look); setOpaque(true); + setLookAndFeel(&look); + setOpaque(true); + const std::array bars{{arson::Range,arson::Hold,arson::Mix, + arson::Link,arson::Highpass,arson::Lowpass}}; for(std::size_t i=0;i(p.state,s.id,k); + addAndMakeVisible(k); + attachments[i]=std::make_unique(p.state,spec.id,k); } style.addItemList({"Clean - feedforward","Feedback - classic","Smooth - dual envelope"},1); - style.setTooltip("Genuinely different DSP models: causal feed-forward, feedback, and dual-envelope."); + style.setTooltip("Three independent zero-added-sample-latency compressor models."); addAndMakeVisible(style); - styleAttachment=std::make_unique(p.state,"style",style); - presets.addItemList({"Default","Vocal | gentle","Vocal | level","Mix bus | glue","Drums | punch","Podcast | steady"},1); - presets.setSelectedId(1,juce::dontSendNotification); presets.onChange=[this]{applyPreset(presets.getSelectedId());}; - presets.setTooltip("Factory starting points. Adjust threshold to your input level."); addAndMakeVisible(presets); - detector.addItemList({"Peak","RMS"},1); addAndMakeVisible(detector); - detectorAttachment=std::make_unique(p.state,"detector",detector); - detector.setTooltip("Peak responds to transients. RMS follows energy over 10 ms without delaying audio."); + styleAttachment=std::make_unique( + p.state,"style",style); + presets.addItemList({"Default","Vocal | gentle","Vocal | level", + "Mix bus | glue","Drums | punch","Podcast | steady"},1); + presets.setTooltip("Choose a factory starting point; threshold depends on input level."); + presets.onChange=[this] {applyPreset(presets.getSelectedId());}; + addAndMakeVisible(presets); + detector.addItemList({"Peak","RMS"},1); + detector.setTooltip("Peak: transients; RMS: smoothed 10 ms energy, with zero lookahead."); + addAndMakeVisible(detector); + detectorAttachment=std::make_unique( + p.state,"detector",detector); juce::ToggleButton* toggles[]{&autoRelease,&external,&listen,&bypass}; - const char* ids[]{"autoRelease","external","listen","bypass"}; - for(int i=0;i<4;++i) { addAndMakeVisible(*toggles[i]); buttons[static_cast(i)]=std::make_unique(p.state,ids[i],*toggles[i]); } - external.setTooltip("Uses the host sidechain bus. If unconnected, detector receives silence."); - listen.setTooltip("Audition the filtered detector signal. Turn off for normal output."); - compare.setTooltip("Swap the current settings with the alternate A/B snapshot."); - compare.onClick=[this] { const auto current=processor.snapshot(); for(std::size_t i=0;i(p.state,toggleIds[i],*toggles[i]); + } + external.setTooltip("Requires the host to route the external sidechain."); + listen.setTooltip("Audition the detector: turn off after checking."); + compare.setTooltip("A/B snapshots apply to actual host parameters."); + compare.onClick=[this] { + const auto current=processor.snapshot(); + for(std::size_t i=0;i( - "Save ArSonComp preset",suggested,"*.arsoncomp"); + "Save ArSonComp preset", + juce::File::getSpecialLocation(juce::File::userDocumentsDirectory) + .getChildFile("ArSonComp-Preset.arsoncomp"),"*.arsoncomp"); juce::Component::SafePointer safe(this); presetChooser->launchAsync(juce::FileBrowserComponent::saveMode | - juce::FileBrowserComponent::canSelectFiles | - juce::FileBrowserComponent::warnAboutOverwriting,[safe](const juce::FileChooser& chooser) { + juce::FileBrowserComponent::canSelectFiles | + juce::FileBrowserComponent::warnAboutOverwriting, + [safe](const juce::FileChooser& chooser) { if(auto* editor=safe.getComponent()) { auto file=chooser.getResult(); - if(file==juce::File{}) return; - if(!file.hasFileExtension(".arsoncomp")) file=file.withFileExtension(".arsoncomp"); + if(file==juce::File{})return; + if(!file.hasFileExtension(".arsoncomp")) + file=file.withFileExtension(".arsoncomp"); if(!arson::preset::save(editor->processor,file)) - juce::AlertWindow::showMessageBoxAsync(juce::MessageBoxIconType::WarningIcon, - "Preset save failed","Could not write the selected preset file."); + juce::AlertWindow::showMessageBoxAsync( + juce::MessageBoxIconType::WarningIcon, + "Save failed","Could not write the selected preset."); } }); }; loadPreset.onClick=[this] { presetChooser=std::make_unique( - "Open ArSonComp preset",juce::File::getSpecialLocation(juce::File::userDocumentsDirectory), - "*.arsoncomp"); + "Open ArSonComp preset", + juce::File::getSpecialLocation(juce::File::userDocumentsDirectory),"*.arsoncomp"); juce::Component::SafePointer safe(this); presetChooser->launchAsync(juce::FileBrowserComponent::openMode | - juce::FileBrowserComponent::canSelectFiles,[safe](const juce::FileChooser& chooser) { + juce::FileBrowserComponent::canSelectFiles, + [safe](const juce::FileChooser& chooser) { if(auto* editor=safe.getComponent()) { const auto file=chooser.getResult(); - if(file==juce::File{}) return; + if(file==juce::File{})return; if(!arson::preset::load(editor->processor,file)) { - juce::AlertWindow::showMessageBoxAsync(juce::MessageBoxIconType::WarningIcon, - "Preset open failed","Unsupported or damaged .arsoncomp preset."); + juce::AlertWindow::showMessageBoxAsync( + juce::MessageBoxIconType::WarningIcon, + "Preset rejected","This is not a compatible ArSonComp preset."); return; } editor->presetSnapshot=editor->processor.snapshot(); editor->presets.setSelectedId(0,juce::dontSendNotification); - editor->presets.setText("USER / "+file.getFileNameWithoutExtension(), - juce::dontSendNotification); - editor->repaint(editor->display); + editor->presets.setText(file.getFileNameWithoutExtension(),juce::dontSendNotification); + editor->cachedCurveKey[0]=999; + editor->repaint(); } }); }; addAndMakeVisible(savePreset); addAndMakeVisible(loadPreset); compact.setComponentID("view.compact"); - compact.setTooltip("Toggle compact hardware-style view without losing settings."); + compact.setTooltip("MINI shows hardware controls and horizontal stereo meters."); compact.onClick=[this] { compactMode=!compactMode; if(compactMode) { expandedWidth=getWidth();expandedHeight=getHeight(); - setResizeLimits(920,380,1320,380); + setResizeLimits(960,380,1600,380); compact.setButtonText("FULL"); setSize(expandedWidth,380); } else { - setResizeLimits(920,620,1320,840); + setResizeLimits(960,670,1600,1040); compact.setButtonText("MINI"); setSize(expandedWidth,expandedHeight); } }; addAndMakeVisible(compact); - arson::MeterFrame discard; for(std::uint32_t i=0;iendChangeGesture(); + if(auto* parameter=processor.state.getParameter("threshold")) + parameter->endChangeGesture(); setLookAndFeel(nullptr); } void Editor::setValue(std::size_t i,float value) { - if(auto* param=processor.state.getParameter(arson::specs[i].id)) { - param->beginChangeGesture(); param->setValueNotifyingHost(param->convertTo0to1(value)); param->endChangeGesture(); + if(auto* parameter=processor.state.getParameter(arson::specs[i].id)) { + parameter->beginChangeGesture(); + parameter->setValueNotifyingHost(parameter->convertTo0to1(value)); + parameter->endChangeGesture(); } } void Editor::applyPreset(int id) { - if(id<1) return; + if(id<1)return; arson::Parameters p; - if(id==2) { p.value[arson::Ratio]=2.5f;p.value[arson::Attack]=15;p.value[arson::Release]=180;p.value[arson::Knee]=12;p.value[arson::Style]=2; } - if(id==3) { p.value[arson::Threshold]=-24;p.value[arson::Ratio]=3;p.value[arson::Detector]=1;p.value[arson::AutoRelease]=1;p.value[arson::Highpass]=100;p.value[arson::Style]=1; } - if(id==4) { p.value[arson::Ratio]=2;p.value[arson::Attack]=30;p.value[arson::Release]=250;p.value[arson::Knee]=12;p.value[arson::Range]=6;p.value[arson::Highpass]=80;p.value[arson::Style]=2; } - if(id==5) { p.value[arson::Ratio]=5;p.value[arson::Attack]=25;p.value[arson::Release]=80;p.value[arson::Knee]=3;p.value[arson::Mix]=75; } - if(id==6) { p.value[arson::Threshold]=-24;p.value[arson::Ratio]=4;p.value[arson::Attack]=5;p.value[arson::Release]=180;p.value[arson::Knee]=12;p.value[arson::Highpass]=100;p.value[arson::AutoRelease]=1;p.value[arson::Style]=2; } + if(id==2) {p.value[arson::Ratio]=2.5f;p.value[arson::Attack]=15; + p.value[arson::Release]=180;p.value[arson::Knee]=12;p.value[arson::Style]=2;} + if(id==3) {p.value[arson::Threshold]=-24;p.value[arson::Ratio]=3; + p.value[arson::Detector]=1;p.value[arson::AutoRelease]=1; + p.value[arson::Highpass]=100;p.value[arson::Style]=1;} + if(id==4) {p.value[arson::Ratio]=2;p.value[arson::Attack]=30; + p.value[arson::Release]=250;p.value[arson::Knee]=12; + p.value[arson::Range]=6;p.value[arson::Highpass]=80;p.value[arson::Style]=2;} + if(id==5) {p.value[arson::Ratio]=5;p.value[arson::Attack]=25; + p.value[arson::Release]=80;p.value[arson::Knee]=3;p.value[arson::Mix]=75;} + if(id==6) {p.value[arson::Threshold]=-24;p.value[arson::Ratio]=4; + p.value[arson::Attack]=5;p.value[arson::Release]=180; + p.value[arson::Knee]=12;p.value[arson::Highpass]=100; + p.value[arson::AutoRelease]=1;p.value[arson::Style]=2;} presetSnapshot=p; - for(std::size_t i=0;i Editor::plotBounds() const noexcept { + if(compactMode || display.isEmpty())return {}; + return {static_cast(display.getX()+82), + static_cast(display.getY()+30), + static_cast(display.getWidth()-206), + static_cast(display.getHeight()-60)}; } void Editor::resized() { const int w=getWidth(),h=getHeight(); - compact.setBounds(213,26,50,27); - style.setBounds(270,25,154,29); - presets.setBounds(w-464,25,164,29); - savePreset.setBounds(w-294,25,46,29); - loadPreset.setBounds(w-242,25,46,29); - compare.setBounds(w-190,25,64,29); - bypass.setBounds(w-121,25,101,29); - display=compactMode ? juce::Rectangle{} : juce::Rectangle{18,66,w-36,h-326}; - const int y=compactMode ? 71 : display.getBottom()+14; - const int knobWidth=(w-40)/8; - const std::array primary{arson::Threshold,arson::Ratio,arson::Attack, - arson::Release,arson::Knee,arson::Range,arson::Makeup,arson::Mix}; - for(std::size_t j=0;j(j)*knobWidth; - labels[i].setBounds(x,y,knobWidth,18); - knobs[i].setBounds(x+5,y+17,knobWidth-10,89); + compact.setBounds(194,31,52,28); + style.setBounds(257,30,177,29); + presets.setBounds(w-472,30,160,29); + savePreset.setBounds(w-304,30,50,29); + loadPreset.setBounds(w-248,30,50,29); + compare.setBounds(w-192,30,67,29); + bypass.setBounds(w-116,32,101,26); + display=compactMode?juce::Rectangle{}:juce::Rectangle{9,83,w-18,h-366}; + const int mainY=compactMode?71:display.getBottom()+7; + const int cell=(w-28)/7; + const std::array main{arson::Input,arson::Attack, + arson::Release,arson::Threshold,arson::Ratio,arson::Knee,arson::Makeup}; + for(std::size_t k=0;k(k)*cell; + labels[i].setBounds(x,mainY+5,cell,17); + knobs[i].setBounds(x+4,mainY+20,cell-8,114); } - const int bottom=y+118,small=(w-300)/5; - const std::array secondary{arson::Input,arson::Hold,arson::Link, - arson::Highpass,arson::Lowpass}; - for(std::size_t j=0;j(j)*small; - labels[i].setBounds(x,bottom,small,18); - knobs[i].setBounds(x+7,bottom+17,small-14,77); + const int bottomY=compactMode?203:h-126; + const int small=(w-218)/6; + const std::array smallControls{arson::Range,arson::Hold, + arson::Mix,arson::Link,arson::Highpass,arson::Lowpass}; + for(std::size_t k=0;k(k)*small; + labels[i].setBounds(x,bottomY+4,small,17); + knobs[i].setBounds(x+5,bottomY+23,small-10,61); } - const int x=w-272; - detector.setBounds(x,bottom+7,103,26); - autoRelease.setBounds(x+110,bottom+7,146,26); - external.setBounds(x,bottom+43,125,26); - listen.setBounds(x+135,bottom+43,120,26); - if(compactMode) {grid=juce::Image();return;} + const int opts=w-204; + detector.setBounds(opts,bottomY+6,91,27); + autoRelease.setBounds(opts+99,bottomY+5,109,27); + external.setBounds(opts,bottomY+42,105,26); + listen.setBounds(opts+107,bottomY+42,104,26); + if(compactMode){grid=juce::Image();return;} + + // The graph background never depends on audio. Build it on layout changes only. + cachedCurveWidth=-1; grid=juce::Image(juce::Image::RGB,display.getWidth(),display.getHeight(),true); juce::Graphics g(grid); - g.fillAll(panel); - const int graphLeft=290,graphRight=display.getWidth()-132; - const float top=32.0f,bottomY=static_cast(display.getHeight()-35); - for(int db=0;db>=-60;db-=12) { - const float yy=bottomY-static_cast(db+60)/60.0f*(bottomY-top); - g.setColour(line.withAlpha(0.50f)); - g.drawHorizontalLine(static_cast(yy),static_cast(graphLeft),static_cast(graphRight)); - g.setColour(muted.withAlpha(0.65f));g.setFont(juce::FontOptions(10)); - g.drawText(juce::String(db),graphRight+3,static_cast(yy)-8,23,16,juce::Justification::centred); + const float width=static_cast(display.getWidth()),height=static_cast(display.getHeight()); + g.setGradientFill(juce::ColourGradient(panel,0.0f,0.0f,bg,width,height,false)); + g.fillAll(); + const auto plot=plotBounds().translated(-static_cast(display.getX()), + -static_cast(display.getY())); + g.setColour(juce::Colour{0xff20262b}.withAlpha(0.43f)); + g.fillRect(plot); + const float bottom=plot.getBottom(),left=plot.getX(),right=plot.getRight(); + for(int db=-60;db<=0;db+=6) { + const float yy=graphY(plot,static_cast(db)); + g.setColour(juce::Colour{0xff58616a}.withAlpha(db%12==0?0.24f:0.1f)); + g.drawHorizontalLine(static_cast(yy),left,right); + if(db%12==0) { + g.setColour(muted.withAlpha(0.72f)); + g.setFont(juce::FontOptions(10.0f)); + g.drawText(juce::String(db),static_cast(left)-37, + static_cast(yy)-8,31,17,juce::Justification::centredRight); + } } - for(int i=1;i<8;++i) { - const float xx=static_cast(graphLeft)+(graphRight-graphLeft)*i/8.0f; - g.setColour(line.withAlpha(0.32f));g.drawVerticalLine(static_cast(xx),top,bottomY); + for(int db=-60;db<=0;db+=10) { + const float xx=left+(static_cast(db+60)/60.0f)*plot.getWidth(); + g.setColour(juce::Colour{0xff64707a}.withAlpha(db%20==0?0.24f:0.11f)); + g.drawVerticalLine(static_cast(xx),plot.getY(),bottom); } - g.setColour(line);g.drawVerticalLine(272,16.0f,static_cast(display.getHeight()-16)); - g.drawVerticalLine(display.getWidth()-124,16.0f,static_cast(display.getHeight()-16)); + g.setColour(juce::Colour{0xff51585f}.withAlpha(0.7f)); + g.drawRect(plot,0.9f); + g.setColour(juce::Colour{0xff454b50}); + g.drawVerticalLine(static_cast(left)-45,18.0f,height-20.0f); + g.drawVerticalLine(static_cast(right)+12,18.0f,height-20.0f); } - void Editor::timerCallback() { - if(!isShowing()) return; + if(!isShowing())return; if(presets.getSelectedId()>0) { const auto current=processor.snapshot(); - for(std::size_t i=0;i0.001f) { - presets.setSelectedId(0,juce::dontSendNotification); presets.setText("Custom",juce::dontSendNotification); break; + for(std::size_t i=0;i0.001f) { + presets.setSelectedId(0,juce::dontSendNotification); + presets.setText("Custom",juce::dontSendNotification); + break; + } + } + arson::MeterFrame frame; float in=0,out=0,reduction=0; + std::array inPeaks{},outPeaks{}; + int received=0; + while(received(arson::MeterQueue::capacity) && + processor.meters.pop(frame)) { + history[head]=frame; + head=(head+1)%history.size(); + ++received; + in=std::max(in,frame.input); + out=std::max(out,frame.output); + reduction=std::max(reduction,frame.reduction); + currentChannels=frame.channels; + for(int i=0;i<2;++i) { + inPeaks[static_cast(i)]=std::max(inPeaks[static_cast(i)], + frame.inputChannel[static_cast(i)]); + outPeaks[static_cast(i)]=std::max(outPeaks[static_cast(i)], + frame.outputChannel[static_cast(i)]); } } - arson::MeterFrame frame; float in=0,out=0,reduction=0; int received=0; - // Fixed upper bound; coalesce meters to one UI update, retain 100 Hz trace history. - while(received(arson::MeterQueue::capacity) && processor.meters.pop(frame)) { - history[head]=frame;head=(head+1)%history.size();++received; - in=std::max(in,frame.input);out=std::max(out,frame.output);reduction=std::max(reduction,frame.reduction); + inputDb=std::max(arson::gainToDb(in),inputDb-1.2f); + outputDb=std::max(arson::gainToDb(out),outputDb-1.2f); + gr=std::max(reduction,gr-0.8f); + for(int i=0;i<2;++i) { + inChannelDb[static_cast(i)]= + std::max(arson::gainToDb(inPeaks[static_cast(i)]), + inChannelDb[static_cast(i)]-1.2f); + outChannelDb[static_cast(i)]= + std::max(arson::gainToDb(outPeaks[static_cast(i)]), + outChannelDb[static_cast(i)]-1.2f); } - inputDb=std::max(arson::gainToDb(in),inputDb-1.2f); outputDb=std::max(arson::gainToDb(out),outputDb-1.2f); gr=std::max(reduction,gr-0.8f); - if(compactMode) repaint(20,301,getWidth()-40,44); + if(compactMode)repaint(14,298,getWidth()-28,57); else repaint(display); } void Editor::paint(juce::Graphics& g) { g.fillAll(bg); - g.setGradientFill(juce::ColourGradient(juce::Colour{0xff2b302a},0.0f,0.0f,bg,0.0f,64.0f,false)); - g.fillRect(0,0,getWidth(),65); - g.setColour(text);g.setFont(juce::FontOptions(21)); - g.drawText("ArSonComp",21,13,190,29,juce::Justification::centredLeft); - g.setColour(gold);g.fillRoundedRectangle(23.0f,48.0f,53.0f,2.0f,1.0f); - g.setColour(muted);g.setFont(juce::FontOptions(10)); - g.drawText("LIVE DYNAMICS",88,44,145,14,juce::Justification::centredLeft); - g.drawText("MODEL",271,8,146,15,juce::Justification::left); - g.drawText("PRESETS",getWidth()-463,8,164,15,juce::Justification::left); + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff272b30},0,0,bg,0,77,false)); + g.fillRect(0,0,getWidth(),76); + g.setColour(juce::Colour{0xff41464b}); + g.drawHorizontalLine(76,0.0f,static_cast(getWidth())); + g.setFont(juce::FontOptions(24.0f)); + g.setColour(text); + g.drawText("ArSon",18,16,93,28,juce::Justification::centredLeft); + g.setColour(accent); + g.drawText("Comp",111,16,87,28,juce::Justification::centredLeft); + g.fillRoundedRectangle(19.0f,57.0f,48.0f,2.5f,1.2f); + g.setColour(muted);g.setFont(juce::FontOptions(9.5f)); + g.drawText("LIVE DYNAMICS",77,53,121,17,juce::Justification::centredLeft); + g.drawText("MODEL",258,11,100,17,juce::Justification::left); + g.drawText("PRESET",getWidth()-472,11,130,17,juce::Justification::left); + const int mainY=compactMode?71:display.getBottom()+7; + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff1c2025}, + 0,static_cast(mainY),bg,0,static_cast(mainY+170),false)); + g.fillRect(8,mainY,getWidth()-16,compactMode?133:140); + g.setColour(line.withAlpha(0.80f)); + g.drawHorizontalLine(mainY,12.0f,static_cast(getWidth()-12)); + g.drawHorizontalLine(compactMode?197:getHeight()-126, + 12.0f,static_cast(getWidth()-12)); if(!compactMode) { if(grid.isValid())g.drawImageAt(grid,display.getX(),display.getY()); - g.setColour(line);g.drawRoundedRectangle(display.toFloat(),6.0f,1.0f); + g.setColour(juce::Colour{0xff50565c}); + g.drawRoundedRectangle(display.toFloat(),5.0f,0.85f); drawDisplay(g); + } else paintCompactMeters(g); + g.setColour(muted.withAlpha(0.75f)); + g.setFont(juce::FontOptions(9.3f)); + g.drawText("ZERO ADDED SAMPLES / ZERO LOOKAHEAD / VST3", + 16,getHeight()-18,438,14,juce::Justification::left); + g.drawText("Original real-time compressor | Drag controls / double-click reset", + getWidth()-435,getHeight()-18,420,14,juce::Justification::centredRight); +} +void Editor::refreshTransfer(const arson::Parameters& p,juce::Rectangle plot) { + const std::array key{{p[arson::Threshold],p[arson::Ratio], + p[arson::Knee],p[arson::Range]}}; + if(key==cachedCurveKey && plot.getWidth()==cachedCurveWidth)return; + cachedCurveKey=key; + cachedCurveWidth=plot.getWidth(); + transferCurve.clear(); + transferShade.clear(); + const int steps=std::max(100,static_cast(plot.getWidth())); + for(int i=0;i<=steps;++i) { + const float db=-60.0f+60.0f*static_cast(i)/steps; + const float y=graphY(plot,db-arson::reduction(db,key[0],key[1],key[2],key[3])); + const float x=plot.getX()+plot.getWidth()*static_cast(i)/steps; + if(i==0){transferCurve.startNewSubPath(x,y);transferShade.startNewSubPath(x,y);} + else {transferCurve.lineTo(x,y);transferShade.lineTo(x,y);} } - g.setColour(line.withAlpha(0.75f)); - g.drawHorizontalLine(compactMode ? 296 : display.getBottom()+123, - 20.0f,static_cast(getWidth()-20)); - if(compactMode) { - // Compact mode retains essential performance metering rather than - // becoming a knob-only view. No cached graph is allocated. - const float values[]{inputDb,gr,outputDb}; - const char* names[]{"IN","GR","OUT"}; - const int section=(getWidth()-40)/3; - for(int i=0;i<3;++i) { - const float x=20.0f+static_cast(i*section); - g.setColour(muted);g.setFont(juce::FontOptions(11)); - g.drawText(names[i],static_cast(x)+3,305,55,17,juce::Justification::left); - g.setColour(text);g.setFont(juce::FontOptions(11.5f)); - g.drawText(values[i]<-99 ? "-inf dB" : juce::String(values[i],1)+" dB", - static_cast(x)+section-82,305,76,18,juce::Justification::centredRight); - const float bx=x+3.0f,bw=static_cast(section-15); - g.setColour(line);g.fillRoundedRectangle(bx,331.0f,bw,6.0f,2.0f); - const float amount=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36.0f) - : juce::jlimit(0.0f,1.0f,(values[i]+60.0f)/60.0f); - g.setColour(i==1 ? gold : cyan); - if(amount>0.0f)g.fillRoundedRectangle(bx,331.0f,bw*amount,6.0f,2.0f); + transferShade.lineTo(plot.getRight(),plot.getBottom()); + transferShade.closeSubPath(); +} +void Editor::drawMeter(juce::Graphics& g,juce::Rectangle bounds, + float dB1,float dB2,const juce::String& title,bool gainReduction) { + const auto x=bounds.getX(),y=bounds.getY(),h=bounds.getHeight(); + g.setColour(muted); + g.setFont(juce::FontOptions(10.0f)); + g.drawText(title,static_cast(x)-3,static_cast(y)-22, + static_cast(bounds.getWidth())+6,18,juce::Justification::centred); + const int bars=(gainReduction || currentChannels==1)?1:2; + const float bw=bars==1?13.0f:9.0f; + const float spacing=3.0f; + const float total=bw*bars+spacing*(bars-1); + const float start=x+(bounds.getWidth()-total)*0.5f; + for(int c=0;c(segments); + for(int step=0;step(step+1)/segments; + const float sy=gainReduction?y+step*sh:y+h-(step+1)*sh; + if(fraction<=fill) { + juce::Colour color; + if(gainReduction)color=accent; + else if(fraction>0.90f)color=juce::Colour{0xffff5c63}; + else if(fraction>0.71f)color=yellow; + else color=green; + g.setColour(color); + } else g.setColour(juce::Colour{0xff313637}.withAlpha(0.52f)); + g.fillRect(bx,sy,bw,std::max(1.0f,sh-1.2f)); } + g.setColour(juce::Colour{0xff535b60}); + g.drawRect(bx-1.0f,y-1.0f,bw+2,h+2,0.7f); } - g.setColour(muted);g.setFont(juce::FontOptions(10.5f)); - g.drawText("0 SAMPLES ADDED | REAL-TIME DSP | VST3",20,getHeight()-25,455,17,juce::Justification::left); - g.drawText("Drag controls / double-click reset / type exact values", - getWidth()-420,getHeight()-25,400,17,juce::Justification::centredRight); + g.setFont(juce::FontOptions(11.0f)); + g.setColour(text); + g.drawText(levelText(dB1),static_cast(x)-10,static_cast(y+h+6), + static_cast(bounds.getWidth())+20,18,juce::Justification::centred); } - void Editor::drawDisplay(juce::Graphics& g) { juce::Graphics::ScopedSaveState save(g); g.reduceClipRegion(display); g.setOrigin(display.getPosition()); - const float h=static_cast(display.getHeight()); - const float w=static_cast(display.getWidth()); + const auto plot=plotBounds().translated(-static_cast(display.getX()), + -static_cast(display.getY())); + if(plot.isEmpty())return; const auto p=processor.snapshot(); - const float top=32.0f,bottom=h-35.0f; - g.setFont(juce::FontOptions(11.0f)); - g.setColour(muted);g.drawText("TRANSFER | DRAG GOLD MARKER",23,10,250,18,juce::Justification::left); - g.drawText("DYNAMICS | 4s",291,10,230,18,juce::Justification::left); + const float w=static_cast(display.getWidth()),h=static_cast(display.getHeight()); + refreshTransfer(p,plot); + g.setFont(juce::FontOptions(10.0f)); + g.setColour(muted); + g.drawText("DYNAMICS / 4.0 s",static_cast(plot.getX())+7,8,185,17, + juce::Justification::left); + g.setColour(accent.withAlpha(0.82f)); + g.drawText("TRANSFER / DRAG THRESHOLD",static_cast(plot.getRight())-225,8,219,17, + juce::Justification::centredRight); - const juce::Rectangle curve{26.0f,top,229.0f,bottom-top}; - const auto yCurve=[&](float db) { - return curve.getBottom()-juce::jlimit(0.0f,1.0f,(db+60.0f)/60.0f)*curve.getHeight(); - }; - g.setColour(line.withAlpha(0.75f));g.drawRect(curve,1.0f); - g.setColour(muted.withAlpha(0.30f)); - g.drawLine(curve.getX(),curve.getBottom(),curve.getRight(),curve.getY(),1.0f); - const float tx=curve.getX()+juce::jlimit(0.0f,1.0f,(p[arson::Threshold]+60)/60.0f)*curve.getWidth(); - g.setColour(gold.withAlpha(0.30f));g.drawVerticalLine(static_cast(tx),top,bottom); - juce::Path transfer; - for(int i=0;i<=229;++i) { - const float db=-60.0f+60.0f*i/229.0f; - const float gain=arson::reduction(db,p[arson::Threshold],p[arson::Ratio],p[arson::Knee],p[arson::Range]); - const float yy=yCurve(db-gain); - if(i==0)transfer.startNewSubPath(curve.getX(),yy); - else transfer.lineTo(curve.getX()+i,yy); - } - g.setColour(gold.withAlpha(0.18f));g.strokePath(transfer,juce::PathStrokeType(5.0f)); - g.setColour(gold);g.strokePath(transfer,juce::PathStrokeType(1.9f)); - const float dotX=curve.getX()+juce::jlimit(0.0f,1.0f,(inputDb+60)/60)*curve.getWidth(); - const float dotY=yCurve(inputDb-arson::reduction(inputDb,p[arson::Threshold], - p[arson::Ratio],p[arson::Knee],p[arson::Range])); - g.setColour(gold.withAlpha(0.25f));g.fillEllipse(dotX-6,dotY-6,12,12); - g.setColour(juce::Colours::white);g.fillEllipse(dotX-2.2f,dotY-2.2f,4.4f,4.4f); - g.setColour(muted);g.setFont(juce::FontOptions(10.0f)); - g.drawText("-60 dB",24,static_cast(h)-29,65,17,juce::Justification::left); - g.drawText("0 dB",190,static_cast(h)-29,65,17,juce::Justification::right); + // Graph and metering share a -60 to 0 dBFS scale. The transfer line is a + // real response curve; the animated lines are real per-block telemetry. + // The two data types never claim to share an x-axis: static transfer uses + // input level on x, dynamic history uses time. + g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.23f), + plot.getX(),plot.getY()+plot.getHeight()*0.28f, + accent.withAlpha(0.006f),plot.getX(),plot.getBottom(),false)); + g.fillPath(transferShade); + g.setColour(accent.withAlpha(0.17f)); + g.strokePath(transferCurve,juce::PathStrokeType(6.0f)); + g.setColour(accentBright); + g.strokePath(transferCurve,juce::PathStrokeType(2.1f)); - // GUI drains a fixed 400-frame telemetry history; no audio-thread graphics. - const float left=290,right=w-132; - const auto levelY=[&](float db) { - return bottom-juce::jlimit(0.0f,1.0f,(db+60.0f)/60.0f)*(bottom-top); - }; - juce::Path inPath,outPath,grPath,grFill; + const float mx=plot.getX()+dbFraction(p[arson::Threshold])*plot.getWidth(); + const float my=graphY(plot,p[arson::Threshold]- + arson::reduction(p[arson::Threshold],p[arson::Threshold], + p[arson::Ratio],p[arson::Knee],p[arson::Range])); + g.setColour(accent.withAlpha(0.28f)); + g.drawVerticalLine(static_cast(mx),plot.getY(),plot.getBottom()); + g.setColour(accent.withAlpha(0.24f)); + g.fillEllipse(mx-9,my-9,18,18); + g.setColour(juce::Colours::white); + g.fillEllipse(mx-4.0f,my-4.0f,8.0f,8.0f); + + // Only message-thread path objects; 400 fixed frames = 4 seconds at 100Hz. + juce::Path inputTrace,outputTrace,reductionTrace,reductionFill; for(std::size_t i=0;i(i)/(history.size()-1); - const float iy=levelY(arson::gainToDb(f.input)); - const float oy=levelY(arson::gainToDb(f.output)); - const float ry=top+juce::jlimit(0.0f,1.0f,f.reduction/36.0f)*(bottom-top); + const float x=plot.getX()+plot.getWidth()*static_cast(i)/ + static_cast(history.size()-1); + const float inY=graphY(plot,arson::gainToDb(f.input)); + const float outY=graphY(plot,arson::gainToDb(f.output)); + const float grY=plot.getY()+clamp01(f.reduction/30.0f)*plot.getHeight()*0.40f; if(i==0) { - inPath.startNewSubPath(xx,iy);outPath.startNewSubPath(xx,oy); - grPath.startNewSubPath(xx,ry); - grFill.startNewSubPath(xx,top);grFill.lineTo(xx,ry); + inputTrace.startNewSubPath(x,inY); + outputTrace.startNewSubPath(x,outY); + reductionTrace.startNewSubPath(x,grY); + reductionFill.startNewSubPath(x,plot.getY()); + reductionFill.lineTo(x,grY); } else { - inPath.lineTo(xx,iy);outPath.lineTo(xx,oy); - grPath.lineTo(xx,ry);grFill.lineTo(xx,ry); + inputTrace.lineTo(x,inY); + outputTrace.lineTo(x,outY); + reductionTrace.lineTo(x,grY); + reductionFill.lineTo(x,grY); } } - grFill.lineTo(right,top);grFill.closeSubPath(); - g.setGradientFill(juce::ColourGradient(gold.withAlpha(0.16f),left,top, - gold.withAlpha(0.0f),left,bottom,false)); - g.fillPath(grFill); - g.setColour(muted.withAlpha(0.48f));g.strokePath(inPath,juce::PathStrokeType(1.05f)); - g.setColour(cyan.withAlpha(0.93f));g.strokePath(outPath,juce::PathStrokeType(1.55f)); - g.setColour(gold);g.strokePath(grPath,juce::PathStrokeType(1.55f)); - g.setColour(gold.withAlpha(0.33f)); - g.drawHorizontalLine(static_cast(levelY(p[arson::Threshold])),left,right); - g.setFont(juce::FontOptions(10.5f)); - g.setColour(muted);g.drawText("IN",static_cast(left),static_cast(h)-28,36,17,juce::Justification::left); - g.setColour(cyan);g.drawText("OUT",static_cast(left)+38,static_cast(h)-28,48,17,juce::Justification::left); - g.setColour(gold);g.drawText("GR",static_cast(left)+93,static_cast(h)-28,38,17,juce::Justification::left); - const float values[]{inputDb,gr,outputDb};const char* names[]{"IN","GR","OUT"}; - for(int i=0;i<3;++i) { - const float x=w-116.0f+static_cast(i)*37.0f; - g.setColour(muted);g.drawText(names[i],static_cast(x)-3,8,31,18,juce::Justification::centred); - g.setColour(juce::Colour{0xff26313c});g.fillRoundedRectangle(x+7,top,10,bottom-top,3); - const float fraction=i==1 ? juce::jlimit(0.0f,1.0f,values[i]/36.0f) - : juce::jlimit(0.0f,1.0f,(values[i]+60.0f)/60.0f); - const float filled=(bottom-top)*fraction; - g.setColour(i==1 ? gold : cyan); - if(filled>0)g.fillRoundedRectangle(x+7,(i==1 ? top : bottom-filled),10,filled,3.0f); - g.setColour(text);g.setFont(juce::FontOptions(10.0f)); - g.drawText(values[i]<-99 ? "-inf" : juce::String(values[i],1), - static_cast(x)-6,static_cast(h)-29,39,18,juce::Justification::centred); - } + reductionFill.lineTo(plot.getRight(),plot.getY()); + reductionFill.closeSubPath(); + g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.20f), + plot.getX(),plot.getY(),accent.withAlpha(0.0f), + plot.getX(),plot.getY()+plot.getHeight()*0.4f,false)); + g.fillPath(reductionFill); + g.setColour(juce::Colours::white.withAlpha(0.26f)); + g.strokePath(inputTrace,juce::PathStrokeType(1.15f)); + g.setColour(juce::Colour{0xffd8d9d8}.withAlpha(0.63f)); + g.strokePath(outputTrace,juce::PathStrokeType(1.15f)); + g.setColour(accentBright.withAlpha(0.94f)); + g.strokePath(reductionTrace,juce::PathStrokeType(1.7f)); + + drawMeter(g,{14.0f,plot.getY(),33.0f,plot.getHeight()}, + inChannelDb[0],inChannelDb[1],"IN",false); + drawMeter(g,{w-110.0f,plot.getY(),34.0f,plot.getHeight()}, + gr,gr,"GR",true); + drawMeter(g,{w-61.0f,plot.getY(),42.0f,plot.getHeight()}, + outChannelDb[0],outChannelDb[1],"OUT",false); + g.setColour(muted.withAlpha(0.88f)); + g.setFont(juce::FontOptions(9.0f)); + g.drawText("-60 dB",static_cast(plot.getX()), + static_cast(h)-27,60,15,juce::Justification::left); + g.drawText("0 dBFS",static_cast(plot.getRight())-60, + static_cast(h)-27,60,15,juce::Justification::right); if(p[arson::Listen]>0.5f || p[arson::Bypass]>0.5f) { - g.setColour(gold);g.setFont(juce::FontOptions(11.0f)); - g.drawText(p[arson::Bypass]>0.5f ? "BYPASSED" : "SIDECHAIN MONITOR", - static_cast(left)+125,8,210,18,juce::Justification::left); + g.setFont(juce::FontOptions(11.0f)); + g.setColour(accentBright); + g.drawText(p[arson::Bypass]>0.5f?"BYPASSED":"SIDECHAIN MONITOR", + static_cast(plot.getCentreX())-95,8,190,19,juce::Justification::centred); + } +} +void Editor::paintCompactMeters(juce::Graphics& g) { + g.setColour(juce::Colour{0xff151a1e}); + g.fillRoundedRectangle(13.0f,301.0f,static_cast(getWidth()-26),49.0f,4.0f); + const float values[]{inputDb,gr,outputDb}; + const char* labelsText[]{"INPUT","GAIN REDUCTION","OUTPUT"}; + const int segment=(getWidth()-42)/3; + for(int i=0;i<3;++i) { + const float x=20.0f+static_cast(i*segment); + g.setColour(muted);g.setFont(juce::FontOptions(10.0f)); + g.drawText(labelsText[i],static_cast(x),304,109,16,juce::Justification::left); + g.setColour(text);g.setFont(juce::FontOptions(11.0f)); + g.drawText(levelText(values[i])+" dB",static_cast(x)+segment-85,304,78,16, + juce::Justification::centredRight); + g.setColour(line); + const float bw=static_cast(segment-16), y=330.0f; + g.fillRoundedRectangle(x,y,bw,6.0f,3.0f); + const float filled=i==1?clamp01(values[i]/30.0f):dbFraction(values[i]); + g.setColour(i==1?accent:green); + if(filled>0.0f)g.fillRoundedRectangle(x,y,bw*filled,6.0f,3.0f); } } - -// Dragging the gold transfer marker is a real host-automatable control. -// One host gesture covers the entire mouse interaction. void Editor::mouseDown(const juce::MouseEvent& event) { - if(compactMode || !display.contains(event.getPosition())) return; - const auto local=event.getPosition()-display.getPosition(); - if(local.x<26 || local.x>255 || local.y<32 || local.y>display.getHeight()-35) return; - const float markerX=26.0f+ - juce::jlimit(0.0f,1.0f,(processor.snapshot()[arson::Threshold]+60.0f)/60.0f)*229.0f; - if(std::abs(static_cast(local.x)-markerX)>14.0f) return; - if(auto* p=processor.state.getParameter("threshold")) { - p->beginChangeGesture(); + if(compactMode || !plotBounds().contains(event.position))return; + const auto p=processor.snapshot(); + const auto plot=plotBounds(); + const float mx=plot.getX()+dbFraction(p[arson::Threshold])*plot.getWidth(); + const float my=graphY(plot,p[arson::Threshold]- + arson::reduction(p[arson::Threshold],p[arson::Threshold], + p[arson::Ratio],p[arson::Knee],p[arson::Range])); + if(std::abs(event.position.x-mx)>16.0f || + std::abs(event.position.y-my)>18.0f)return; + if(auto* parameter=processor.state.getParameter("threshold")) { thresholdDragging=true; + parameter->beginChangeGesture(); mouseDrag(event); } } void Editor::mouseDrag(const juce::MouseEvent& event) { - if(!thresholdDragging) return; - const float x=static_cast(event.getPosition().x-display.getX()); - const float threshold=-60.0f+60.0f*juce::jlimit(0.0f,1.0f,(x-26.0f)/229.0f); - if(auto* p=processor.state.getParameter("threshold")) - p->setValueNotifyingHost(p->convertTo0to1(threshold)); + if(!thresholdDragging)return; + const auto plot=plotBounds(); + const float threshold=-60.0f+60.0f*clamp01( + (event.position.x-plot.getX())/plot.getWidth()); + if(auto* parameter=processor.state.getParameter("threshold")) + parameter->setValueNotifyingHost(parameter->convertTo0to1(threshold)); repaint(display); } void Editor::mouseUp(const juce::MouseEvent&) { - if(!thresholdDragging) return; + if(!thresholdDragging)return; thresholdDragging=false; - if(auto* p=processor.state.getParameter("threshold")) p->endChangeGesture(); + if(auto* parameter=processor.state.getParameter("threshold")) + parameter->endChangeGesture(); setMouseCursor(juce::MouseCursor::NormalCursor); } void Editor::mouseMove(const juce::MouseEvent& event) { - if(compactMode || !display.contains(event.getPosition())) { - setMouseCursor(juce::MouseCursor::NormalCursor);return; + if(compactMode || !plotBounds().contains(event.position)) { + setMouseCursor(juce::MouseCursor::NormalCursor); + return; } - const auto local=event.getPosition()-display.getPosition(); - const float markerX=26.0f+ - juce::jlimit(0.0f,1.0f,(processor.snapshot()[arson::Threshold]+60.0f)/60.0f)*229.0f; - const bool near=local.y>=32 && local.y<=display.getHeight()-35 && - std::abs(static_cast(local.x)-markerX)<=14.0f; - setMouseCursor(near ? juce::MouseCursor::PointingHandCursor - : juce::MouseCursor::NormalCursor); + const auto p=processor.snapshot(); + const auto plot=plotBounds(); + const float mx=plot.getX()+dbFraction(p[arson::Threshold])*plot.getWidth(); + const float my=graphY(plot,p[arson::Threshold]- + arson::reduction(p[arson::Threshold],p[arson::Threshold], + p[arson::Ratio],p[arson::Knee],p[arson::Range])); + const bool active=std::abs(event.position.x-mx)<=16.0f && + std::abs(event.position.y-my)<=18.0f; + setMouseCursor(active?juce::MouseCursor::PointingHandCursor: + juce::MouseCursor::NormalCursor); } diff --git a/plugin/Editor.h b/plugin/Editor.h index f86b1b8..25f6a2f 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -6,6 +6,9 @@ class CompLook final : public juce::LookAndFeel_V4 { CompLook(); juce::Label* createSliderTextBox(juce::Slider&) override; void drawRotarySlider(juce::Graphics&,int,int,int,int,float,float,float,juce::Slider&) override; + void drawLinearSlider(juce::Graphics&,int,int,int,int,float,float,float, + const juce::Slider::SliderStyle,juce::Slider&) override; + void drawToggleButton(juce::Graphics&,juce::ToggleButton&,bool,bool) override; }; class Editor final : public juce::AudioProcessorEditor, private juce::Timer { public: @@ -22,6 +25,11 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { void applyPreset(int); void setValue(std::size_t,float); void drawDisplay(juce::Graphics&); + juce::Rectangle plotBounds() const noexcept; + void refreshTransfer(const arson::Parameters&,juce::Rectangle); + void drawMeter(juce::Graphics&,juce::Rectangle,float,float, + const juce::String&,bool); + void paintCompactMeters(juce::Graphics&); Processor& processor; CompLook look; juce::TooltipWindow tooltip{this,650}; @@ -43,7 +51,12 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { std::array history{}; std::size_t head=0; float inputDb=-120,outputDb=-120,gr=0; + std::array inChannelDb{{-120.0f,-120.0f}},outChannelDb{{-120.0f,-120.0f}}; + int currentChannels=2; juce::Rectangle display; juce::Image grid; + juce::Path transferCurve,transferShade; + std::array cachedCurveKey{{999,999,999,999}}; + float cachedCurveWidth=-1; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Editor) }; diff --git a/plugin/PresetIO.h b/plugin/PresetIO.h index 339640c..3a40cde 100644 --- a/plugin/PresetIO.h +++ b/plugin/PresetIO.h @@ -8,7 +8,7 @@ namespace arson::preset { inline bool save(Processor& processor, const juce::File& file) { juce::MemoryBlock bytes; processor.getStateInformation(bytes); - auto xml=juce::getXmlFromBinary(bytes.getData(),static_cast(bytes.getSize())); + auto xml=juce::AudioProcessor::getXmlFromBinary(bytes.getData(),static_cast(bytes.getSize())); return xml!=nullptr && file.hasFileExtension(".arsoncomp") && xml->writeTo(file); } inline bool load(Processor& processor, const juce::File& file) { @@ -18,7 +18,7 @@ inline bool load(Processor& processor, const juce::File& file) { if(!xml || !xml->hasTagName("ArSonCompState") || xml->getIntAttribute("schema",1)!=1) return false; juce::MemoryBlock bytes; - juce::copyXmlToBinary(*xml,bytes); + juce::AudioProcessor::copyXmlToBinary(*xml,bytes); processor.setStateInformation(bytes.getData(),static_cast(bytes.getSize())); return true; } diff --git a/tests/EngineTests.cpp b/tests/EngineTests.cpp index 524bf8f..f4d7195 100644 --- a/tests/EngineTests.cpp +++ b/tests/EngineTests.cpp @@ -177,6 +177,24 @@ int main() { require(allocations.load()==before,"no allocation in process or parameter updates"); MeterFrame f;int count=0;while(q.pop(f))++count;require(count==511,"bounded telemetry drops on saturation"); } + { + // Two LED meter columns must carry genuinely independent channel + // peak values, rather than duplicating one shared maximum. + Compressor c;Parameters p;p.value[Ratio]=1.0f;c.prepare(48000,p); + float left[480],right[480]; + for(int i=0;i<480;++i){left[i]=0.2f;right[i]=0.65f;} + float* audio[]{left,right}; + MeterQueue meter; + c.process(audio,2,480,nullptr,0,&meter); + MeterFrame f; + require(meter.pop(f),"one meter frame per 10 milliseconds"); + require(f.channels==2,"stereo metering channel count"); + require(near(f.inputChannel[0],0.2f) && near(f.inputChannel[1],0.65f), + "independent stereo input peaks"); + require(near(f.outputChannel[0],0.2f) && near(f.outputChannel[1],0.65f), + "independent stereo output peaks"); + require(near(f.input,0.65f),"aggregate peak remains unchanged"); + } { MeterQueue queue;constexpr int count=100000;std::atomic good{true}; std::thread producer([&]{for(int i=0;i(i),0,0}))std::this_thread::yield();}); diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index 2194bec..ab71597 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -32,9 +32,17 @@ int main(int argc,char** argv) { std::unique_ptr editor(processor.createEditor()); if(!editor->findChildWithID("preset.save") || !editor->findChildWithID("preset.load")) return 18; - editor->setSize(iteration%2 ? 920 : 1040,iteration%2 ? 620 : 680); - if(editor->getWidth()!=(iteration%2 ? 920 : 1040) || - editor->getHeight()!=(iteration%2 ? 620 : 680))return 9; + editor->setSize(iteration%2 ? 960 : 1120,iteration%2 ? 670 : 760); + if(editor->getWidth()!=(iteration%2 ? 960 : 1120) || + editor->getHeight()!=(iteration%2 ? 670 : 760))return 9; + const auto* threshold=editor->findChildWithID("param.threshold"); + const auto* input=editor->findChildWithID("param.input"); + const auto* ratio=editor->findChildWithID("param.ratio"); + const auto* attack=editor->findChildWithID("param.attack"); + if(!threshold || !input || !ratio || !attack || + !(input->getX()getX() && attack->getX()getX() && + threshold->getX()getX()))return 19; + if(threshold->getBounds().intersects(ratio->getBounds()))return 20; editor->addToDesktop(0); editor->setVisible(true); for(int j=0;j<1500;++j) { for(int i=0;i<128;++i) { @@ -63,7 +71,7 @@ int main(int argc,char** argv) { if(!stream || !juce::PNGImageFormat{}.writeImageToStream(compactImage,*stream))return 13; } mini->onClick(); - if(editor->getHeight()!=680)return 14; + if(editor->getHeight()!=760)return 14; } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3; From 6050baa318e842d78be6f81474c7a4a0678496e9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 07:56:49 +0700 Subject: [PATCH 10/35] Milestone: compact premium compressor UI, no-collision controls and cached smooth telemetry --- README.md | 6 + docs/ARD.md | 6 + docs/HANDOFF.md | 4 + docs/VALIDATION.md | 8 + docs/WINDOWS-QUICKSTART.md | 4 + plugin/Editor.cpp | 322 +++++++++++++++++++++++-------------- plugin/Editor.h | 6 +- tests/PluginSmoke.cpp | 33 +++- 8 files changed, 261 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index 4b2beac..a5bed96 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,9 @@ Repository license remains AGPL-3.0. JUCE has its own AGPL/commercial terms; see ## GUI visual reference and acceptance The newly redesigned UI uses the user-supplied ArSonComp mockup as a layout acceptance target: integrated upper graph, side meters, red glow and premium hardware controls. No bitmap UI assets, lookahead, worker waits or added algorithmic sample delay. The static graph background builds only on resize and the transfer curve is cached until threshold/ratio/knee/range or width changes. Windows test screenshots must show default 1120x760, minimum 960x670 and MINI 380px. A prior Windows CI build of the portable-preset milestone failed to compile due to incorrectly qualified JUCE XML helper methods; the new milestone fixes these to public AudioProcessor static methods. + +## Focused GUI and no-overdraw rendering milestone + +The 900x765 default layout replaces the earlier 1120x760 wide editor. Minimum 860x700; the optional 380px MINI/FULL mode retains all audio controls. Header, secondary sliders and toggles now use fixed-reserved regions and short labels such as HP/LP/LINK/EXT SC, with detailed dark contextual tooltips. The full graph is closer to square and remains the hero element. JUCE paint maintains a muted graphite/coral palette with a single enlarged Threshold. + +The GUI timer coalesces 100 Hz telemetry at 30 Hz and applies time-normalized attack/release easing only to the **display**, not audio. Input/output and actual GR history use a persistent fixed 400-frame ring buffer, with Path objects rebuilt only on new telemetry or layout change; any UI repaint simply strokes cached paths. Static grid remains cached per resize and transfer curve geometry only rebuilds when its parameters/size change. No new DSP latency, audio-thread worker, lock, heap use or lookahead. diff --git a/docs/ARD.md b/docs/ARD.md index 6534277..871879d 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -31,3 +31,9 @@ RAII owns GUI attachments and buffers. Timer is stopped before editor teardown. ## Deferred, not represented as working Pro-C-specific styles, mid/side compression, frequency-dependent linking, auto makeup, lookahead/offline quality mode, oversampling, scalable vector accessibility polish, user preset files, ASIO standalone integration and measured proprietary sound matching. Future modes must declare latency and pass block/automation tests separately. + +## Focused-layout / animation CPU milestone + +GUI target: **900x765 default; 860x700 min; 380px MINI**, instead of 1120x760. Header reserves safe widths for logo, MINI, model, preset, SAVE, OPEN, A/B and bypass. Main row contains exactly 7 knobs with larger Threshold. Secondary row computes 6 bounded strips plus fixed right-side space for detector and three shortened flags; labels keep full descriptions in dark custom JUCE tooltips. Geometric overlap and bounds are asserted by plugin smoke at default/min sizes, including MINI/FULL restoration. + +GUI drawing pipeline: `resized` caches graph background and regenerates path geometry for the new size; `timerCallback` drains SPSC 100 Hz samples once then computes time-compensated meter display easing (18ms rise/210ms fall, 22ms GR rise/185ms fall); when new frames arrive, it computes and reuses four 400-point paths for the time history with lightweight visual one-pole smoothing. `drawDisplay` only strokes existing time paths, cached transfer curve and segmented LED meters at 30 Hz, with dirty-region repaint. This removes repeated per-paint conversion/path-building for ~1200 dB point calculations. All smoothing affects presentation alone; DSP has unchanged zero added algorithmic samples. If editor is hidden, timer skips heavy visualization updates; reopening drains and paints the bounded queue. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index b547faa..ceef7fa 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -15,3 +15,7 @@ Keep builds grouped: one relevant-PR workflow with Linux safety and one Windows ## Current priority: reference visual fidelity + previous build regression The supplied red ArSonComp mockup is now the acceptance layout for a full-width integrated transfer/compression graph, side LED meters with true stereo peaks, animated actual GR, red dissolving fill, dominant Threshold knob, and two-row compact controls. Preserve no-lookahead live mode. IMPORTANT: CI for f847fa6 failed because PresetIO.h incorrectly called juce namespace functions getXmlFromBinary/copyXmlToBinary. Correct public API is juce::AudioProcessor::getXmlFromBinary/copyXmlToBinary. Validate Windows compile and the three screenshot variants before claiming milestone completed. Keep one grouped commit/CI and retain Draft until real verification. + +## Focused-layout milestone handoff + +The full reference GUI in commit f63e8c6 passed Windows/Linux CI, but user feedback on actual screenshot showed it was too wide and secondary controls were crowded. The new grouped follow-up moves to 900x765 default (860x700 minimum), shortens secondary labels with tooltip help, reflows all header/buttons/slider regions and adds smoke collision bounds tests. It also caches 400-point signal/GR Path objects between actual telemetry updates and applies UI-only time-based meter easing. Do not move easing onto the audio callback or add Lookahead. Review default/minimum/MINI Windows screenshots before release; host/pluginval/real device tests remain outstanding. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 1717989..85d0246 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -21,3 +21,11 @@ Current results must be recorded from the CI run for the commit which introduces ## Integrated-graph reference milestone (pending CI) Verify default 1120x760, minimum 960x670 and compact 380px Windows screenshot geometry; confirm accurate dark/red gradients, animated reduction/input/output history on a single canvas, red curved transfer law, dominant Threshold knob, stereo IN L/R and OUT L/R LED meters and GR meter. Engine checks 0.2/0.65 independent stereo input/output peaks and preserved aggregate maximum. Preset smoke must pass after correcting public static AudioProcessor XML helpers. No false lookahead knob, no added DSP samples. Host validation and DPI scaling remain release gates; screenshot smoke alone does not prove sonic parity. + +## Focused GUI milestone — acceptance + +- Assert 900×765 default, 860×700 minimum, 380px MINI and FULL roundtrip in Windows VST3 editor smoke. +- Check no collision / no off-window bounds for model+preset+SAVE+OPEN, 7 main controls, 6 secondary controls and detector/AUTO/EXT SC/LISTEN group; verify labels and tooltip visual design. +- Screenshot visual review: graph aspect and central prominence, legible 6 dB grid, restrained coral dissolving fill, stereo LED meters, large Threshold, full/mini readability. +- UI 30 Hz timing and 100 Hz bounded queue; time-based meter easing only on GUI; fixed ring history paths reused across paints and recomputed only for new telemetry or resize. Confirm on host with audio that motion is smoother without extra DSP latency. +- No engine code changed on this milestone; zero added sample contract preserved. Benchmark multiple editors/instances and measure CPU only from real device when available. pluginval / 150% DPI still pending. diff --git a/docs/WINDOWS-QUICKSTART.md b/docs/WINDOWS-QUICKSTART.md index 579a2c4..95cb635 100644 --- a/docs/WINDOWS-QUICKSTART.md +++ b/docs/WINDOWS-QUICKSTART.md @@ -32,3 +32,7 @@ FabFilter Pro-C is an independent benchmark for workflow/quality only. No FabFil ### New full-graph GUI acceptance Check upper central transfer graph, red fading curve and live gain reduction line, left input stereo LED meters, right GR and output stereo LEDs, and enlarged Threshold knob. Check the default/minimum/MINI screenshots from this commit, not a previous ZIP. No lookahead is present in the zero-added-sample live signal path. + +### Focused GUI revision + +The current test build opens at 900×765 instead of 1120×760. Minimum resizable size is 860×700; MINI is 380px high, and FULL restores the previous expanded dimensions. Check that all header elements fit, HP/LP and detector AUTO/EXT SC/LISTEN do not collide, and that long explanations appear in tooltips. With a running signal, verify smooth meter/GR motion against the exact audio; smoothing is UI only, with zero extra DSP samples. diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index 2f3f08d..010a894 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -4,13 +4,20 @@ #include namespace { -const juce::Colour bg{0xff0c0f11}, top{0xff171b20}, panel{0xff101317}, - line{0xff30353a}, text{0xffe5e8eb}, muted{0xffa2a8ae}, - accent{0xfffa4a58}, accentBright{0xffff6870}, green{0xff70e593}, - yellow{0xffffd661}; +const juce::Colour bg{0xff101315}, panel{0xff14191c}, + line{0xff343c41}, text{0xffe3e6e5}, muted{0xff9ea6a7}, + accent{0xffdf5860}, accentBright{0xfff4797d}, green{0xff83cfa1}, + yellow{0xffe9c978}; float clamp01(float x) noexcept { return juce::jlimit(0.0f,1.0f,x); } float dbFraction(float x) noexcept { return clamp01((x+60.0f)/60.0f); } +// Visual ballistics only: no effect on detector, gain or audio latency. +float approachVisual(float current,float target,double elapsedSeconds, + double riseSeconds,double fallSeconds) noexcept { + const double tau=target>current ? riseSeconds : fallSeconds; + const float alpha=static_cast(1.0-std::exp(-elapsedSeconds/tau)); + return current+alpha*(target-current); +} float graphY(const juce::Rectangle& p,float db) noexcept { return p.getBottom()-dbFraction(db)*p.getHeight(); } @@ -124,6 +131,22 @@ void CompLook::drawToggleButton(juce::Graphics& g,juce::ToggleButton& button, button.getHeight(),juce::Justification::centredLeft); } +void CompLook::drawTooltip(juce::Graphics& g,const juce::String& value,int w,int h) { + const auto r=juce::Rectangle(1.0f,1.0f,static_cast(w-2),static_cast(h-2)); + g.setColour(juce::Colours::black.withAlpha(0.22f)); + g.fillRoundedRectangle(r.translated(0.0f,1.0f),6.0f); + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff283037},0,0, + juce::Colour{0xff15191d},static_cast(w),static_cast(h),false)); + g.fillRoundedRectangle(r,6.0f); + g.setColour(juce::Colour{0xff5b6267}); + g.drawRoundedRectangle(r,6.0f,0.8f); + g.setColour(accent.withAlpha(0.78f)); + g.fillRoundedRectangle(7.0f,8.0f,2.0f,static_cast(std::max(4,h-16)),1.0f); + g.setColour(text); + g.setFont(juce::FontOptions(12.0f)); + g.drawFittedText(value,15,5,w-24,h-10,juce::Justification::centredLeft,3); +} + Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.snapshot()) { setLookAndFeel(&look); setOpaque(true); @@ -143,7 +166,12 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn k.setName(spec.name); k.setComponentID("param."+juce::String(spec.id)); k.setTooltip(juce::String(spec.name)+": drag to change; double click resets; type exact values."); - labels[i].setText(juce::String(spec.name).toUpperCase(),juce::dontSendNotification); + juce::String shortLabel=juce::String(spec.name).toUpperCase(); + if(i==arson::Highpass) shortLabel="HP"; + if(i==arson::Lowpass) shortLabel="LP"; + if(i==arson::Link) shortLabel="LINK"; + labels[i].setText(shortLabel,juce::dontSendNotification); + labels[i].setTooltip(juce::String(spec.name)+": adjust the compressor's "+spec.name); labels[i].setFont(juce::FontOptions(11.0f)); labels[i].setJustificationType(juce::Justification::centred); addAndMakeVisible(labels[i]); @@ -151,16 +179,19 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn attachments[i]=std::make_unique(p.state,spec.id,k); } style.addItemList({"Clean - feedforward","Feedback - classic","Smooth - dual envelope"},1); + style.setComponentID("view.model"); style.setTooltip("Three independent zero-added-sample-latency compressor models."); addAndMakeVisible(style); styleAttachment=std::make_unique( p.state,"style",style); presets.addItemList({"Default","Vocal | gentle","Vocal | level", "Mix bus | glue","Drums | punch","Podcast | steady"},1); + presets.setComponentID("view.presets"); presets.setTooltip("Choose a factory starting point; threshold depends on input level."); presets.onChange=[this] {applyPreset(presets.getSelectedId());}; addAndMakeVisible(presets); detector.addItemList({"Peak","RMS"},1); + detector.setComponentID("view.detector"); detector.setTooltip("Peak: transients; RMS: smoothed 10 ms energy, with zero lookahead."); addAndMakeVisible(detector); detectorAttachment=std::make_unique( @@ -171,8 +202,15 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn addAndMakeVisible(*toggles[i]); buttons[i]=std::make_unique(p.state,toggleIds[i],*toggles[i]); } - external.setTooltip("Requires the host to route the external sidechain."); - listen.setTooltip("Audition the detector: turn off after checking."); + autoRelease.setComponentID("view.auto"); + external.setComponentID("view.external"); + listen.setComponentID("view.listen"); + autoRelease.setButtonText("AUTO"); + external.setButtonText("EXT SC"); + listen.setButtonText("LISTEN"); + autoRelease.setTooltip("Auto Release - adapts recovery time to signal activity."); + external.setTooltip("External Sidechain - routes the host's auxiliary detector bus."); + listen.setTooltip("Listen Sidechain - audition the filtered detector signal."); compare.setTooltip("A/B snapshots apply to actual host parameters."); compare.onClick=[this] { const auto current=processor.snapshot(); @@ -242,11 +280,11 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn compactMode=!compactMode; if(compactMode) { expandedWidth=getWidth();expandedHeight=getHeight(); - setResizeLimits(960,380,1600,380); + setResizeLimits(860,380,1200,380); compact.setButtonText("FULL"); setSize(expandedWidth,380); } else { - setResizeLimits(960,670,1600,1040); + setResizeLimits(860,700,1200,965); compact.setButtonText("MINI"); setSize(expandedWidth,expandedHeight); } @@ -257,8 +295,8 @@ Editor::Editor(Processor& p):AudioProcessorEditor(p),processor(p),alternate(p.sn presets.setSelectedId(0,juce::dontSendNotification); presets.setText("Custom / restored",juce::dontSendNotification); setResizable(true,true); - setResizeLimits(960,670,1600,1040); - setSize(1120,760); + setResizeLimits(860,700,1200,965); + setSize(900,765); startTimerHz(30); } Editor::~Editor() { @@ -306,72 +344,78 @@ juce::Rectangle Editor::plotBounds() const noexcept { } void Editor::resized() { const int w=getWidth(),h=getHeight(); - compact.setBounds(194,31,52,28); - style.setBounds(257,30,177,29); - presets.setBounds(w-472,30,160,29); - savePreset.setBounds(w-304,30,50,29); - loadPreset.setBounds(w-248,30,50,29); - compare.setBounds(w-192,30,67,29); - bypass.setBounds(w-116,32,101,26); - display=compactMode?juce::Rectangle{}:juce::Rectangle{9,83,w-18,h-366}; - const int mainY=compactMode?71:display.getBottom()+7; + // Narrow portrait-weight layout: fixed utility budget + elastic control cells. + // No label or toggle is allowed to overlap its neighbor at minimum size. + compact.setBounds(166,23,47,28); + style.setBounds(220,22,146,29); + presets.setBounds(w-467,22,151,29); + savePreset.setBounds(w-308,22,47,29); + loadPreset.setBounds(w-257,22,47,29); + compare.setBounds(w-206,22,64,29); + bypass.setBounds(w-135,23,122,27); + display=compactMode?juce::Rectangle{}: + juce::Rectangle{8,73,w-16,h-333}; + const int mainY=compactMode?68:display.getBottom()+8; const int cell=(w-28)/7; - const std::array main{arson::Input,arson::Attack, + constexpr std::array main{arson::Input,arson::Attack, arson::Release,arson::Threshold,arson::Ratio,arson::Knee,arson::Makeup}; for(std::size_t k=0;k(k)*cell; - labels[i].setBounds(x,mainY+5,cell,17); - knobs[i].setBounds(x+4,mainY+20,cell-8,114); + const auto i=main[k];const int x=14+static_cast(k)*cell; + labels[i].setBounds(x,mainY+3,cell,17); + knobs[i].setBounds(x+3,mainY+20,cell-6,105); } - const int bottomY=compactMode?203:h-126; - const int small=(w-218)/6; - const std::array smallControls{arson::Range,arson::Hold, + const int bottomY=compactMode?202:h-119; + const int small=(w-245)/6; + constexpr std::array secondary{arson::Range,arson::Hold, arson::Mix,arson::Link,arson::Highpass,arson::Lowpass}; - for(std::size_t k=0;k(k)*small; - labels[i].setBounds(x,bottomY+4,small,17); - knobs[i].setBounds(x+5,bottomY+23,small-10,61); + for(std::size_t k=0;k(k)*small; + labels[i].setBounds(x,bottomY+1,small,16); + knobs[i].setBounds(x+6,bottomY+18,small-12,55); } - const int opts=w-204; - detector.setBounds(opts,bottomY+6,91,27); - autoRelease.setBounds(opts+99,bottomY+5,109,27); - external.setBounds(opts,bottomY+42,105,26); - listen.setBounds(opts+107,bottomY+42,104,26); + const int opts=w-220; + detector.setBounds(opts,bottomY+1,84,26); + autoRelease.setBounds(opts+90,bottomY+1,112,26); + external.setBounds(opts,bottomY+37,94,24); + listen.setBounds(opts+102,bottomY+37,100,24); if(compactMode){grid=juce::Image();return;} - // The graph background never depends on audio. Build it on layout changes only. + // This cache owns only immutable decoration. Animated history paths are + // separate message-thread caches rebuilt on new telemetry, not paint(). cachedCurveWidth=-1; grid=juce::Image(juce::Image::RGB,display.getWidth(),display.getHeight(),true); juce::Graphics g(grid); - const float width=static_cast(display.getWidth()),height=static_cast(display.getHeight()); + const float width=static_cast(display.getWidth()); + const float height=static_cast(display.getHeight()); g.setGradientFill(juce::ColourGradient(panel,0.0f,0.0f,bg,width,height,false)); g.fillAll(); const auto plot=plotBounds().translated(-static_cast(display.getX()), -static_cast(display.getY())); - g.setColour(juce::Colour{0xff20262b}.withAlpha(0.43f)); + g.setColour(juce::Colour{0xff20262b}.withAlpha(0.34f)); g.fillRect(plot); const float bottom=plot.getBottom(),left=plot.getX(),right=plot.getRight(); for(int db=-60;db<=0;db+=6) { const float yy=graphY(plot,static_cast(db)); - g.setColour(juce::Colour{0xff58616a}.withAlpha(db%12==0?0.24f:0.1f)); + g.setColour(juce::Colour{0xff58616a}.withAlpha(db%12==0?0.18f:0.07f)); g.drawHorizontalLine(static_cast(yy),left,right); if(db%12==0) { - g.setColour(muted.withAlpha(0.72f)); - g.setFont(juce::FontOptions(10.0f)); + g.setColour(muted.withAlpha(0.62f)); + g.setFont(juce::FontOptions(9.0f)); g.drawText(juce::String(db),static_cast(left)-37, static_cast(yy)-8,31,17,juce::Justification::centredRight); } } for(int db=-60;db<=0;db+=10) { const float xx=left+(static_cast(db+60)/60.0f)*plot.getWidth(); - g.setColour(juce::Colour{0xff64707a}.withAlpha(db%20==0?0.24f:0.11f)); + g.setColour(juce::Colour{0xff64707a}.withAlpha(db%20==0?0.18f:0.08f)); g.drawVerticalLine(static_cast(xx),plot.getY(),bottom); } - g.setColour(juce::Colour{0xff51585f}.withAlpha(0.7f)); - g.drawRect(plot,0.9f); - g.setColour(juce::Colour{0xff454b50}); + g.setColour(juce::Colour{0xff51585f}.withAlpha(0.52f)); + g.drawRect(plot,0.8f); + g.setColour(juce::Colour{0xff454b50}.withAlpha(0.75f)); g.drawVerticalLine(static_cast(left)-45,18.0f,height-20.0f); g.drawVerticalLine(static_cast(right)+12,18.0f,height-20.0f); + rebuildHistoryPaths(); } void Editor::timerCallback() { if(!isShowing())return; @@ -385,9 +429,11 @@ void Editor::timerCallback() { break; } } - arson::MeterFrame frame; float in=0,out=0,reduction=0; + arson::MeterFrame frame; + float in=0,out=0,reduction=0; std::array inPeaks{},outPeaks{}; int received=0; + // Coalesce the bounded SPSC queue exactly once per GUI tick. while(received(arson::MeterQueue::capacity) && processor.meters.pop(frame)) { history[head]=frame; @@ -397,63 +443,115 @@ void Editor::timerCallback() { out=std::max(out,frame.output); reduction=std::max(reduction,frame.reduction); currentChannels=frame.channels; - for(int i=0;i<2;++i) { - inPeaks[static_cast(i)]=std::max(inPeaks[static_cast(i)], - frame.inputChannel[static_cast(i)]); - outPeaks[static_cast(i)]=std::max(outPeaks[static_cast(i)], - frame.outputChannel[static_cast(i)]); + for(std::size_t i=0;i<2;++i) { + inPeaks[i]=std::max(inPeaks[i],frame.inputChannel[i]); + outPeaks[i]=std::max(outPeaks[i],frame.outputChannel[i]); } } - inputDb=std::max(arson::gainToDb(in),inputDb-1.2f); - outputDb=std::max(arson::gainToDb(out),outputDb-1.2f); - gr=std::max(reduction,gr-0.8f); - for(int i=0;i<2;++i) { - inChannelDb[static_cast(i)]= - std::max(arson::gainToDb(inPeaks[static_cast(i)]), - inChannelDb[static_cast(i)]-1.2f); - outChannelDb[static_cast(i)]= - std::max(arson::gainToDb(outPeaks[static_cast(i)]), - outChannelDb[static_cast(i)]-1.2f); + // Time-based visual smoothing: attack remains responsive (~18 ms) while + // falloff is calm (~210 ms). No change to real detector or DSP latency. + const double now=juce::Time::getMillisecondCounterHiRes(); + const double elapsed=lastUiTickMs>0.0 ? + std::clamp((now-lastUiTickMs)*0.001,0.008,0.120):1.0/30.0; + lastUiTickMs=now; + inputDb=approachVisual(inputDb,arson::gainToDb(in),elapsed,0.018,0.210); + outputDb=approachVisual(outputDb,arson::gainToDb(out),elapsed,0.018,0.210); + gr=approachVisual(gr,reduction,elapsed,0.022,0.185); + for(std::size_t i=0;i<2;++i) { + inChannelDb[i]=approachVisual(inChannelDb[i], + arson::gainToDb(inPeaks[i]),elapsed,0.018,0.210); + outChannelDb[i]=approachVisual(outChannelDb[i], + arson::gainToDb(outPeaks[i]),elapsed,0.018,0.210); } + if(!compactMode && received>0)rebuildHistoryPaths(); if(compactMode)repaint(14,298,getWidth()-28,57); else repaint(display); } + +void Editor::rebuildHistoryPaths() { + inputHistory.clear(); + outputHistory.clear(); + reductionHistory.clear(); + reductionArea.clear(); + const auto plot=plotBounds().translated(-static_cast(display.getX()), + -static_cast(display.getY())); + if(plot.isEmpty())return; + float inY=plot.getBottom(),outY=plot.getBottom(),grY=plot.getY(); + constexpr float inputEase=0.52f, outputEase=0.52f, grEase=0.42f; + for(std::size_t i=0;i(i)/ + static_cast(history.size()-1); + const float targetIn=graphY(plot,arson::gainToDb(f.input)); + const float targetOut=graphY(plot,arson::gainToDb(f.output)); + const float targetGr=plot.getY()+clamp01(f.reduction/30.0f)*plot.getHeight()*0.40f; + if(i==0){inY=targetIn;outY=targetOut;grY=targetGr;} + else { + inY+=(targetIn-inY)*inputEase; + outY+=(targetOut-outY)*outputEase; + grY+=(targetGr-grY)*grEase; + } + if(i==0) { + inputHistory.startNewSubPath(x,inY); + outputHistory.startNewSubPath(x,outY); + reductionHistory.startNewSubPath(x,grY); + reductionArea.startNewSubPath(x,plot.getY()); + reductionArea.lineTo(x,grY); + } else { + inputHistory.lineTo(x,inY); + outputHistory.lineTo(x,outY); + reductionHistory.lineTo(x,grY); + reductionArea.lineTo(x,grY); + } + } + reductionArea.lineTo(plot.getRight(),plot.getY()); + reductionArea.closeSubPath(); +} void Editor::paint(juce::Graphics& g) { g.fillAll(bg); - g.setGradientFill(juce::ColourGradient(juce::Colour{0xff272b30},0,0,bg,0,77,false)); - g.fillRect(0,0,getWidth(),76); - g.setColour(juce::Colour{0xff41464b}); - g.drawHorizontalLine(76,0.0f,static_cast(getWidth())); - g.setFont(juce::FontOptions(24.0f)); + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff202528}, + 0.0f,0.0f,bg,0.0f,69.0f,false)); + g.fillRect(0,0,getWidth(),68); + g.setColour(line.withAlpha(0.67f)); + g.drawHorizontalLine(68,0.0f,static_cast(getWidth())); + g.setFont(juce::FontOptions(20.5f)); g.setColour(text); - g.drawText("ArSon",18,16,93,28,juce::Justification::centredLeft); + g.drawText("ArSon",16,11,81,29,juce::Justification::centredLeft); g.setColour(accent); - g.drawText("Comp",111,16,87,28,juce::Justification::centredLeft); - g.fillRoundedRectangle(19.0f,57.0f,48.0f,2.5f,1.2f); - g.setColour(muted);g.setFont(juce::FontOptions(9.5f)); - g.drawText("LIVE DYNAMICS",77,53,121,17,juce::Justification::centredLeft); - g.drawText("MODEL",258,11,100,17,juce::Justification::left); - g.drawText("PRESET",getWidth()-472,11,130,17,juce::Justification::left); - const int mainY=compactMode?71:display.getBottom()+7; - g.setGradientFill(juce::ColourGradient(juce::Colour{0xff1c2025}, - 0,static_cast(mainY),bg,0,static_cast(mainY+170),false)); - g.fillRect(8,mainY,getWidth()-16,compactMode?133:140); - g.setColour(line.withAlpha(0.80f)); + g.drawText("Comp",89,11,71,29,juce::Justification::centredLeft); + g.fillRoundedRectangle(16.0f,49.0f,42.0f,2.0f,1.0f); + g.setColour(muted.withAlpha(0.86f)); + g.setFont(juce::FontOptions(8.7f)); + g.drawText("LIVE DYNAMICS",67,46,99,16,juce::Justification::centredLeft); + g.drawText("MODEL",221,5,90,16,juce::Justification::left); + g.drawText("PRESET",getWidth()-466,5,140,16,juce::Justification::left); + const int mainY=compactMode?68:display.getBottom()+8; + g.setGradientFill(juce::ColourGradient(juce::Colour{0xff1b2023}, + 0.0f,static_cast(mainY),bg,0.0f,static_cast(mainY+141),false)); + g.fillRect(8,mainY,getWidth()-16,132); + g.setColour(line.withAlpha(0.58f)); g.drawHorizontalLine(mainY,12.0f,static_cast(getWidth()-12)); - g.drawHorizontalLine(compactMode?197:getHeight()-126, + g.drawHorizontalLine(compactMode?198:getHeight()-123, 12.0f,static_cast(getWidth()-12)); + const int cell=(getWidth()-28)/7; + for(int i=1;i<7;++i) { + const float x=14.0f+static_cast(i*cell); + g.setColour(line.withAlpha(0.16f)); + g.drawVerticalLine(static_cast(x),static_cast(mainY+16), + static_cast(mainY+117)); + } if(!compactMode) { if(grid.isValid())g.drawImageAt(grid,display.getX(),display.getY()); - g.setColour(juce::Colour{0xff50565c}); - g.drawRoundedRectangle(display.toFloat(),5.0f,0.85f); + g.setColour(juce::Colour{0xff555d60}.withAlpha(0.62f)); + g.drawRoundedRectangle(display.toFloat(),5.0f,0.8f); drawDisplay(g); } else paintCompactMeters(g); - g.setColour(muted.withAlpha(0.75f)); - g.setFont(juce::FontOptions(9.3f)); - g.drawText("ZERO ADDED SAMPLES / ZERO LOOKAHEAD / VST3", - 16,getHeight()-18,438,14,juce::Justification::left); - g.drawText("Original real-time compressor | Drag controls / double-click reset", - getWidth()-435,getHeight()-18,420,14,juce::Justification::centredRight); + g.setColour(muted.withAlpha(0.67f)); + g.setFont(juce::FontOptions(9.0f)); + g.drawText("0 SAMPLES ADDED / VST3",14,getHeight()-19,250,15, + juce::Justification::left); + g.drawText("Drag / double-click reset / type exact values", + getWidth()-313,getHeight()-19,299,15,juce::Justification::centredRight); } void Editor::refreshTransfer(const arson::Parameters& p,juce::Rectangle plot) { const std::array key{{p[arson::Threshold],p[arson::Ratio], @@ -537,11 +635,11 @@ void Editor::drawDisplay(juce::Graphics& g) { // real response curve; the animated lines are real per-block telemetry. // The two data types never claim to share an x-axis: static transfer uses // input level on x, dynamic history uses time. - g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.23f), + g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.14f), plot.getX(),plot.getY()+plot.getHeight()*0.28f, - accent.withAlpha(0.006f),plot.getX(),plot.getBottom(),false)); + accent.withAlpha(0.005f),plot.getX(),plot.getBottom(),false)); g.fillPath(transferShade); - g.setColour(accent.withAlpha(0.17f)); + g.setColour(accent.withAlpha(0.12f)); g.strokePath(transferCurve,juce::PathStrokeType(6.0f)); g.setColour(accentBright); g.strokePath(transferCurve,juce::PathStrokeType(2.1f)); @@ -557,40 +655,18 @@ void Editor::drawDisplay(juce::Graphics& g) { g.setColour(juce::Colours::white); g.fillEllipse(mx-4.0f,my-4.0f,8.0f,8.0f); - // Only message-thread path objects; 400 fixed frames = 4 seconds at 100Hz. - juce::Path inputTrace,outputTrace,reductionTrace,reductionFill; - for(std::size_t i=0;i(i)/ - static_cast(history.size()-1); - const float inY=graphY(plot,arson::gainToDb(f.input)); - const float outY=graphY(plot,arson::gainToDb(f.output)); - const float grY=plot.getY()+clamp01(f.reduction/30.0f)*plot.getHeight()*0.40f; - if(i==0) { - inputTrace.startNewSubPath(x,inY); - outputTrace.startNewSubPath(x,outY); - reductionTrace.startNewSubPath(x,grY); - reductionFill.startNewSubPath(x,plot.getY()); - reductionFill.lineTo(x,grY); - } else { - inputTrace.lineTo(x,inY); - outputTrace.lineTo(x,outY); - reductionTrace.lineTo(x,grY); - reductionFill.lineTo(x,grY); - } - } - reductionFill.lineTo(plot.getRight(),plot.getY()); - reductionFill.closeSubPath(); - g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.20f), + // These 400-point paths are computed once when fresh telemetry arrives, + // never rebuilt by repaint or a host redraw. All buffers live on GUI. + g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.14f), plot.getX(),plot.getY(),accent.withAlpha(0.0f), plot.getX(),plot.getY()+plot.getHeight()*0.4f,false)); - g.fillPath(reductionFill); - g.setColour(juce::Colours::white.withAlpha(0.26f)); - g.strokePath(inputTrace,juce::PathStrokeType(1.15f)); - g.setColour(juce::Colour{0xffd8d9d8}.withAlpha(0.63f)); - g.strokePath(outputTrace,juce::PathStrokeType(1.15f)); - g.setColour(accentBright.withAlpha(0.94f)); - g.strokePath(reductionTrace,juce::PathStrokeType(1.7f)); + g.fillPath(reductionArea); + g.setColour(juce::Colours::white.withAlpha(0.18f)); + g.strokePath(inputHistory,juce::PathStrokeType(1.05f)); + g.setColour(juce::Colour{0xffd8d9d8}.withAlpha(0.50f)); + g.strokePath(outputHistory,juce::PathStrokeType(1.1f)); + g.setColour(accentBright.withAlpha(0.90f)); + g.strokePath(reductionHistory,juce::PathStrokeType(1.55f)); drawMeter(g,{14.0f,plot.getY(),33.0f,plot.getHeight()}, inChannelDb[0],inChannelDb[1],"IN",false); diff --git a/plugin/Editor.h b/plugin/Editor.h index 25f6a2f..62e9a1c 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -9,6 +9,7 @@ class CompLook final : public juce::LookAndFeel_V4 { void drawLinearSlider(juce::Graphics&,int,int,int,int,float,float,float, const juce::Slider::SliderStyle,juce::Slider&) override; void drawToggleButton(juce::Graphics&,juce::ToggleButton&,bool,bool) override; + void drawTooltip(juce::Graphics&,const juce::String&,int,int) override; }; class Editor final : public juce::AudioProcessorEditor, private juce::Timer { public: @@ -30,6 +31,7 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { void drawMeter(juce::Graphics&,juce::Rectangle,float,float, const juce::String&,bool); void paintCompactMeters(juce::Graphics&); + void rebuildHistoryPaths(); Processor& processor; CompLook look; juce::TooltipWindow tooltip{this,650}; @@ -47,15 +49,17 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { arson::Parameters alternate, presetSnapshot; bool alternateActive=false; bool compactMode=false,thresholdDragging=false; - int expandedWidth=1040,expandedHeight=680; + int expandedWidth=900,expandedHeight=765; std::array history{}; std::size_t head=0; float inputDb=-120,outputDb=-120,gr=0; + double lastUiTickMs=0.0; std::array inChannelDb{{-120.0f,-120.0f}},outChannelDb{{-120.0f,-120.0f}}; int currentChannels=2; juce::Rectangle display; juce::Image grid; juce::Path transferCurve,transferShade; + juce::Path inputHistory,outputHistory,reductionHistory,reductionArea; std::array cachedCurveKey{{999,999,999,999}}; float cachedCurveWidth=-1; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Editor) diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index ab71597..815379d 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -32,9 +32,9 @@ int main(int argc,char** argv) { std::unique_ptr editor(processor.createEditor()); if(!editor->findChildWithID("preset.save") || !editor->findChildWithID("preset.load")) return 18; - editor->setSize(iteration%2 ? 960 : 1120,iteration%2 ? 670 : 760); - if(editor->getWidth()!=(iteration%2 ? 960 : 1120) || - editor->getHeight()!=(iteration%2 ? 670 : 760))return 9; + editor->setSize(iteration%2 ? 860 : 900,iteration%2 ? 700 : 765); + if(editor->getWidth()!=(iteration%2 ? 860 : 900) || + editor->getHeight()!=(iteration%2 ? 700 : 765))return 9; const auto* threshold=editor->findChildWithID("param.threshold"); const auto* input=editor->findChildWithID("param.input"); const auto* ratio=editor->findChildWithID("param.ratio"); @@ -43,6 +43,31 @@ int main(int argc,char** argv) { !(input->getX()getX() && attack->getX()getX() && threshold->getX()getX()))return 19; if(threshold->getBounds().intersects(ratio->getBounds()))return 20; + // Enforce responsive layout invariants at both default and minimum. + // This fails CI before a clipped/colliding UI ships to Windows users. + const auto* hp=editor->findChildWithID("param.highpass"); + const auto* lp=editor->findChildWithID("param.lowpass"); + const auto* detector=editor->findChildWithID("view.detector"); + const auto* autoMode=editor->findChildWithID("view.auto"); + const auto* external=editor->findChildWithID("view.external"); + const auto* listen=editor->findChildWithID("view.listen"); + const auto* style=editor->findChildWithID("view.model"); + const auto* presets=editor->findChildWithID("view.presets"); + const auto* save=editor->findChildWithID("preset.save"); + const auto* load=editor->findChildWithID("preset.load"); + if(!hp||!lp||!detector||!autoMode||!external||!listen|| + !style||!presets||!save||!load)return 21; + if(lp->getRight()>detector->getX() || + detector->getBounds().intersects(autoMode->getBounds()) || + external->getBounds().intersects(listen->getBounds()) || + style->getBounds().intersects(presets->getBounds()) || + presets->getBounds().intersects(save->getBounds()) || + save->getBounds().intersects(load->getBounds()))return 22; + for(const auto* widget : {threshold,input,ratio,attack,hp,lp,detector, + autoMode,external,listen,style,presets,save,load}) { + if(widget->getX()<0 || widget->getRight()>editor->getWidth() || + widget->getY()<0 || widget->getBottom()>editor->getHeight())return 23; + } editor->addToDesktop(0); editor->setVisible(true); for(int j=0;j<1500;++j) { for(int i=0;i<128;++i) { @@ -71,7 +96,7 @@ int main(int argc,char** argv) { if(!stream || !juce::PNGImageFormat{}.writeImageToStream(compactImage,*stream))return 13; } mini->onClick(); - if(editor->getHeight()!=760)return 14; + if(editor->getHeight()!=765)return 14; } auto image=editor->createComponentSnapshot(editor->getLocalBounds()); if(image.isNull())return 3; From 8e7432c68611c52265304db38926f5c3711b310c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 08:16:28 +0700 Subject: [PATCH 11/35] Milestone: two-sided graph dissolve, cached LED rails and raster fade regression --- README.md | 8 +++++ docs/ARD.md | 6 ++++ docs/HANDOFF.md | 6 ++++ docs/VALIDATION.md | 8 +++++ docs/WINDOWS-QUICKSTART.md | 4 +++ plugin/Editor.cpp | 70 ++++++++++++++++++++++---------------- plugin/Editor.h | 3 ++ plugin/GraphPaint.h | 44 ++++++++++++++++++++++++ tests/PluginSmoke.cpp | 32 +++++++++++++++++ 9 files changed, 152 insertions(+), 29 deletions(-) create mode 100644 plugin/GraphPaint.h diff --git a/README.md b/README.md index a5bed96..f5672e6 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,11 @@ The newly redesigned UI uses the user-supplied ArSonComp mockup as a layout acce The 900x765 default layout replaces the earlier 1120x760 wide editor. Minimum 860x700; the optional 380px MINI/FULL mode retains all audio controls. Header, secondary sliders and toggles now use fixed-reserved regions and short labels such as HP/LP/LINK/EXT SC, with detailed dark contextual tooltips. The full graph is closer to square and remains the hero element. JUCE paint maintains a muted graphite/coral palette with a single enlarged Threshold. The GUI timer coalesces 100 Hz telemetry at 30 Hz and applies time-normalized attack/release easing only to the **display**, not audio. Input/output and actual GR history use a persistent fixed 400-frame ring buffer, with Path objects rebuilt only on new telemetry or layout change; any UI repaint simply strokes cached paths. Static grid remains cached per resize and transfer curve geometry only rebuilds when its parameters/size change. No new DSP latency, audio-thread worker, lock, heap use or lookahead. + +## 2026-10-31: professional graph-edge dissolve and LED render budget + +The animated input, output and gain-reduction traces now dissolve on **both horizontal edges**, transitioning from transparent to full brightness by 13.5% of graph width, staying clear until 86.5%, then fading smoothly out. The static transfer curve and its subtle glow use a lower, still visible edge alpha to preserve reading/control affordance. All gradients reuse the same RGB across their stops (avoids muddy fades); the GR activity fill also fades horizontally. + +Six four-stop `juce::ColourGradient` brushes are computed only during `resized()` and reused during repaint. The 46-segment **unlit** stereo IN / GR / OUT meter rails now live in the cached static background; `drawMeter()` only draws genuinely **lit** segments and live text. The existing fixed 400-frame history Path cache, 30 Hz paint cadence and SPSC audio telemetry remain in place. No lookahead, worker, heap allocation or lock is introduced in audio processing. JUCE graphics/GUI remains message-thread only. + +CI smoke checks numerical alpha symmetry, endpoint/centre contrast and actual ARGB rasterized fade, plus the existing preset round-trip, layout collision, multi-editor and zero-added-sample tests. Use the current CI artifact's Standalone or VST3 to evaluate smoothness and both-line-edge treatment on a physical Windows audio device. diff --git a/docs/ARD.md b/docs/ARD.md index 871879d..5b5aa16 100644 --- a/docs/ARD.md +++ b/docs/ARD.md @@ -37,3 +37,9 @@ Pro-C-specific styles, mid/side compression, frequency-dependent linking, auto m GUI target: **900x765 default; 860x700 min; 380px MINI**, instead of 1120x760. Header reserves safe widths for logo, MINI, model, preset, SAVE, OPEN, A/B and bypass. Main row contains exactly 7 knobs with larger Threshold. Secondary row computes 6 bounded strips plus fixed right-side space for detector and three shortened flags; labels keep full descriptions in dark custom JUCE tooltips. Geometric overlap and bounds are asserted by plugin smoke at default/min sizes, including MINI/FULL restoration. GUI drawing pipeline: `resized` caches graph background and regenerates path geometry for the new size; `timerCallback` drains SPSC 100 Hz samples once then computes time-compensated meter display easing (18ms rise/210ms fall, 22ms GR rise/185ms fall); when new frames arrive, it computes and reuses four 400-point paths for the time history with lightweight visual one-pole smoothing. `drawDisplay` only strokes existing time paths, cached transfer curve and segmented LED meters at 30 Hz, with dirty-region repaint. This removes repeated per-paint conversion/path-building for ~1200 dB point calculations. All smoothing affects presentation alone; DSP has unchanged zero added algorithmic samples. If editor is hidden, timer skips heavy visualization updates; reopening drains and paints the bounded queue. + +## Edge-fade brush cache and meter rails + +`plugin/GraphPaint.h` keeps a single composable, GUI-only four-stop horizontal colour gradient helper and reusable meter-rail painting function. The colour stops at x=0 (0% opacity), 13.5% (full), 86.5% (full) and x=100% (0%) apply to live IN / OUT / GR strokes, without a postprocessing blur or offscreen layer. Transfer law keeps ~18% edge brightness to remain visually recognizable at the graph boundaries. The actual centre segment is unchanged and continues to display measured telemetry. Dither/traces are not fabricated. + +`Editor::resized` caches six gradients and the 46-segment dark LED rails into the existing graph background, then `drawDisplay` only composites the cached paths using gradient strokes and draws active segments on top. This eliminates ~5×46 inactive-rectangle paints per 30Hz GUI frame and avoids allocating new gradient stop arrays on every paint. The waveform paths are rebuilt only on new telemetry/resize; gain reduction and static transfer DSP logic are untouched. All objects remain message-thread-owned. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index ceef7fa..7573d31 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -19,3 +19,9 @@ The supplied red ArSonComp mockup is now the acceptance layout for a full-width ## Focused-layout milestone handoff The full reference GUI in commit f63e8c6 passed Windows/Linux CI, but user feedback on actual screenshot showed it was too wide and secondary controls were crowded. The new grouped follow-up moves to 900x765 default (860x700 minimum), shortens secondary labels with tooltip help, reflows all header/buttons/slider regions and adds smoke collision bounds tests. It also caches 400-point signal/GR Path objects between actual telemetry updates and applies UI-only time-based meter easing. Do not move easing onto the audio callback or add Lookahead. Review default/minimum/MINI Windows screenshots before release; host/pluginval/real device tests remain outstanding. + +## Edge dissolve and physical-test handoff + +The latest grouped GUI milestone applies symmetric horizontal transparency fades to input/output/GR history and keeps the transfer curve readable with a lower-opacity edge; cache the six gradient brushes and meter rails on resize. The new `GraphPaint.h` helper is GUI-only; numerical and ARGB rasterizer smoke asserts actual fades. Meter-active segments are rendered at 30Hz over pre-rendered inactive rails; do not recreate LED background rectangles every frame. There must be **no** DSP engine changes or new audio-thread visual work. + +Build and visually inspect 900x765 default, 860x700 minimum and MINI 380 screenshots in the Windows Actions artifact before distributing. Verify live rendering on the user's real Windows host/ASIO interface and DAW/ArSonMiX, check visual motion and actual CPU usage, channel independence, host automation, and session reopen. Running an editor smoke in CI does not replace a physical-device validation. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 85d0246..9291778 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -29,3 +29,11 @@ Verify default 1120x760, minimum 960x670 and compact 380px Windows screenshot ge - Screenshot visual review: graph aspect and central prominence, legible 6 dB grid, restrained coral dissolving fill, stereo LED meters, large Threshold, full/mini readability. - UI 30 Hz timing and 100 Hz bounded queue; time-based meter easing only on GUI; fixed ring history paths reused across paints and recomputed only for new telemetry or resize. Confirm on host with audio that motion is smoother without extra DSP latency. - No engine code changed on this milestone; zero added sample contract preserved. Benchmark multiple editors/instances and measure CPU only from real device when available. pluginval / 150% DPI still pending. + +## Graph-edge dissolve — required validation + +- JUCE `ColourGradient::addColour` four-stop alpha unit test: transparent endpoints, full centre, mirror-like left/right falloffs; transfer retains nonzero edge alpha for readability. +- Raster test: draw line using real JUCE ARGB `Graphics`, check centre alpha > 0.70 and both edge samples < 35% of centre; no bitmap masks or CPU blur. +- Assert full/minimum/MINI editor snapshots, preset save/reload, automation ID stability, no overlap and independent stereo metering via existing tests. +- Static segmented meter rails cached in resized image; repaint draws **only active** segments plus labels/values. Confirm no off-bars ghosting with host running then stopping and resizing. +- No engine changes: existing Linux sanitizer suite proves zero additional DSP samples, bounded SPSC and no audio-thread allocation. Pending real-device CPU/latency/pluginval and 150% DPI. diff --git a/docs/WINDOWS-QUICKSTART.md b/docs/WINDOWS-QUICKSTART.md index 95cb635..00d1d8e 100644 --- a/docs/WINDOWS-QUICKSTART.md +++ b/docs/WINDOWS-QUICKSTART.md @@ -36,3 +36,7 @@ Check upper central transfer graph, red fading curve and live gain reduction lin ### Focused GUI revision The current test build opens at 900×765 instead of 1120×760. Minimum resizable size is 860×700; MINI is 380px high, and FULL restores the previous expanded dimensions. Check that all header elements fit, HP/LP and detector AUTO/EXT SC/LISTEN do not collide, and that long explanations appear in tooltips. With a running signal, verify smooth meter/GR motion against the exact audio; smoothing is UI only, with zero extra DSP samples. + +### Two-sided dissolve, low-cost LED metering + +Use the Standalone EXE or VST3 from the **latest** matching Windows Actions artifact. With audio playing, confirm the red gain-reduction trace and gray input/output traces disappear gradually at **both ends** of the dynamics graph without abrupt vertical cutoffs, while remaining crisp in the middle. The curve marker and compressor settings must still work as before. Confirm meters decay smoothly and their unlit segments are visible at all levels. Graph rendering is GUI-only, with no lookahead or additional algorithmic audio samples. Measure CPU and crackles in your own host/driver at 32/64/128 sample buffers rather than treating CI synthetic numbers as real-device measurements. diff --git a/plugin/Editor.cpp b/plugin/Editor.cpp index 010a894..4561999 100644 --- a/plugin/Editor.cpp +++ b/plugin/Editor.cpp @@ -1,5 +1,6 @@ #include "Editor.h" #include "PresetIO.h" +#include "GraphPaint.h" #include #include @@ -415,6 +416,20 @@ void Editor::resized() { g.setColour(juce::Colour{0xff454b50}.withAlpha(0.75f)); g.drawVerticalLine(static_cast(left)-45,18.0f,height-20.0f); g.drawVerticalLine(static_cast(right)+12,18.0f,height-20.0f); + // Fully reusable gradient stops; preserve transfer readability at + // near-silent endpoints while moving traces dissolve to transparent. + const float x0=plot.getX(),x1=plot.getRight(); + edgeFades[0]=arson::ui::makeEdgeFade(juce::Colours::white,x0,x1,0.19f); + edgeFades[1]=arson::ui::makeEdgeFade(juce::Colour{0xffd8d9d8},x0,x1,0.52f); + edgeFades[2]=arson::ui::makeEdgeFade(accentBright,x0,x1,0.91f); + edgeFades[3]=arson::ui::makeEdgeFade(accentBright,x0,x1,0.97f,0.18f); + edgeFades[4]=arson::ui::makeEdgeFade(accent,x0,x1,0.14f,0.10f); + edgeFades[5]=arson::ui::makeEdgeFade(accent,x0,x1,0.105f); + // Pre-rasterize inactive LED rails once with grid; runtime paints + // active segments only, avoiding ~230 inactive rect draws per frame. + arson::ui::paintMeterRail(g,{14.0f,plot.getY(),33.0f,plot.getHeight()},false); + arson::ui::paintMeterRail(g,{width-110.0f,plot.getY(),34.0f,plot.getHeight()},true); + arson::ui::paintMeterRail(g,{width-61.0f,plot.getY(),42.0f,plot.getHeight()},false); rebuildHistoryPaths(); } void Editor::timerCallback() { @@ -579,34 +594,33 @@ void Editor::drawMeter(juce::Graphics& g,juce::Rectangle bounds, g.setFont(juce::FontOptions(10.0f)); g.drawText(title,static_cast(x)-3,static_cast(y)-22, static_cast(bounds.getWidth())+6,18,juce::Justification::centred); - const int bars=(gainReduction || currentChannels==1)?1:2; + // Cached dark LED rails are already part of Editor::grid. + // Draw only the illuminated pixels, no 46x redraw of dark segments. + const int bars=gainReduction?1:2; const float bw=bars==1?13.0f:9.0f; const float spacing=3.0f; const float total=bw*bars+spacing*(bars-1); const float start=x+(bounds.getWidth()-total)*0.5f; + constexpr int segments=46; + const float segmentH=h/static_cast(segments); for(int c=0;c(std::ceil(fraction*static_cast(segments)))); const float bx=start+c*(bw+spacing); - g.setColour(juce::Colour{0xff20262a}); - g.fillRect(bx,y,bw,h); - constexpr int segments=46; - const float sh=h/static_cast(segments); - for(int step=0;step(step+1)/segments; - const float sy=gainReduction?y+step*sh:y+h-(step+1)*sh; - if(fraction<=fill) { - juce::Colour color; - if(gainReduction)color=accent; - else if(fraction>0.90f)color=juce::Colour{0xffff5c63}; - else if(fraction>0.71f)color=yellow; - else color=green; - g.setColour(color); - } else g.setColour(juce::Colour{0xff313637}.withAlpha(0.52f)); - g.fillRect(bx,sy,bw,std::max(1.0f,sh-1.2f)); + for(int step=0;step(step+1)/segments>0.90f? + juce::Colour{0xffff5c63}: + (static_cast(step+1)/segments>0.71f? + yellow:green)); + g.setColour(colour); + g.fillRect(bx,yy,bw,std::max(1.0f,segmentH-1.2f)); } - g.setColour(juce::Colour{0xff535b60}); - g.drawRect(bx-1.0f,y-1.0f,bw+2,h+2,0.7f); } g.setFont(juce::FontOptions(11.0f)); g.setColour(text); @@ -639,9 +653,9 @@ void Editor::drawDisplay(juce::Graphics& g) { plot.getX(),plot.getY()+plot.getHeight()*0.28f, accent.withAlpha(0.005f),plot.getX(),plot.getBottom(),false)); g.fillPath(transferShade); - g.setColour(accent.withAlpha(0.12f)); + g.setGradientFill(edgeFades[4]); g.strokePath(transferCurve,juce::PathStrokeType(6.0f)); - g.setColour(accentBright); + g.setGradientFill(edgeFades[3]); g.strokePath(transferCurve,juce::PathStrokeType(2.1f)); const float mx=plot.getX()+dbFraction(p[arson::Threshold])*plot.getWidth(); @@ -657,15 +671,13 @@ void Editor::drawDisplay(juce::Graphics& g) { // These 400-point paths are computed once when fresh telemetry arrives, // never rebuilt by repaint or a host redraw. All buffers live on GUI. - g.setGradientFill(juce::ColourGradient(accent.withAlpha(0.14f), - plot.getX(),plot.getY(),accent.withAlpha(0.0f), - plot.getX(),plot.getY()+plot.getHeight()*0.4f,false)); + g.setGradientFill(edgeFades[5]); g.fillPath(reductionArea); - g.setColour(juce::Colours::white.withAlpha(0.18f)); + g.setGradientFill(edgeFades[0]); g.strokePath(inputHistory,juce::PathStrokeType(1.05f)); - g.setColour(juce::Colour{0xffd8d9d8}.withAlpha(0.50f)); + g.setGradientFill(edgeFades[1]); g.strokePath(outputHistory,juce::PathStrokeType(1.1f)); - g.setColour(accentBright.withAlpha(0.90f)); + g.setGradientFill(edgeFades[2]); g.strokePath(reductionHistory,juce::PathStrokeType(1.55f)); drawMeter(g,{14.0f,plot.getY(),33.0f,plot.getHeight()}, diff --git a/plugin/Editor.h b/plugin/Editor.h index 62e9a1c..02839dd 100644 --- a/plugin/Editor.h +++ b/plugin/Editor.h @@ -60,6 +60,9 @@ class Editor final : public juce::AudioProcessorEditor, private juce::Timer { juce::Image grid; juce::Path transferCurve,transferShade; juce::Path inputHistory,outputHistory,reductionHistory,reductionArea; + // Six cached horizontal gradient brushes: input, output, GR, transfer, + // transfer glow and reduction-area fade. Built only on full-view resize. + std::array edgeFades; std::array cachedCurveKey{{999,999,999,999}}; float cachedCurveWidth=-1; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Editor) diff --git a/plugin/GraphPaint.h b/plugin/GraphPaint.h new file mode 100644 index 0000000..0fe0547 --- /dev/null +++ b/plugin/GraphPaint.h @@ -0,0 +1,44 @@ +#pragma once +#include +#include + +namespace arson::ui { +// A four-stop horizontal opacity envelope. Same RGB at every stop avoids +// muddy colour mixing, and keeps line edges organically dissolved. +// Only called on the message thread on component resize, never during audio. +inline juce::ColourGradient makeEdgeFade(juce::Colour colour,float x0,float x1, + float opacity,float edgeOpacity=0.0f) { + const float visible=juce::jlimit(0.0f,1.0f,opacity); + const float edge=visible*juce::jlimit(0.0f,1.0f,edgeOpacity); + juce::ColourGradient gradient(colour.withAlpha(edge),x0,0.0f, + colour.withAlpha(edge),x1,0.0f,false); + gradient.addColour(0.135,colour.withAlpha(visible)); + gradient.addColour(0.865,colour.withAlpha(visible)); + return gradient; +} + +// Static segmented meter rails go in Editor's cached grid image, not its +// 30Hz paint path. Active LEDs alone are painted over the rails at runtime. +inline void paintMeterRail(juce::Graphics& g,juce::Rectangle bounds, + bool gainReduction) { + const int bars=gainReduction?1:2; + const float bw=bars==1?13.0f:9.0f; + const float spacing=3.0f, total=bw*bars+spacing*(bars-1); + const float start=bounds.getX()+(bounds.getWidth()-total)*0.5f; + constexpr int segments=46; + const float segmentH=bounds.getHeight()/static_cast(segments); + for(int channel=0;channel #include int main(int argc,char** argv) { juce::ScopedJuceInitialiser_GUI gui; + // Quantitative edge-dissolve contract: endpoints transparent, the + // central ~73% clearly visible, symmetric fades and stable RGB. + { + const auto coral=juce::Colour{0xffdf5860}; + const auto fade=arson::ui::makeEdgeFade(coral,0.0f,239.0f,0.9f); + if(fade.getNumColours()!=4 || + fade.getColourAtPosition(0.0).getFloatAlpha()>0.01f || + fade.getColourAtPosition(1.0).getFloatAlpha()>0.01f || + fade.getColourAtPosition(0.5).getFloatAlpha()<0.88f || + fade.getColourAtPosition(0.02).getFloatAlpha()>= + fade.getColourAtPosition(0.10).getFloatAlpha() || + std::abs(fade.getColourAtPosition(0.07).getFloatAlpha()- + fade.getColourAtPosition(0.93).getFloatAlpha())>0.02f) + return 24; + const auto transfer=arson::ui::makeEdgeFade(coral,0.0f,239.0f,1.0f,0.18f); + if(transfer.getColourAtPosition(0.0).getFloatAlpha()<0.17f || + transfer.getColourAtPosition(0.50).getFloatAlpha()<0.99f) + return 25; + + // Actual software rasterizer output: no hidden bitmap, no blur, + // and both ends less bright than the middle in a real ARGB image. + juce::Image canvas(juce::Image::ARGB,240,16,true); + juce::Graphics graph(canvas); + graph.setGradientFill(fade); + graph.drawLine(0.0f,8.0f,239.0f,8.0f,2.0f); + const float left=canvas.getPixelAt(5,8).getFloatAlpha(); + const float centre=canvas.getPixelAt(120,8).getFloatAlpha(); + const float right=canvas.getPixelAt(234,8).getFloatAlpha(); + if(!(centre>0.7f && leftsetValueNotifyingHost(parameter->convertTo0to1(-27)); From 52c00f90ad589eedc2a4df35a78055e0721b2cd0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 08:25:11 +0700 Subject: [PATCH 12/35] Fix platform-specific fade smoke rasterization and expose alpha diagnostics --- tests/PluginSmoke.cpp | 44 +++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/tests/PluginSmoke.cpp b/tests/PluginSmoke.cpp index c56be41..aa453b5 100644 --- a/tests/PluginSmoke.cpp +++ b/tests/PluginSmoke.cpp @@ -10,31 +10,47 @@ int main(int argc,char** argv) { { const auto coral=juce::Colour{0xffdf5860}; const auto fade=arson::ui::makeEdgeFade(coral,0.0f,239.0f,0.9f); - if(fade.getNumColours()!=4 || - fade.getColourAtPosition(0.0).getFloatAlpha()>0.01f || - fade.getColourAtPosition(1.0).getFloatAlpha()>0.01f || - fade.getColourAtPosition(0.5).getFloatAlpha()<0.88f || - fade.getColourAtPosition(0.02).getFloatAlpha()>= - fade.getColourAtPosition(0.10).getFloatAlpha() || - std::abs(fade.getColourAtPosition(0.07).getFloatAlpha()- - fade.getColourAtPosition(0.93).getFloatAlpha())>0.02f) + const float head=fade.getColourAtPosition(0.0).getFloatAlpha(); + const float tail=fade.getColourAtPosition(1.0).getFloatAlpha(); + const float middle=fade.getColourAtPosition(0.5).getFloatAlpha(); + const float nearStart=fade.getColourAtPosition(0.02).getFloatAlpha(); + const float innerStart=fade.getColourAtPosition(0.10).getFloatAlpha(); + const float mirrorStart=fade.getColourAtPosition(0.07).getFloatAlpha(); + const float mirrorEnd=fade.getColourAtPosition(0.93).getFloatAlpha(); + if(fade.getNumColours()!=4 || head>0.015f || tail>0.015f || + middle<0.85f || nearStart>=innerStart || + std::abs(mirrorStart-mirrorEnd)>0.035f) { + std::cerr<<"edge-stop test: count="<