feat: legible ReaSampler 9000 editor — bigger knobs, ms time constants, per-ring double-click reset, and an antialiased draw pass
This commit is contained in:
@@ -11,7 +11,7 @@ The pure engine/geometry core this shell wraps (`sampler_core`, `pitch_shift`,
|
||||
`sample_map`, `component_state_io`, `play_params.h`, `editor_geometry`, `sample_bands`,
|
||||
`sample_chrome`, `keyboard_strip`, `waveform_view`, `capture_browser`, `browser_scroll`,
|
||||
`param_slider`, `trigger_seam`, `velocity_curve`, `embed_strip`, `knob_deck`,
|
||||
`deck_groups`, `curve_popup`, `spline_edit`, `master_gain`, `reasampler_uid.h`) lives in `core/instrument/*` and
|
||||
`deck_groups`, `deck_values`, `curve_popup`, `spline_edit`, `master_gain`, `reasampler_uid.h`) lives in `core/instrument/*` and
|
||||
`core/wire` and is documented there — this directory consumes it but does not own it.
|
||||
|
||||
## Invariants
|
||||
@@ -101,7 +101,7 @@ declared ahead of the instrument slots at that member in `reasampler_processor.h
|
||||
|
||||
- `reaper_bridge` — READ-ONLY bank consumer: receives bank snapshots from the extension and exposes them as a read-only view. **Never writes to the extension's bank** — this is a load-bearing invariant; no mutation path exists in this module. **pS-usage:** gains `writeUsageExtState` (prefix-guarded — accepts only `rsusage_`-prefixed keys, refuses all others) so the processor can publish usage without weakening the read-only-bank invariant.
|
||||
- `reasampler_processor` (`shell/instrument/`: `reasampler_processor.cpp` lifecycle + `process()`, `processor_state.cpp` component-state I/O + UI-thread parameter accessors, `processor_reload.cpp` the off-audio-thread `reloadInstrument`/publish family — Q-W2v, T4-12 split; `process()` and its per-block work stay ONE TU on purpose, no cross-TU call on the per-sample path) — VST3 `SingleComponentEffect` shell: declares event-input bus + **permanently stereo** output (GA fix: dynamic mono↔stereo bus renegotiation deleted; `ChannelMode` is now decode-only), marshals MIDI note-on/off into the VoiceEngine, renders audio; owns off-audio-thread `reloadInstrument` + atomic pointer swap so `process()` does no allocation, no file I/O, no bridge calls. The instance state is `{loaded capture id, one InstrumentParams}`, and `reloadInstrument` resolves + decodes exactly that one capture into the `SampleData` the engine plays. **Self-contained playback (pS):** `ComponentState` v10 adds a `SampleRefs` table — per referenced sample, a project-relative path + decode intrinsics (root, loop, channels, displayName); `reloadInstrument` decodes directly from `SampleRefs`, bank-free (plays with the extension absent). The bank/bridge is a browser source: loading a capture copies its reference in; the reopen-heal timer + poll-to-play apparatus are removed. `retireIdleDrain()` retires fully-idle drain snapshots on the UI-timer cadence. Voice-param edits (`setVoiceCount`/`setVoiceMode`/`setMonoTrigger`) rebuild the engine from the already-decoded `SampleData` via the drain-slot swap — no bank re-read, no WAV re-decode, no audible cut to ringing tails. **FB1:** applies the post-mixer `masterGainLinear` (from `ComponentState` v8) as a per-sample ramp over the summed output — no zipper noise. **GA v9:** `channelModeExplicit_` flag persisted; `channelModeFor()` auto-defaults the mode from the loaded capture's channel count when the flag is not set. **pS:** `ComponentState` bumped v9→v10 (`SampleRefs` table); pre-v10 blobs lift to empty refs and re-save self-contained. **pS-usage:** publishes instance usage (held `SampleRefs` paths) to `rsusage_<instanceGuid>` at the tail of `reloadInstrument` (off audio thread) via `reaper_bridge::writeUsageExtState`; `ComponentState` bumped v10→**v11** (`instanceGuid` field); pre-v11 blobs mint guid on first publish.
|
||||
- `reasampler_editor` — VST3 `IPlugView` LICE editor shell: hosts a LICE-drawn child window; the Sample face is home and Browse is a modal picker over it. Split on the Sample face's BAND axis, mirroring the pure `sample_bands` allocator: `editor_session` (session/bridge state, caches, commit-and-reload), `editor_controls` (the control-value domain maps + the node-drag bounds that must match them, plus the ONE `faceLayout` band resolve every paint and hit-test path shares), `editor_models` (the orthogonal half: which stored struct each transient editor selection names — the staged-envelope pack/unpack, the drawn contour, and the three velocity curves), then matching paint and input sets — `editor_paint`/`editor_input` (dispatch + drag router + hover dispatch), `_chrome`, `_waveform`, `_deck` — plus the two band-independent surfaces (`_browse` for the modal picker, `_curve` for the velocity-curve popup) and `editor_platform` (IPlugView/Win32 window plumbing). Shared internals in `editor_internal.h`, no TU of its own. Drop-onto-editor ingest is NOT shipped (deferred).
|
||||
- `reasampler_editor` — VST3 `IPlugView` LICE editor shell: hosts a LICE-drawn child window; the Sample face is home and Browse is a modal picker over it. Split on the Sample face's BAND axis, mirroring the pure `sample_bands` allocator: `editor_session` (session/bridge state, caches, commit-and-reload), `editor_controls` (the ONE `faceLayout` band resolve every paint and hit-test path shares, the node-drag bounds, the value labels, and the per-instance controls the parameter set does not carry — the parameter-set binding itself is the pure `core/instrument/ui/deck_values` module this only adapts int ids onto), `editor_models` (the orthogonal half: which stored struct each transient editor selection names — the staged-envelope pack/unpack, the drawn contour, and the three velocity curves), then matching paint and input sets — `editor_paint`/`editor_input` (dispatch + drag router + hover dispatch), `_chrome`, `_waveform`, `_deck` — plus the two band-independent surfaces (`_browse` for the modal picker, `_curve` for the velocity-curve popup) and `editor_platform` (IPlugView/Win32 window plumbing). Shared internals in `editor_internal.h`, no TU of its own. Drop-onto-editor ingest is NOT shipped (deferred).
|
||||
- `reasampler_embed` — implements `IReaperUIEmbedInterface` so the instrument draws inline in the TCP/MCP without a plugin-owned HWND; delegates layout to `embed_strip`. A read-only readout: the loaded capture across the keyboard span with its root marked, plus the activity level. It takes no mouse input (there is nothing on the strip to select).
|
||||
- `vst_entry` — VST3 entry point: `GetPluginFactory` export, class registration, channel-forked class UIDs.
|
||||
- `editor_internal.h` — INTERNAL shared helpers for the `reasampler_editor` TU family, included only by the editor's own shell TUs (`editor_session` / `editor_controls` / `editor_paint_*` / `editor_input_*` / `editor_platform`), never a public seam: the `Rect`↔kit adapters, small draw primitives (knob face / title band), label helpers, and the velocity-curve box derivation — the helpers more than one band TU needs. The deck's control ids, group ids and group composition are the pure `deck_groups` module's, not this file's. The piano-strip and root-key draws live in `editor_paint_chrome`, their only consumer, not here.
|
||||
@@ -111,6 +111,11 @@ declared ahead of the instrument slots at that member in `reasampler_processor.h
|
||||
|
||||
- `editor_internal.h` is include-only — it has no TU of its own and must never become
|
||||
a public seam; only the `reasampler_editor` band-axis TUs include it.
|
||||
- **The editor window class carries `CS_DBLCLKS`, which REPLACES the second button-down of
|
||||
a double-click** with `WM_?BUTTONDBLCLK`. Every surface that counts two downs — Browse's
|
||||
load accelerator, the spline surfaces' right-click delete — survives only because both
|
||||
DBLCLK handlers fall through to the ordinary down handler. Adding a new double-click
|
||||
consumer means preserving that fall-through, not bypassing it.
|
||||
- The two VST3 class UIDs (`core/wire/reasampler_uid.h`, consumed via
|
||||
`reasampler_vst.h`) are FOREVER-FROZEN — never regenerate an already-shipped UID.
|
||||
- The UID selection `#ifdef` in `reasampler_vst.h` is the one deliberate exception to
|
||||
|
||||
@@ -86,7 +86,8 @@ if(WIN32 AND EXISTS "${VST3_SDK}/public.sdk/source/main/pluginfactory.cpp")
|
||||
capture_browser keyboard_strip sample_bands sample_chrome
|
||||
waveform_view bank_sync browser_scroll param_slider tooltip
|
||||
theme component_geometry bank_grid trigger_seam envelope_overlay envelope_edit
|
||||
knob_deck deck_groups curve_popup spline_edit master_gain sample_usage file_bytes curve_law)
|
||||
knob_deck deck_groups deck_values curve_popup spline_edit master_gain sample_usage
|
||||
file_bytes curve_law)
|
||||
# SDK_INC gives the REAPER VST3 interfaces + API header for the bridge; WDL_INC gives
|
||||
# LICE for the editor. The VST3 SDK headers arrive via vst3_sdk PUBLIC.
|
||||
target_include_directories(reasampler_vst PRIVATE ${REASAMPLER_SRC_DIR} ${SDK_INC} ${WDL_INC})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// editor_controls.cpp — the ReaSamplerEditor's parameter plumbing: the band-stack layout
|
||||
// resolve every paint/hit-test path shares, the control-value domain maps (controlValue /
|
||||
// applyControl — seconds/fraction/frames <-> normalized 0..1), the control-id<->value binding
|
||||
// against the pure `deck_groups` module's descriptors, and the node-drag clamp bounds that must
|
||||
// match those domains. The orthogonal half — which stored struct each editor selection names —
|
||||
// is editor_models. Value logic only: no painting, no window plumbing.
|
||||
// resolve every paint/hit-test path shares, the shell's half of the control-value binding (the
|
||||
// per-instance controls the parameter set does not carry — key-track, voice count, master gain,
|
||||
// preview velocity — plus the value labels), and the node-drag clamp bounds. The parameter-set
|
||||
// half is the pure `deck_values` module. The orthogonal half — which stored struct each editor
|
||||
// selection names — is editor_models. Value logic only: no painting, no window plumbing.
|
||||
|
||||
#include "shell/instrument/reasampler_editor.h"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "core/instrument/engine/filter/filter_params.h" // the filter's own control laws
|
||||
#include "core/instrument/engine/master_gain.h" // master-gain dB<->linear<->knob taper
|
||||
#include "core/instrument/ui/deck_groups.h" // sampleDeckGroups (the deck's composition)
|
||||
#include "core/instrument/ui/deck_values.h" // the parameter-set binding + its ms units
|
||||
#include "core/instrument/ui/knob_deck.h" // deckHeight / kDeckKnobSize (the band's own height)
|
||||
#include "core/util/clamp01.h"
|
||||
#include "core/util/curve_law.h" // the ONE curve-exponent domain
|
||||
@@ -30,32 +31,22 @@ using instrument::ui::chromeRects;
|
||||
using instrument::ui::deckHeight;
|
||||
using instrument::ui::kDeckKnobSize;
|
||||
using instrument::ui::kPad;
|
||||
using instrument::ui::deckBipolarFromNorm;
|
||||
using instrument::ui::deckNormFromBipolar;
|
||||
using instrument::ui::deckParamNorm;
|
||||
using instrument::ui::formatEnvTimeMs;
|
||||
using instrument::ui::kEnvTimeMaxSeconds;
|
||||
using instrument::ui::kKeyTrackMax;
|
||||
using instrument::ui::resetDeckParam;
|
||||
using instrument::ui::sampleDeckGroups;
|
||||
using instrument::ui::setDeckParam;
|
||||
using instrument::engine::formatMasterGainLabel;
|
||||
using instrument::engine::masterGainLinearFromNorm;
|
||||
using instrument::engine::masterGainNormFromLinear;
|
||||
using instrument::engine::filter::MorphLaw;
|
||||
using instrument::engine::filter::filterCutoffHzFromNorm;
|
||||
using instrument::engine::filter::filterDriveDepthFromNorm;
|
||||
using instrument::engine::filter::filterQFromNorm;
|
||||
using util::clamp01;
|
||||
|
||||
namespace {
|
||||
// Control-surface value domains (the shell owns these — param_slider is engine-free and maps
|
||||
// only 0..1). Every stage-time knob spans [0, kEnvTimeMaxSeconds] seconds — rate-free, exactly
|
||||
// what the parameter set stores; the build resolves seconds->frames at the live rate. No knob
|
||||
// on this surface stores a source-frame count any more, so none needs a rate to draw.
|
||||
//
|
||||
// The ceiling is READ from the overlay's schematic scale rather than restated: the AHDSR
|
||||
// schematic anchors a maxed knob at the canvas edge, which only holds while the two agree.
|
||||
constexpr double kEnvTimeMaxSeconds = instrument::ui::kGateStageMaxSeconds;
|
||||
// Pitch depth throw: +/-kVelocityPitchRangeSemitones, centered. The one throw the pitch
|
||||
// envelope's peak and the velocity->pitch curve's full scale both speak (play_params.h).
|
||||
constexpr double kPitchDepthMaxSemis = kVelocityPitchRangeSemitones;
|
||||
constexpr double kKeyTrackMax = 2.0; // key-track slider ceiling (0..200%)
|
||||
|
||||
// The raw stored curve exponent for a curve-dial control id, read DIRECTLY off the field —
|
||||
// never round-tripped through curveFromKnobNorm(knobNormFromCurve(x)): the knob-norm law's
|
||||
// centre detent (curve_law.h) snaps anything near-neutral back to exactly 1.0, so a round trip
|
||||
@@ -91,191 +82,25 @@ ReaSamplerEditor::FaceLayout ReaSamplerEditor::faceLayout(int w, int h) const {
|
||||
return fl;
|
||||
}
|
||||
|
||||
// The parameter-set binding is the pure deck_values module's; these three are the shell's thin
|
||||
// int-id adapters onto it (ParamControl is an alias of DeckParam).
|
||||
double ReaSamplerEditor::controlValue(int id, const PlaySeconds& play) const {
|
||||
// Wall-clock seconds -> normalized over the seconds ceiling; fractions and normalized
|
||||
// control positions pass through; curve exponents take the log travel.
|
||||
const auto secToNorm = [](double s) { return clamp01(s / kEnvTimeMaxSeconds); };
|
||||
switch (static_cast<ParamControl>(id)) {
|
||||
case ParamControl::kPlayMode: return play.playMode == PlayMode::Trigger ? 1.0 : 0.0;
|
||||
case ParamControl::kAmpEnvMode:
|
||||
return play.ampSpline.mode == EnvMode::Spline ? 1.0 : 0.0;
|
||||
case ParamControl::kPitchEnvMode:
|
||||
return play.pitchSpline.mode == EnvMode::Spline ? 1.0 : 0.0;
|
||||
case ParamControl::kFilterEnvMode:
|
||||
return play.filterSpline.mode == EnvMode::Spline ? 1.0 : 0.0;
|
||||
case ParamControl::kPitchEngine: return play.pitchEngine == PitchEngine::Preserve ? 1.0 : 0.0;
|
||||
case ParamControl::kAttack: return secToNorm(play.adsr.attackSeconds);
|
||||
case ParamControl::kHold: return secToNorm(play.adsr.holdSeconds);
|
||||
case ParamControl::kDecay: return secToNorm(play.adsr.decaySeconds);
|
||||
case ParamControl::kSustain: return clamp01(play.adsr.sustainLevel);
|
||||
case ParamControl::kRelease: return secToNorm(play.adsr.releaseSeconds);
|
||||
case ParamControl::kAttackCurve: return util::knobNormFromCurve(play.adsr.attackCurve);
|
||||
case ParamControl::kDecayCurve: return util::knobNormFromCurve(play.adsr.decayCurve);
|
||||
case ParamControl::kReleaseCurve: return util::knobNormFromCurve(play.adsr.releaseCurve);
|
||||
case ParamControl::kTrigLength: return clamp01(play.trigger.lengthFraction);
|
||||
case ParamControl::kTrigAttack: return secToNorm(play.trigAhd.attackSeconds);
|
||||
case ParamControl::kTrigHold: return clamp01(play.trigAhd.holdFraction);
|
||||
case ParamControl::kTrigDecay: return secToNorm(play.trigAhd.decaySeconds);
|
||||
case ParamControl::kTrigAttackCurve: return util::knobNormFromCurve(play.trigAhd.attackCurve);
|
||||
case ParamControl::kTrigDecayCurve: return util::knobNormFromCurve(play.trigAhd.decayCurve);
|
||||
case ParamControl::kPitchEnvEnable:return play.pitchEnv.enabled ? 1.0 : 0.0;
|
||||
case ParamControl::kPitchEnvAttack:return secToNorm(play.pitchEnv.shape.attackSeconds);
|
||||
case ParamControl::kPitchEnvHold: return clamp01(play.pitchEnv.shape.holdFraction);
|
||||
case ParamControl::kPitchEnvDecay: return secToNorm(play.pitchEnv.shape.decaySeconds);
|
||||
case ParamControl::kPitchEnvAttackCurve:
|
||||
return util::knobNormFromCurve(play.pitchEnv.shape.attackCurve);
|
||||
case ParamControl::kPitchEnvDecayCurve:
|
||||
return util::knobNormFromCurve(play.pitchEnv.shape.decayCurve);
|
||||
case ParamControl::kPitchEnvDepth:
|
||||
// Signed depth centered at 0.5 (0.5 == 0 semitones).
|
||||
return clamp01(0.5 + play.pitchEnv.peakSemitones / (2.0 * kPitchDepthMaxSemis));
|
||||
// Filter. The four tone controls ARE the module's normalized positions — stored and
|
||||
// shown as-is, so the knob travel is exactly filter_params' own law.
|
||||
case ParamControl::kFilterEnable: return play.filter.enabled ? 1.0 : 0.0;
|
||||
case ParamControl::kFilterLaw:
|
||||
return play.filter.settings.morphLaw == MorphLaw::HighNotchLow ? 1.0 : 0.0;
|
||||
case ParamControl::kFilterMorph: return clamp01(play.filter.settings.morphNorm);
|
||||
case ParamControl::kFilterCutoff: return clamp01(play.filter.settings.cutoffNorm);
|
||||
case ParamControl::kFilterQ: return clamp01(play.filter.settings.resonanceNorm);
|
||||
case ParamControl::kFilterDrive: return clamp01(play.filter.settings.driveNorm);
|
||||
case ParamControl::kFilterModAmt: return deckNormFromBipolar(play.filter.modAmount);
|
||||
case ParamControl::kFilterVel: return deckNormFromBipolar(play.filter.velAmount);
|
||||
case ParamControl::kFilterKeyTrack:return clamp01(play.filter.keyTrack / kKeyTrackMax);
|
||||
case ParamControl::kFilterEnvAttack: return secToNorm(play.filter.env.attackSeconds);
|
||||
case ParamControl::kFilterEnvHold: return secToNorm(play.filter.env.holdSeconds);
|
||||
case ParamControl::kFilterEnvDecay: return secToNorm(play.filter.env.decaySeconds);
|
||||
case ParamControl::kFilterEnvSustain: return clamp01(play.filter.env.sustainLevel);
|
||||
case ParamControl::kFilterEnvRelease: return secToNorm(play.filter.env.releaseSeconds);
|
||||
case ParamControl::kFilterEnvAttackCurve:
|
||||
return util::knobNormFromCurve(play.filter.env.attackCurve);
|
||||
case ParamControl::kFilterEnvDecayCurve:
|
||||
return util::knobNormFromCurve(play.filter.env.decayCurve);
|
||||
case ParamControl::kFilterEnvReleaseCurve:
|
||||
return util::knobNormFromCurve(play.filter.env.releaseCurve);
|
||||
case ParamControl::kFilterTrigAttack: return secToNorm(play.filter.trigEnv.attackSeconds);
|
||||
case ParamControl::kFilterTrigHold: return clamp01(play.filter.trigEnv.holdFraction);
|
||||
case ParamControl::kFilterTrigDecay: return secToNorm(play.filter.trigEnv.decaySeconds);
|
||||
case ParamControl::kFilterTrigAttackCurve:
|
||||
return util::knobNormFromCurve(play.filter.trigEnv.attackCurve);
|
||||
case ParamControl::kFilterTrigDecayCurve:
|
||||
return util::knobNormFromCurve(play.filter.trigEnv.decayCurve);
|
||||
default: return 0.0;
|
||||
}
|
||||
return deckParamNorm(static_cast<instrument::ui::DeckParam>(id), play);
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
int segment) const {
|
||||
const auto normToSec = [](double v) { return clamp01(v) * kEnvTimeMaxSeconds; };
|
||||
switch (static_cast<ParamControl>(id)) {
|
||||
case ParamControl::kPlayMode:
|
||||
// Gate is refused while any EG is drawn — see splineActive (play_params.h). The
|
||||
// segment paints Disabled for the same reason, so the refusal is never a surprise.
|
||||
if (segment == 0 && splineActive(play)) break;
|
||||
play.playMode = (segment == 1) ? PlayMode::Trigger : PlayMode::Gate;
|
||||
break;
|
||||
// Switching TO Spline drops Gate, which the spline model has no place for. Switching
|
||||
// back does NOT restore it: the previous mode is not stored, and silently re-gating an
|
||||
// instrument the user has since heard as a one-shot is the worse surprise.
|
||||
case ParamControl::kAmpEnvMode:
|
||||
case ParamControl::kPitchEnvMode:
|
||||
case ParamControl::kFilterEnvMode: {
|
||||
const EnvMode m = (segment == 1) ? EnvMode::Spline : EnvMode::Staged;
|
||||
switch (static_cast<ParamControl>(id)) {
|
||||
case ParamControl::kAmpEnvMode: play.ampSpline.mode = m; break;
|
||||
case ParamControl::kPitchEnvMode: play.pitchSpline.mode = m; break;
|
||||
default: play.filterSpline.mode = m; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamControl::kPitchEngine:
|
||||
play.pitchEngine = (segment == 1) ? PitchEngine::Preserve : PitchEngine::Varispeed;
|
||||
break;
|
||||
case ParamControl::kAttack: play.adsr.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kHold: play.adsr.holdSeconds = normToSec(value); break;
|
||||
case ParamControl::kDecay: play.adsr.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kSustain: play.adsr.sustainLevel = clamp01(value); break;
|
||||
case ParamControl::kRelease: play.adsr.releaseSeconds = normToSec(value); break;
|
||||
case ParamControl::kAttackCurve: play.adsr.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kDecayCurve: play.adsr.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kReleaseCurve: play.adsr.releaseCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kTrigLength:
|
||||
// lengthFraction is (0,1]; keep a small floor so a zero-length trigger never plays nothing.
|
||||
play.trigger.lengthFraction = (std::max)(0.01, clamp01(value));
|
||||
break;
|
||||
case ParamControl::kTrigAttack: play.trigAhd.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kTrigHold: play.trigAhd.holdFraction = clamp01(value); break;
|
||||
case ParamControl::kTrigDecay: play.trigAhd.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kTrigAttackCurve:
|
||||
play.trigAhd.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kTrigDecayCurve:
|
||||
play.trigAhd.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvEnable:
|
||||
play.pitchEnv.enabled = (segment == 1);
|
||||
break;
|
||||
case ParamControl::kPitchEnvAttack:
|
||||
play.pitchEnv.shape.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kPitchEnvHold:
|
||||
play.pitchEnv.shape.holdFraction = clamp01(value); break;
|
||||
case ParamControl::kPitchEnvDecay:
|
||||
play.pitchEnv.shape.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kPitchEnvAttackCurve:
|
||||
play.pitchEnv.shape.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvDecayCurve:
|
||||
play.pitchEnv.shape.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvDepth:
|
||||
play.pitchEnv.peakSemitones = (clamp01(value) - 0.5) * 2.0 * kPitchDepthMaxSemis;
|
||||
break;
|
||||
case ParamControl::kFilterEnable: play.filter.enabled = (segment == 1); break;
|
||||
case ParamControl::kFilterLaw:
|
||||
play.filter.settings.morphLaw =
|
||||
(segment == 1) ? MorphLaw::HighNotchLow : MorphLaw::HighBandLow;
|
||||
break;
|
||||
case ParamControl::kFilterMorph:
|
||||
play.filter.settings.morphNorm = static_cast<float>(clamp01(value)); break;
|
||||
case ParamControl::kFilterCutoff:
|
||||
play.filter.settings.cutoffNorm = static_cast<float>(clamp01(value)); break;
|
||||
case ParamControl::kFilterQ:
|
||||
play.filter.settings.resonanceNorm = static_cast<float>(clamp01(value)); break;
|
||||
case ParamControl::kFilterDrive:
|
||||
play.filter.settings.driveNorm = static_cast<float>(clamp01(value)); break;
|
||||
case ParamControl::kFilterModAmt: play.filter.modAmount = deckBipolarFromNorm(value); break;
|
||||
case ParamControl::kFilterVel: play.filter.velAmount = deckBipolarFromNorm(value); break;
|
||||
case ParamControl::kFilterKeyTrack:
|
||||
play.filter.keyTrack = clamp01(value) * kKeyTrackMax; break;
|
||||
case ParamControl::kFilterEnvAttack:
|
||||
play.filter.env.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterEnvHold:
|
||||
play.filter.env.holdSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterEnvDecay:
|
||||
play.filter.env.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterEnvSustain:
|
||||
play.filter.env.sustainLevel = clamp01(value); break;
|
||||
case ParamControl::kFilterEnvRelease:
|
||||
play.filter.env.releaseSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterEnvAttackCurve:
|
||||
play.filter.env.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterEnvDecayCurve:
|
||||
play.filter.env.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterEnvReleaseCurve:
|
||||
play.filter.env.releaseCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterTrigAttack:
|
||||
play.filter.trigEnv.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterTrigHold:
|
||||
play.filter.trigEnv.holdFraction = clamp01(value); break;
|
||||
case ParamControl::kFilterTrigDecay:
|
||||
play.filter.trigEnv.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterTrigAttackCurve:
|
||||
play.filter.trigEnv.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterTrigDecayCurve:
|
||||
play.filter.trigEnv.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
default: break;
|
||||
setDeckParam(static_cast<instrument::ui::DeckParam>(id), play, value, segment);
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::resetParamControl(int id) {
|
||||
// kKeyTrack is the one knob whose value sits beside the play bundle, so it defaults from
|
||||
// InstrumentParams rather than from PlaySeconds — the same split applyParamControl draws.
|
||||
if (id == static_cast<int>(ParamControl::kKeyTrack)) {
|
||||
params_.keyTrack = InstrumentParams{}.keyTrack;
|
||||
return;
|
||||
}
|
||||
// ONE normalization point for every control that can flip splineActive — a mode toggle
|
||||
// (above) or an enable toggle (kPitchEnvEnable/kFilterEnable), whose enabling can make an
|
||||
// already-Spline pitch/filter envelope newly active. Applying it once here, rather than at
|
||||
// each site that could cause the flip, is what keeps a future such control from reopening
|
||||
// the same hole. `resolvePlay` (sample_map.cpp) is the other caller of the shared helper.
|
||||
enforceGateUnavailableWhileDrawn(play);
|
||||
resetDeckParam(static_cast<instrument::ui::DeckParam>(id), params_.play);
|
||||
}
|
||||
|
||||
double ReaSamplerEditor::liveSampleRate() const {
|
||||
@@ -348,29 +173,29 @@ std::string ReaSamplerEditor::deckValueLabel(int id) const {
|
||||
const PlaySeconds& play = params_.play;
|
||||
switch (id == -2 ? ParamControl::kCount : static_cast<ParamControl>(id)) {
|
||||
case ParamControl::kAttack:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.adsr.attackSeconds); break;
|
||||
formatEnvTimeMs(play.adsr.attackSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kHold:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.adsr.holdSeconds); break;
|
||||
formatEnvTimeMs(play.adsr.holdSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kDecay:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.adsr.decaySeconds); break;
|
||||
formatEnvTimeMs(play.adsr.decaySeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kSustain:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.adsr.sustainLevel * 100.0); break;
|
||||
case ParamControl::kRelease:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.adsr.releaseSeconds); break;
|
||||
formatEnvTimeMs(play.adsr.releaseSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kTrigLength:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.trigger.lengthFraction * 100.0); break;
|
||||
case ParamControl::kTrigAttack:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.trigAhd.attackSeconds); break;
|
||||
formatEnvTimeMs(play.trigAhd.attackSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kTrigHold:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.trigAhd.holdFraction * 100.0); break;
|
||||
case ParamControl::kTrigDecay:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.trigAhd.decaySeconds); break;
|
||||
formatEnvTimeMs(play.trigAhd.decaySeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kPitchEnvAttack:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.pitchEnv.shape.attackSeconds); break;
|
||||
formatEnvTimeMs(play.pitchEnv.shape.attackSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kPitchEnvHold:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.pitchEnv.shape.holdFraction * 100.0); break;
|
||||
case ParamControl::kPitchEnvDecay:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.pitchEnv.shape.decaySeconds); break;
|
||||
formatEnvTimeMs(play.pitchEnv.shape.decaySeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kPitchEnvDepth:
|
||||
snprintf(buf, sizeof(buf), "%+.1fst", play.pitchEnv.peakSemitones); break;
|
||||
case ParamControl::kKeyTrack:
|
||||
@@ -407,21 +232,21 @@ std::string ReaSamplerEditor::deckValueLabel(int id) const {
|
||||
case ParamControl::kFilterKeyTrack:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.filter.keyTrack * 100.0); break;
|
||||
case ParamControl::kFilterEnvAttack:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.env.attackSeconds); break;
|
||||
formatEnvTimeMs(play.filter.env.attackSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kFilterEnvHold:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.env.holdSeconds); break;
|
||||
formatEnvTimeMs(play.filter.env.holdSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kFilterEnvDecay:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.env.decaySeconds); break;
|
||||
formatEnvTimeMs(play.filter.env.decaySeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kFilterEnvSustain:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.filter.env.sustainLevel * 100.0); break;
|
||||
case ParamControl::kFilterEnvRelease:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.env.releaseSeconds); break;
|
||||
formatEnvTimeMs(play.filter.env.releaseSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kFilterTrigAttack:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.trigEnv.attackSeconds); break;
|
||||
formatEnvTimeMs(play.filter.trigEnv.attackSeconds, buf, sizeof(buf)); break;
|
||||
case ParamControl::kFilterTrigHold:
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", play.filter.trigEnv.holdFraction * 100.0); break;
|
||||
case ParamControl::kFilterTrigDecay:
|
||||
snprintf(buf, sizeof(buf), "%.3fs", play.filter.trigEnv.decaySeconds); break;
|
||||
formatEnvTimeMs(play.filter.trigEnv.decaySeconds, buf, sizeof(buf)); break;
|
||||
// Every curve exponent reads the same way: the neutral shows as 1.00.
|
||||
case ParamControl::kAttackCurve:
|
||||
case ParamControl::kDecayCurve:
|
||||
|
||||
@@ -40,6 +40,19 @@ void ReaSamplerEditor::onMouseDown(int x, int y) {
|
||||
mouseDownWaveform(fl, x, y);
|
||||
}
|
||||
|
||||
bool ReaSamplerEditor::onMouseDoubleClick(int x, int y) {
|
||||
// Only the Sample face's radial knobs claim the gesture. Everything else — Browse's
|
||||
// load accelerator, the spline surfaces' point grammar — is left to the caller's
|
||||
// fall-through to onMouseDown, which is the path those surfaces were built on.
|
||||
if (!processor_ || view_ != View::kSample || curvePopup_ != CurveTarget::kNone) return false;
|
||||
RECT cr{};
|
||||
GetClientRect(childHwnd_, &cr);
|
||||
const FaceLayout fl = faceLayout(cr.right - cr.left, cr.bottom - cr.top);
|
||||
if (doubleClickChrome(fl, x, y)) return true;
|
||||
if (selectedId_.empty()) return false;
|
||||
return doubleClickDeck(fl, x, y);
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::onMouseMove(int x, int y) {
|
||||
if (drag_ == DragKind::kNone) return;
|
||||
dragCurX_ = x; // keep the live cursor position for drag-state draw cues (e.g. drag-off warn)
|
||||
|
||||
@@ -80,6 +80,18 @@ bool ReaSamplerEditor::mouseDownChrome(const FaceLayout& fl, int x, int y) {
|
||||
return contains(cr.controls, x, y);
|
||||
}
|
||||
|
||||
bool ReaSamplerEditor::doubleClickChrome(const FaceLayout& fl, int x, int y) {
|
||||
// The preview-velocity dial answers the same reset gesture the deck's knobs do — it is a
|
||||
// radial knob drawn by the same primitive, so a user who learns the gesture there expects
|
||||
// it here. Resolved against the whole cell, not the circle: the cell IS the knob's target
|
||||
// on this surface (there is no neighbouring control to steal from).
|
||||
if (selectedId_.empty() || !processor_) return false;
|
||||
if (!contains(fl.chrome.velCell, x, y)) return false;
|
||||
processor_->setPreviewVelocity(kPreviewVelocityDefault);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::dragChrome(const FaceLayout& fl, int x, int y) {
|
||||
const Rect& stripArea = fl.chrome.rootStrip;
|
||||
if (stripArea.empty()) return;
|
||||
|
||||
@@ -108,6 +108,43 @@ bool ReaSamplerEditor::mouseDownDeck(const FaceLayout& fl, int x, int y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReaSamplerEditor::doubleClickDeck(const FaceLayout& fl, int x, int y) {
|
||||
const Rect& band = fl.bands.decks;
|
||||
if (!contains(band, x, y)) return false;
|
||||
const DeckLayout dl = layoutDeck(fl.deckDescs, band.x, band.y, band.width);
|
||||
// Resolved against the drawn CIRCLES (hitTestKnobFace), not the cell a drag grabs anywhere
|
||||
// in: the two rings are concentric, so only a radial resolve can tell "reset the exponent"
|
||||
// from "reset the value".
|
||||
const DeckFaceHit hit = hitTestKnobFace(dl, x, y);
|
||||
if (hit.id < 0) return false;
|
||||
if (deckKnobDisabled(hit.id)) return true; // drawn-but-dead: swallow, change nothing
|
||||
// A VELOCITY cell is a popup opener with no scalar value to reset.
|
||||
if (curveTargetFor(hit.id) != CurveTarget::kNone) return true;
|
||||
|
||||
const ParamControl curve = curveParamFor(static_cast<ParamControl>(hit.id));
|
||||
const bool inner = hit.inner && curve != ParamControl::kCount;
|
||||
const int target = inner ? static_cast<int>(curve) : hit.id;
|
||||
// The processor-side knobs own their own defaults — they never reach the parameter set.
|
||||
if (target == static_cast<int>(ParamControl::kVoiceCount)) {
|
||||
voiceCount_ = kDefaultVoiceCount;
|
||||
processor_->setVoiceCount(voiceCount_);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
if (target == static_cast<int>(ParamControl::kMasterGain)) {
|
||||
processor_->setMasterGainLinear(1.0);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
resetParamControl(target);
|
||||
// Same commit tiering a drag of this control takes, so a reset reaches the sounding note
|
||||
// exactly as a drag to the same value would.
|
||||
if (dragCommitsLive(DragKind::kDeckKnob, target)) commitLive();
|
||||
else commitAndReload();
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReaSamplerEditor::dragDeck(int x, int y) {
|
||||
// Radial knob: grab-anchored vertical drag — knobDragValue maps the y delta from the
|
||||
// value at grab (up = increase), so the value tracks relative motion and never jumps on
|
||||
|
||||
@@ -111,6 +111,13 @@ inline void drawTitleBand(LICE_IBitmap* bmp, const instrument::ui::Rect& title,
|
||||
kitText(bmp, titleText, readout.c_str(), Font::Title, ui::Role::TextPrimary);
|
||||
}
|
||||
|
||||
// Stroke widths for the radial faces. The value arc is drawn as adjacent 1px AA arcs rather
|
||||
// than one thick primitive — LICE has no thick-arc call, and stacking radii is what keeps every
|
||||
// ring antialiased.
|
||||
inline constexpr int kKnobValueArcPx = 3;
|
||||
inline constexpr int kInnerDialArcPx = 2;
|
||||
inline constexpr int kKnobNeedlePx = 2;
|
||||
|
||||
// Draws one radial knob face: param_slider owns the value<->angle map; this turns it into
|
||||
// LICE calls. LICE takes radians, and drawing the 7->5 o'clock sweep through the top needs
|
||||
// a continuous angle span, so degrees convert as (deg - 360) * pi/180, mapping 210..510
|
||||
@@ -144,16 +151,19 @@ inline void drawKnobFace(LICE_IBitmap* bmp, const instrument::ui::Rect& knobRect
|
||||
(arc.startDeg + v * instrument::ui::knobSweepDeg(arc) - 360.0) * kDegToRad);
|
||||
const ui::Role valueRole = disabled ? ui::Role::TextDim
|
||||
: (hot ? ui::Role::AccentHot : ui::Role::AccentPrimary);
|
||||
LICE_Arc(bmp, cx, cy, rOuter, a0, av, toLice(ui::roleColor(valueRole)), 1.0f, 0, true);
|
||||
const LICE_pixel valueCol = toLice(ui::roleColor(valueRole));
|
||||
for (int i = 0; i < kKnobValueArcPx; ++i) {
|
||||
LICE_Arc(bmp, cx, cy, rOuter - static_cast<float>(i), a0, av, valueCol, 1.0f, 0, true);
|
||||
}
|
||||
}
|
||||
// Needle: from ~35% radius out to the rim at the value's angle.
|
||||
// Needle: from ~35% radius out to the rim at the value's angle. ThickFLine keeps the float
|
||||
// endpoints AND is always antialiased, so the needle is smooth at every angle.
|
||||
const KnobPoint tip = instrument::ui::knobNeedlePoint(kg, arc, v);
|
||||
const float ix = cx + static_cast<float>((tip.x - kg.centerX) * 0.35);
|
||||
const float iy = cy + static_cast<float>((tip.y - kg.centerY) * 0.35);
|
||||
const double ix = kg.centerX + (tip.x - kg.centerX) * 0.35;
|
||||
const double iy = kg.centerY + (tip.y - kg.centerY) * 0.35;
|
||||
const ui::Role needleRole = disabled ? ui::Role::TextDim : ui::Role::TextPrimary;
|
||||
LICE_Line(bmp, static_cast<int>(ix + 0.5f), static_cast<int>(iy + 0.5f),
|
||||
static_cast<int>(tip.x + 0.5f), static_cast<int>(tip.y + 0.5f),
|
||||
toLice(ui::roleColor(needleRole)), 1.0f, 0, true);
|
||||
LICE_ThickFLine(bmp, ix, iy, tip.x, tip.y, toLice(ui::roleColor(needleRole)), 1.0f, 0,
|
||||
kKnobNeedlePx);
|
||||
}
|
||||
|
||||
// The concentric INNER dial: a second value on the same cell, drawn in the categorical
|
||||
@@ -184,12 +194,15 @@ inline void drawInnerDial(LICE_IBitmap* bmp, const instrument::ui::Rect& innerRe
|
||||
(arc.startDeg + v * instrument::ui::knobSweepDeg(arc) - 360.0) * kDegToRad);
|
||||
const ui::Role arcRole = disabled ? ui::Role::TextDim
|
||||
: (hot ? ui::Role::AccentHot : ui::Role::AccentTertiary);
|
||||
LICE_Arc(bmp, cx, cy, r, a0, av, toLice(ui::roleColor(arcRole)), 1.0f, 0, true);
|
||||
const LICE_pixel arcCol = toLice(ui::roleColor(arcRole));
|
||||
for (int i = 0; i < kInnerDialArcPx; ++i) {
|
||||
LICE_Arc(bmp, cx, cy, r - static_cast<float>(i), a0, av, arcCol, 1.0f, 0, true);
|
||||
}
|
||||
const KnobPoint tip = instrument::ui::knobNeedlePoint(kg, arc, v);
|
||||
LICE_Line(bmp, static_cast<int>(cx + 0.5f), static_cast<int>(cy + 0.5f),
|
||||
static_cast<int>(tip.x + 0.5f), static_cast<int>(tip.y + 0.5f),
|
||||
toLice(ui::roleColor(disabled ? ui::Role::TextDim : ui::Role::AccentTertiary)),
|
||||
1.0f, 0, true);
|
||||
LICE_FLine(bmp, static_cast<float>(kg.centerX), static_cast<float>(kg.centerY),
|
||||
static_cast<float>(tip.x), static_cast<float>(tip.y),
|
||||
toLice(ui::roleColor(disabled ? ui::Role::TextDim : ui::Role::AccentTertiary)),
|
||||
1.0f, 0, true);
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -145,6 +145,14 @@ void ReaSamplerEditor::paintChrome(LICE_IBitmap* bmp, const FaceLayout& fl, bool
|
||||
const LICE_pixel ink = toLice(roleColor(buttonLabelRole(st)));
|
||||
LICE_FillTriangle(bmp, g.leftX, g.topY, g.leftX, g.bottomY, g.apexX, g.apexY,
|
||||
ink, 1.0f, 0);
|
||||
// LICE_FillTriangle takes no aa flag, so its two sloped edges come out stepped.
|
||||
// Re-stroke them in the same ink: an AA line over the fill's own boundary softens
|
||||
// the step without changing the shape. The vertical edge needs none.
|
||||
const float lx = static_cast<float>(g.leftX);
|
||||
const float ax = static_cast<float>(g.apexX);
|
||||
const float ay = static_cast<float>(g.apexY);
|
||||
LICE_FLine(bmp, lx, static_cast<float>(g.topY), ax, ay, ink, 1.0f, 0, true);
|
||||
LICE_FLine(bmp, lx, static_cast<float>(g.bottomY), ax, ay, ink, 1.0f, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,9 @@ void ReaSamplerEditor::paintVelocityCurve(LICE_IBitmap* bmp, const Rect& r) {
|
||||
const int cx = box.left + px;
|
||||
const double vel = curve.pointFromPixel(box, cx, box.top).velocity;
|
||||
const int cy = curve.pixelFromPoint(box, {vel, curve.eval(vel)}).y;
|
||||
if (px > 0) LICE_Line(bmp, prevX, prevY, cx, cy, line, 1.0f, 0, true);
|
||||
// Same weight and antialiasing the envelope traces use — one trace grammar across every
|
||||
// curve surface (editor_paint_waveform.cpp owns why ThickFLine and not LICE_Line).
|
||||
if (px > 0) LICE_ThickFLine(bmp, prevX, prevY, cx, cy, line, 1.0f, 0, 2);
|
||||
prevX = cx;
|
||||
prevY = cy;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace reasampler::vst {
|
||||
using namespace reasampler::ui; // kit vocabulary
|
||||
using namespace reasampler::instrument::ui; // deck geometry
|
||||
|
||||
// The knob's own name/value band. One size up from the group captions and the toggles, which
|
||||
// are chrome you read once — this is the readout you read while turning something.
|
||||
constexpr Font kCellLabelFont = Font::Label;
|
||||
|
||||
void ReaSamplerEditor::paintDeck(LICE_IBitmap* bmp, const FaceLayout& fl) {
|
||||
const Rect& deckArea = fl.bands.decks;
|
||||
if (deckArea.width <= 0 || deckArea.height <= 0) return;
|
||||
@@ -194,7 +198,7 @@ void ReaSamplerEditor::paintDeck(LICE_IBitmap* bmp, const FaceLayout& fl) {
|
||||
paintCurveButton(bmp, c.knob, curveCell, disabled,
|
||||
!disabled && isHovered(HoverKind::kControl, c.id));
|
||||
kitTextCentered(bmp, c.label, knobName(static_cast<ParamControl>(c.id)),
|
||||
Font::Micro, Role::TextDim);
|
||||
kCellLabelFont, Role::TextDim);
|
||||
continue;
|
||||
}
|
||||
const bool dragging = (drag_ == DragKind::kDeckKnob && dragParamId_ == c.id);
|
||||
@@ -226,7 +230,7 @@ void ReaSamplerEditor::paintDeck(LICE_IBitmap* bmp, const FaceLayout& fl) {
|
||||
if (innerDragging || innerHov) label = deckValueLabel(static_cast<int>(curve));
|
||||
else if (dragging || hov) label = deckValueLabel(c.id);
|
||||
else label = std::string(knobName(static_cast<ParamControl>(c.id)));
|
||||
kitTextCentered(bmp, c.label, label.c_str(), Font::Micro, Role::TextDim);
|
||||
kitTextCentered(bmp, c.label, label.c_str(), kCellLabelFont, Role::TextDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ constexpr Role kRoleLoopMarker = Role::AccentSecondary;
|
||||
constexpr int kEnvHandleRadius = 3;
|
||||
constexpr int kEnvHandleGrabbedRadius = 5;
|
||||
constexpr int kEnvHandleRingPx = 2;
|
||||
|
||||
// Both envelope traces — staged and drawn — are one grammar and one weight. LICE_ThickFLine is
|
||||
// ALWAYS antialiased (unlike LICE_Line, whose aa flag does nothing on an axis-aligned run), and
|
||||
// the second pixel of width is what stops a shallow slope reading as a staircase over the
|
||||
// waveform behind it.
|
||||
constexpr int kEnvTracePx = 2;
|
||||
} // namespace
|
||||
|
||||
void ReaSamplerEditor::paintWaveform(LICE_IBitmap* bmp, const Rect& band) {
|
||||
@@ -148,7 +154,7 @@ void ReaSamplerEditor::paintSplineOverlay(LICE_IBitmap* bmp, const OverlayArea&
|
||||
const int cx = box.left + px;
|
||||
const double t = curve.pointFromPixel(box, cx, box.top).velocity;
|
||||
const int cy = curve.pixelFromPoint(box, {t, curve.eval(t)}).y;
|
||||
if (px > 0) LICE_Line(bmp, prevX, prevY, cx, cy, line, 1.0f, 0, true);
|
||||
if (px > 0) LICE_ThickFLine(bmp, prevX, prevY, cx, cy, line, 1.0f, 0, kEnvTracePx);
|
||||
prevX = cx;
|
||||
prevY = cy;
|
||||
}
|
||||
@@ -213,7 +219,7 @@ void ReaSamplerEditor::paintEnvelopeOverlay(LICE_IBitmap* bmp, const OverlayArea
|
||||
if (prev != nullptr) {
|
||||
const int x0 = (std::max)(area.x, (std::min)(area.right() - 1, prev->x));
|
||||
const int x1 = (std::max)(area.x, (std::min)(area.right() - 1, v.x));
|
||||
LICE_Line(bmp, x0, prev->y, x1, v.y, line, 1.0f, 0, true);
|
||||
LICE_ThickFLine(bmp, x0, prev->y, x1, v.y, line, 1.0f, 0, kEnvTracePx);
|
||||
}
|
||||
prev = &v;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,10 @@ void ReaSamplerEditor::attachedToParent() {
|
||||
wc.hInstance = hInst;
|
||||
wc.lpszClassName = kChildClassName;
|
||||
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
// CS_DBLCLKS is what makes WM_LBUTTONDBLCLK arrive at all. It also REPLACES the second
|
||||
// WM_LBUTTONDOWN of a double-click, so every surface that counted two downs (Browse's
|
||||
// load accelerator) depends on the DBLCLK handler falling through to onMouseDown.
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
||||
RegisterClassW(&wc);
|
||||
classRegistered = true;
|
||||
}
|
||||
@@ -150,6 +153,17 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
self->onMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
}
|
||||
return 0;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
if (self) {
|
||||
SetCapture(hwnd);
|
||||
SetFocus(hwnd);
|
||||
const int mx = GET_X_LPARAM(lParam);
|
||||
const int my = GET_Y_LPARAM(lParam);
|
||||
// Knob reset first; anything it does not claim is the second click of the pair
|
||||
// this message stands in for (see the class-style note above).
|
||||
if (!self->onMouseDoubleClick(mx, my)) self->onMouseDown(mx, my);
|
||||
}
|
||||
return 0;
|
||||
case WM_MOUSEMOVE:
|
||||
if (self) {
|
||||
const int mx = GET_X_LPARAM(lParam);
|
||||
@@ -202,6 +216,11 @@ LRESULT CALLBACK ReaSamplerEditor::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
// explicitly (the child wndproc historically handled only left-button).
|
||||
if (self) self->onMouseRDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
return 0;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
// CS_DBLCLKS replaces the second RIGHT-button down too, so the spline surfaces'
|
||||
// repeat-delete needs this peer or a fast double right-click drops one delete.
|
||||
if (self) self->onMouseRDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
return 0;
|
||||
case WM_RBUTTONUP:
|
||||
return 0; // claimed so the pair never reaches DefWindowProc (no context menu)
|
||||
case WM_CAPTURECHANGED:
|
||||
|
||||
@@ -195,6 +195,13 @@ private:
|
||||
bool mouseDownDeck(const FaceLayout& fl, int x, int y);
|
||||
void mouseDownBrowse(int w, int h, int x, int y);
|
||||
|
||||
// Double-click = reset the radial knob under the pointer to its default. Returns false when
|
||||
// no knob claims the point, and the caller then replays it as an ordinary mouse-down (the
|
||||
// platform note at the window class explains why that fall-through is load-bearing).
|
||||
bool onMouseDoubleClick(int x, int y);
|
||||
bool doubleClickChrome(const FaceLayout& fl, int x, int y);
|
||||
bool doubleClickDeck(const FaceLayout& fl, int x, int y);
|
||||
|
||||
// Whether deck knob `id` belongs to a group whose enable toggle is off. The ONE predicate
|
||||
// behind both the Disabled paint and the inert grab, so they cannot disagree.
|
||||
bool deckKnobDisabled(int id) const;
|
||||
@@ -335,16 +342,12 @@ private:
|
||||
void beginMarkerDrag(WaveMarker which, const SetupMarkers& m, std::int64_t frames, int x);
|
||||
|
||||
// Deck knobs edit the parameter set's PlaySeconds (play mode + AHDSR; pitch engine + AD
|
||||
// pitch envelope) — wall-clock seconds, rate-free; the build resolves to frames.
|
||||
|
||||
// The normalized [0,1] display value for control `id` given `play` (seconds -> 0..1 over
|
||||
// a fixed ceiling, levels and fractions as-is, semitone depth centered at 0.5, curve
|
||||
// exponents over their logarithmic travel).
|
||||
// pitch envelope) — wall-clock seconds, rate-free; the build resolves to frames. The three
|
||||
// adapters below are thin int-id wrappers over the pure `deck_values` module, which owns
|
||||
// what each control's value means; see its header rather than restating the domains here.
|
||||
double controlValue(int id, const PlaySeconds& play) const;
|
||||
|
||||
// Applies a committed control interaction to `play`: a knob's normalized `value` or a
|
||||
// toggle's `segment` (0/1). Mutates `play` in place.
|
||||
void applyControl(int id, PlaySeconds& play, double value, int segment) const;
|
||||
void resetParamControl(int id);
|
||||
|
||||
// Applies a knob/toggle interaction to the ONE parameter set for control `id`: ordinary
|
||||
// controls route through applyControl; kKeyTrack writes the keyTrack scalar (0..200%
|
||||
@@ -385,8 +388,8 @@ private:
|
||||
// params edit, no reload).
|
||||
void applyDeckKnob(int id, double norm);
|
||||
|
||||
// The knob's live value label shown during hover/drag: seconds, percents, source
|
||||
// frames, signed semitones, a voice count, or the master-gain dB.
|
||||
// The knob's live value label shown during hover/drag: milliseconds, percents, Hz, signed
|
||||
// semitones, a curve exponent, a voice count, or the master-gain dB.
|
||||
std::string deckValueLabel(int id) const;
|
||||
|
||||
ReaSamplerProcessor* processor_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user