instrument: latch the note done at the read-head run-off, fit the migrated fades, and lift the curve dial and overlay selection into pure modules
This commit is contained in:
@@ -283,7 +283,7 @@ anything for a trigger shape.
|
||||
- `param_slider` — parameter control-panel: vertical stack of TOGGLE (two-segment selector) and SLIDER (horizontal track) rows; maps normalized value to/from handle pixel.
|
||||
- `embed_strip` — compact single-row control layout for embed mode in the track FX chain.
|
||||
- `knob_deck` — pure knob-deck layout + hit-test (FB1): group-box / caption-row / compact-toggle / knob-cell geometry, deterministic whole-group wrap, `DeckLayout` / `DeckHit`. Mirror of `action_bar`/`param_slider`; no LICE or REAPER types.
|
||||
- `deck_groups` — also home to `isLiveDeckParam` and `liveCommitFor`, the editor's whole commit-tier routing decision (see "Live parameter delivery" above); WHICH groups the Sample face's deck carries, split from `knob_deck`'s HOW they lay out: the `DeckParam` control-id space (the editor's `ParamControl` is an alias of it), the `DeckGroupId` list, `sampleDeckGroups` in signal-flow order (**pitch → filter → amp**, then voice/master), and the deck's bipolar-knob law. Reads `PlayMode` for the AMP group's Gate/Trigger face, which is why this and not `knob_deck` is the module that touches the engine's value layer.
|
||||
- `deck_groups` — also home to `isLiveDeckParam` and `liveCommitFor`, the editor's whole commit-tier routing decision (see "Live parameter delivery" above), and to `OverlayEnv` + `nextOverlaySelection`/`overlayEnvInert`, the whole overlay-selection state machine (exclusivity, the none resting state, and which selections a disabled group makes inert); WHICH groups the Sample face's deck carries, split from `knob_deck`'s HOW they lay out: the `DeckParam` control-id space (the editor's `ParamControl` is an alias of it), the `DeckGroupId` list, `sampleDeckGroups` in signal-flow order (**pitch → filter → amp**, then voice/master), and the deck's bipolar-knob law. Reads `PlayMode` for the AMP group's Gate/Trigger face, which is why this and not `knob_deck` is the module that touches the engine's value layer.
|
||||
- `curve_popup` — pure curve-popup geometry + dismissal test (FB1): centered sheet over the Sample face — width/height clamps, title row, Close button rect, curve-box rect, outside-sheet dismissal test. Mirror of `overflow_menu`; no LICE or REAPER types.
|
||||
- `envelope_overlay` — pure staged-envelope→polyline geometry for the Sample-view overlay (read from `envelope_overlay.h`): maps a `StageEnvelope` to a polyline inside a rect under whichever of TWO layout policies its `EnvKind` selects — an AHDSR draws a bounded param-domain schematic with its release RIGHT-ANCHORED to the canvas edge, an AHD draws 1:1 over the waveform's own time axis — plus a round mid-segment knot on every sloped stage that has a duration. Every vertex clamped in-canvas. Shares the `EnvNode`/`StageEnvelope`/`timeToX`/`levelToY` vocabulary with `envelope_edit` so the drawn handle and its grab region agree pixel-for-pixel. No VST3/REAPER/LICE types at the boundary.
|
||||
- `envelope_edit` — pure node hit-test + pixel-delta→clamped-param inverse map for the draggable envelope nodes and their curve knots (read from `envelope_edit.h`): `nodeAtPoint` resolves a grab to the nearest node within a pick radius (Chebyshev distance, draw-order tie-break, knots appended last so a coincident endpoint handle wins); `resolveNodeDrag` maps a pixel delta since grab to a new `StageEnvelope` under the same caller-supplied per-param clamp bounds the knobs use — a drag can never produce a param a knob couldn't. Mirror of `card_drag`/`waveform_view`; the inverse of `envelope_overlay`'s params→polyline forward map, so node-drag, knot-drag and knob-edit read/write one shared model and can never diverge.
|
||||
|
||||
@@ -90,8 +90,16 @@ void Voice::start(int note, int velocity, const SampleData& sample, bool declick
|
||||
}
|
||||
|
||||
// The pitch AHD's Hold fraction is taken against the whole playable span, so its three
|
||||
// stages lay 1:1 over the waveform from the start point.
|
||||
pitchEnv_.configure(postStart, p.pitchEnv);
|
||||
// stages lay 1:1 over the waveform from the start point. postStart is a SOURCE-frame count
|
||||
// and this envelope counts OUTPUT frames (envelopes.h), so Varispeed — which consumes
|
||||
// baseRatio_ source frames per output frame — needs the span converted, or a transposed
|
||||
// note's envelope outruns (or outlives) the note it shapes. Preserve reads at the source
|
||||
// rate, so its two domains already coincide.
|
||||
const double pitchSpan =
|
||||
(pitchEngine_ == PitchEngine::Preserve || !(baseRatio_ > 0.0))
|
||||
? static_cast<double>(postStart)
|
||||
: static_cast<double>(postStart) / baseRatio_;
|
||||
pitchEnv_.configure(static_cast<std::int64_t>(pitchSpan + 0.5), p.pitchEnv);
|
||||
pitchEnv_.noteOn();
|
||||
|
||||
// A restart lands every live glide back on the new note's own values, at a step derived
|
||||
|
||||
@@ -348,6 +348,12 @@ private:
|
||||
// play span ends within the ramp). With no declick (the common case) this is
|
||||
// byte-identical to the plain idle-out.
|
||||
if (triggerRanOff || readPos_ >= static_cast<double>(frameCount)) {
|
||||
// The NOTE is over the moment the read head leaves its span, whether or not a ramp
|
||||
// still rings: no later frame can carry envelope output. Latching here is what keeps
|
||||
// a ringing-out voice out of soundingNote() — the Preserve cap would otherwise
|
||||
// refuse a new onset, and mono legato would retune a voice already past its end
|
||||
// (silencing the new note) for the whole ~4 ms ramp.
|
||||
amplitudeDone_ = true;
|
||||
if (declickPending_) seedDeclick();
|
||||
if (!declickActive_) seedTerminalDeclick();
|
||||
if (declickActive_) {
|
||||
@@ -376,8 +382,11 @@ private:
|
||||
// Peer of the read-head exhaustion path above: a Trigger AHD whose stages end BEFORE
|
||||
// the play span (a zero decay, which the shape deliberately keeps expressible) cuts the
|
||||
// same synthetic Preserve tail at whatever level it was at. Seeded from lastOut, which
|
||||
// still holds the PREVIOUS frame — this one is already silent. Gate is left out on
|
||||
// purpose: its amplitude reaches zero through a release, so there is no cut to ring out.
|
||||
// still holds the PREVIOUS frame — this one is already silent. Gate is left out of THIS
|
||||
// site only: its amplitude reaches zero through a release, so nothing here is cut
|
||||
// mid-level. The exhaustion path above deliberately does NOT exclude Gate — a held Gate
|
||||
// note whose source runs out with no loop is cut at its sustain level, and under
|
||||
// Preserve that cut lands on the same recycled synthetic tail.
|
||||
if (amplitudeDone_ && amp == 0.0 && !declickActive_ &&
|
||||
playMode_ == PlayMode::Trigger) {
|
||||
seedTerminalDeclick();
|
||||
|
||||
@@ -91,8 +91,26 @@ namespace reasampler::instrument::map {
|
||||
// seconds at the project rate the reader is handed. v10 writes ZERO into both — the values
|
||||
// live in the AHD now, so a DOWNGRADE to a pre-v10 binary loses the Trigger amp shape.
|
||||
//
|
||||
// LOSSY UNDER A RATE MISMATCH. The fades were SOURCE frames and the AHD stores wall-clock
|
||||
// seconds, so the lift divides by the PROJECT rate while the build later multiplies by the
|
||||
// DECODE rate: a file whose own rate differs from the project's comes back scaled by that
|
||||
// ratio (a 441-frame fade on a 44.1 kHz file in a 48 kHz project resolves to 405 source
|
||||
// frames, ~8% short). The codec cannot close this — it never sees the file — and deferring the
|
||||
// lift to build time would mean carrying the retired fade pair through the parameter set,
|
||||
// reintroducing the mechanism the AHD replaced.
|
||||
//
|
||||
// A truncated/unknown/empty payload yields the DEFAULT parameter set.
|
||||
|
||||
// The exponents the lifted fades take. The AHD's curve law is phi^p (core/util/curve_law.h),
|
||||
// which cannot reproduce the retired pair's equal-power sin/cos exactly at ANY exponent — so
|
||||
// the lift takes the MINIMAX fit rather than the linear neutral, which is free (one constant,
|
||||
// written once here) and several times closer. The two differ because the two stages fit
|
||||
// different forms: attack fits phi^p to sin(pi*phi/2), decay fits 1 - t^q to cos(pi*t/2).
|
||||
// The measured bounds are asserted in tests/test_component_state_io.cpp. Every OTHER curve on
|
||||
// a migrated blob still lifts to the neutral — only the fades had a prior shape to reproduce.
|
||||
inline constexpr double kTriggerFadeLiftAttackCurve = 0.6133;
|
||||
inline constexpr double kTriggerFadeLiftDecayCurve = 1.7437;
|
||||
|
||||
inline constexpr std::uint32_t kPerformanceStateVersion = 2;
|
||||
|
||||
// The params-payload format version and its detection marker. The marker is a high sentinel
|
||||
|
||||
@@ -61,15 +61,17 @@ void putAhd(std::vector<std::uint8_t>& out, const AhdSeconds& a) {
|
||||
}
|
||||
// THE lift of the retired Trigger fade pair onto the AHD that replaced it: Attack takes the
|
||||
// fade-in, Decay the fade-out, Hold the whole remainder — so a zero fade-out lands Decay = 0
|
||||
// and the abrupt end an old instance could express stays representable. The fades were SOURCE
|
||||
// frames and the AHD stores wall-clock seconds, so the conversion goes through the same
|
||||
// project rate the v3 lift already uses. A v10-or-newer blob overwrites this from its own tail.
|
||||
// and the abrupt end an old instance could express stays representable. The seconds conversion
|
||||
// and its rate-mismatch bound, and the two fitted exponents, are documented in
|
||||
// component_state_io.h. A v10-or-newer blob overwrites all five fields from its own tail.
|
||||
void liftTriggerFades(std::int64_t fadeInFrames, std::int64_t fadeOutFrames, double projectRate,
|
||||
AhdSeconds& out) {
|
||||
const double rate = projectRate > 0.0 ? projectRate : 1.0;
|
||||
out.attackSeconds = static_cast<double>(fadeInFrames > 0 ? fadeInFrames : 0) / rate;
|
||||
out.decaySeconds = static_cast<double>(fadeOutFrames > 0 ? fadeOutFrames : 0) / rate;
|
||||
out.holdFraction = 1.0;
|
||||
out.attackCurve = kTriggerFadeLiftAttackCurve;
|
||||
out.decayCurve = kTriggerFadeLiftDecayCurve;
|
||||
}
|
||||
|
||||
// Read the play tail (v5 shape onward) into `p`. Shared by the legacy zone reader and the
|
||||
|
||||
@@ -191,6 +191,32 @@ bool isLiveDeckParam(DeckParam id) {
|
||||
return false; // unreachable for a valid enumerator; silences a warning.
|
||||
}
|
||||
|
||||
OverlayEnv overlayEnvForRadio(int radioId) {
|
||||
switch (static_cast<DeckParam>(radioId)) {
|
||||
case DeckParam::kAmpEnvSelect: return OverlayEnv::kAmp;
|
||||
case DeckParam::kPitchEnvSelect: return OverlayEnv::kPitch;
|
||||
case DeckParam::kFilterEnvSelect: return OverlayEnv::kFilter;
|
||||
default: return OverlayEnv::kNone;
|
||||
}
|
||||
}
|
||||
|
||||
OverlayEnv nextOverlaySelection(OverlayEnv current, int radioId) {
|
||||
const OverlayEnv picked = overlayEnvForRadio(radioId);
|
||||
if (picked == OverlayEnv::kNone) return current; // not a radio: nothing selects
|
||||
return (current == picked) ? OverlayEnv::kNone : picked;
|
||||
}
|
||||
|
||||
bool overlayEnvInert(OverlayEnv env, bool pitchEnvEnabled, bool filterEnabled) {
|
||||
switch (env) {
|
||||
case OverlayEnv::kPitch: return !pitchEnvEnabled;
|
||||
case OverlayEnv::kFilter: return !filterEnabled;
|
||||
case OverlayEnv::kAmp:
|
||||
case OverlayEnv::kNone:
|
||||
return false;
|
||||
}
|
||||
return false; // unreachable for a valid enumerator; silences a warning.
|
||||
}
|
||||
|
||||
bool liveCommitFor(LiveDragKind kind, int paramId) {
|
||||
switch (kind) {
|
||||
case LiveDragKind::kDeckKnob:
|
||||
|
||||
@@ -133,6 +133,25 @@ enum class LiveDragKind { kOther, kDeckKnob, kEnvNode };
|
||||
// can reach — AHDSR or AHD, on any of the three envelopes — is itself live.
|
||||
bool liveCommitFor(LiveDragKind kind, int paramId);
|
||||
|
||||
// Which envelope the waveform overlay draws and edits. Exclusive across the three envelope
|
||||
// decks, and kNone is a valid resting state — the editor opens there. Transient view state:
|
||||
// never persisted, never a parameter.
|
||||
enum class OverlayEnv { kNone, kAmp, kPitch, kFilter };
|
||||
|
||||
// The envelope a deck's overlay-select radio picks; kNone for any other control id.
|
||||
OverlayEnv overlayEnvForRadio(int radioId);
|
||||
|
||||
// The selection a click on `radioId` produces from `current`. Two rules, provable here rather
|
||||
// than in the shell: picking another deck's radio switches to it (exclusivity), and clicking
|
||||
// the ACTIVE one clears back to kNone — "no envelope shown" is a state the user can get back
|
||||
// to, not an error. A non-radio id leaves the selection alone.
|
||||
OverlayEnv nextOverlaySelection(OverlayEnv current, int radioId);
|
||||
|
||||
// Whether the overlay for `env` is INERT: its deck group's enable toggle is off, so its knobs
|
||||
// are drawn-but-dead and a node drag on the same params must be too — otherwise a drag reaches
|
||||
// a param a knob couldn't (envelope_edit.h). Amp has no enable toggle and is never inert.
|
||||
bool overlayEnvInert(OverlayEnv env, bool pitchEnvEnabled, bool filterEnabled);
|
||||
|
||||
// The deck's BIPOLAR knob law: 0.5 of the knob's travel is zero depth, the ends are -1 and
|
||||
// +1. Exact inverses, and exact at the centre detent (0.5 -> 0 -> 0.5), so a knob parked at
|
||||
// centre can never persist a hair of modulation. Out-of-range norm clamps to the endpoints.
|
||||
|
||||
@@ -11,11 +11,13 @@ per-segment envelope curve law.
|
||||
- `file_bytes` (`core/util`) — the ONE whole-file byte loader (Q-W1), linked by both artifacts; blocking I/O, off-audio-thread only.
|
||||
- `clamp01` (`core/util`, header-only) — the ONE unit-interval clamp (Q-W1), replacing four per-module static copies; NaN passes through unchanged rather than collapsing to a bound.
|
||||
- `curve_law` (`core/util`, header-only) — the ONE per-segment envelope curve law: the
|
||||
exponent domain (0.1..10, neutral 1.0), the normalized-position -> normalized-level map, and
|
||||
the mid-segment inverse an overlay knot drags through. Header-only and dependency-free so
|
||||
the engine's evaluator, the overlay's forward map, its inverse, and the deck's inner dial all
|
||||
read one law instead of four copies. **The neutral exponent is the IDENTITY, bit for bit** —
|
||||
that is what makes an instance saved before curves existed play unchanged.
|
||||
exponent domain (0.1..10, neutral 1.0), the normalized-position -> normalized-level map, the
|
||||
mid-segment inverse an overlay knot drags through, and the inner dial's own norm<->exponent
|
||||
travel. Header-only and dependency-free so the engine's evaluator, the overlay's forward map,
|
||||
its inverse, and the deck's inner dial all read one law instead of four copies.
|
||||
**The neutral exponent is the IDENTITY, bit for bit** — that is what makes an instance saved
|
||||
before curves existed play unchanged, and what the knob law's centre detent exists to keep
|
||||
reachable from the dial.
|
||||
- `relative_path` (`core/util`, header-only) — the ONE absolute-path rejection test behind the relative-paths-only invariant, shared by `bank_model` (`Sample.relativePath`) and `core/tracking/origin_ledger` (`OriginRecord.relativePath`). The two must reject identically or a path one accepts could be smuggled past the other; that is why it is one function and not two.
|
||||
|
||||
## Gotchas
|
||||
|
||||
@@ -19,6 +19,12 @@ inline constexpr double kCurveMax = 10.0;
|
||||
// at-rest per-sample path pays one predicted branch instead of a transcendental; every
|
||||
// positive exponent maps 0 -> 0 and 1 -> 1, so a curved stage can never overshoot its own
|
||||
// endpoint levels.
|
||||
//
|
||||
// MEASURED (Release, MSVC 19.44 x64, one dev machine): a non-neutral exponent costs ~4.7 ns per
|
||||
// evaluation. At the 16-voice default with all three envelopes in a sloped stage — three
|
||||
// evaluations per voice per frame, the worst case — that is +224 ns per output frame: 3.1% of
|
||||
// one core at 44.1 kHz becomes 4.1%. Affordable at the shipped voice ceiling; re-measure before
|
||||
// putting a fourth per-voice curve on the frame.
|
||||
inline double curveMap(double phi, double exponent) {
|
||||
if (exponent == kCurveNeutral) return phi;
|
||||
return std::pow(phi, exponent);
|
||||
@@ -29,6 +35,29 @@ inline double clampCurve(double exponent) {
|
||||
return exponent > kCurveMax ? kCurveMax : exponent;
|
||||
}
|
||||
|
||||
// The exponent's KNOB travel: logarithmic, so the two halves of the throw are the reciprocal
|
||||
// shaping directions. Written as kCurveMax^(2t-1) rather than as an interpolation between
|
||||
// log(kCurveMin) and log(kCurveMax) so t == 0.5 evaluates exp(0) == 1.0 EXACTLY — an inexact
|
||||
// centre would put std::pow on the per-sample path for a stage the user believes is parked at
|
||||
// the identity. Requires kCurveMin == 1/kCurveMax, which the domain above satisfies.
|
||||
//
|
||||
// The detent is what makes the identity REACHABLE: a knob drag delivers start - dy/128, a grid
|
||||
// that lands on 0.5 only by luck, so a band wider than one drag step (1/128) snaps to neutral
|
||||
// and a dial swept through the centre cannot skip over it.
|
||||
inline constexpr double kCurveKnobDetent = 0.01;
|
||||
|
||||
inline double curveFromKnobNorm(double norm) {
|
||||
const double t = norm < 0.0 ? 0.0 : (norm > 1.0 ? 1.0 : norm);
|
||||
const double off = t - 0.5;
|
||||
if (off < kCurveKnobDetent && off > -kCurveKnobDetent) return kCurveNeutral;
|
||||
return clampCurve(std::exp((2.0 * t - 1.0) * std::log(kCurveMax)));
|
||||
}
|
||||
|
||||
inline double knobNormFromCurve(double exponent) {
|
||||
const double t = 0.5 + std::log(clampCurve(exponent)) / (2.0 * std::log(kCurveMax));
|
||||
return t < 0.0 ? 0.0 : (t > 1.0 ? 1.0 : t);
|
||||
}
|
||||
|
||||
// The normalized level at a segment's MIDPOINT (phi = 0.5) — where the overlay places the
|
||||
// draggable curve knot — and its inverse. The pair is what keeps knot-drag and inner dial on
|
||||
// one value: both resolve through this law, not through each other.
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "shell/instrument/reasampler_editor.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath> // log/exp (the curve knob's logarithmic travel)
|
||||
#include <cstdint>
|
||||
#include <cstdio> // snprintf (deck value labels)
|
||||
#include <string>
|
||||
@@ -49,23 +48,12 @@ namespace {
|
||||
// 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.
|
||||
constexpr double kEnvTimeMaxSeconds = 2.0; // every stage-time knob's ceiling (seconds)
|
||||
//
|
||||
// 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;
|
||||
constexpr double kPitchDepthMaxSemis = 24.0; // pitch depth throw: +/-24 st, centered
|
||||
constexpr double kKeyTrackMax = 2.0; // key-track slider ceiling (0..200%)
|
||||
|
||||
// A curve exponent's knob travel is LOGARITHMIC: 0.5 is the linear neutral, so the two halves
|
||||
// of the throw are the reciprocal shaping directions and the neutral sits at a centre detent.
|
||||
double curveFromNorm(double norm) {
|
||||
const double t = clamp01(norm);
|
||||
return std::exp(std::log(util::kCurveMin) +
|
||||
t * (std::log(util::kCurveMax) - std::log(util::kCurveMin)));
|
||||
}
|
||||
double normFromCurve(double curve) {
|
||||
const double c = util::clampCurve(curve);
|
||||
return clamp01((std::log(c) - std::log(util::kCurveMin)) /
|
||||
(std::log(util::kCurveMax) - std::log(util::kCurveMin)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ReaSamplerEditor::FaceLayout ReaSamplerEditor::faceLayout(int w, int h) const {
|
||||
@@ -91,23 +79,23 @@ double ReaSamplerEditor::controlValue(int id, const PlaySeconds& play) const {
|
||||
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 normFromCurve(play.adsr.attackCurve);
|
||||
case ParamControl::kDecayCurve: return normFromCurve(play.adsr.decayCurve);
|
||||
case ParamControl::kReleaseCurve: return normFromCurve(play.adsr.releaseCurve);
|
||||
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 normFromCurve(play.trigAhd.attackCurve);
|
||||
case ParamControl::kTrigDecayCurve: return normFromCurve(play.trigAhd.decayCurve);
|
||||
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 normFromCurve(play.pitchEnv.shape.attackCurve);
|
||||
return util::knobNormFromCurve(play.pitchEnv.shape.attackCurve);
|
||||
case ParamControl::kPitchEnvDecayCurve:
|
||||
return normFromCurve(play.pitchEnv.shape.decayCurve);
|
||||
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));
|
||||
@@ -129,18 +117,18 @@ double ReaSamplerEditor::controlValue(int id, const PlaySeconds& play) const {
|
||||
case ParamControl::kFilterEnvSustain: return clamp01(play.filter.env.sustainLevel);
|
||||
case ParamControl::kFilterEnvRelease: return secToNorm(play.filter.env.releaseSeconds);
|
||||
case ParamControl::kFilterEnvAttackCurve:
|
||||
return normFromCurve(play.filter.env.attackCurve);
|
||||
return util::knobNormFromCurve(play.filter.env.attackCurve);
|
||||
case ParamControl::kFilterEnvDecayCurve:
|
||||
return normFromCurve(play.filter.env.decayCurve);
|
||||
return util::knobNormFromCurve(play.filter.env.decayCurve);
|
||||
case ParamControl::kFilterEnvReleaseCurve:
|
||||
return normFromCurve(play.filter.env.releaseCurve);
|
||||
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 normFromCurve(play.filter.trigEnv.attackCurve);
|
||||
return util::knobNormFromCurve(play.filter.trigEnv.attackCurve);
|
||||
case ParamControl::kFilterTrigDecayCurve:
|
||||
return normFromCurve(play.filter.trigEnv.decayCurve);
|
||||
return util::knobNormFromCurve(play.filter.trigEnv.decayCurve);
|
||||
default: return 0.0;
|
||||
}
|
||||
}
|
||||
@@ -160,9 +148,9 @@ void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
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 = curveFromNorm(value); break;
|
||||
case ParamControl::kDecayCurve: play.adsr.decayCurve = curveFromNorm(value); break;
|
||||
case ParamControl::kReleaseCurve: play.adsr.releaseCurve = curveFromNorm(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));
|
||||
@@ -171,9 +159,9 @@ void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
case ParamControl::kTrigHold: play.trigAhd.holdFraction = clamp01(value); break;
|
||||
case ParamControl::kTrigDecay: play.trigAhd.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kTrigAttackCurve:
|
||||
play.trigAhd.attackCurve = curveFromNorm(value); break;
|
||||
play.trigAhd.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kTrigDecayCurve:
|
||||
play.trigAhd.decayCurve = curveFromNorm(value); break;
|
||||
play.trigAhd.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvEnable:
|
||||
play.pitchEnv.enabled = (segment == 1);
|
||||
break;
|
||||
@@ -184,9 +172,9 @@ void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
case ParamControl::kPitchEnvDecay:
|
||||
play.pitchEnv.shape.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kPitchEnvAttackCurve:
|
||||
play.pitchEnv.shape.attackCurve = curveFromNorm(value); break;
|
||||
play.pitchEnv.shape.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvDecayCurve:
|
||||
play.pitchEnv.shape.decayCurve = curveFromNorm(value); break;
|
||||
play.pitchEnv.shape.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kPitchEnvDepth:
|
||||
play.pitchEnv.peakSemitones = (clamp01(value) - 0.5) * 2.0 * kPitchDepthMaxSemis;
|
||||
break;
|
||||
@@ -218,11 +206,11 @@ void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
case ParamControl::kFilterEnvRelease:
|
||||
play.filter.env.releaseSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterEnvAttackCurve:
|
||||
play.filter.env.attackCurve = curveFromNorm(value); break;
|
||||
play.filter.env.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterEnvDecayCurve:
|
||||
play.filter.env.decayCurve = curveFromNorm(value); break;
|
||||
play.filter.env.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterEnvReleaseCurve:
|
||||
play.filter.env.releaseCurve = curveFromNorm(value); break;
|
||||
play.filter.env.releaseCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterTrigAttack:
|
||||
play.filter.trigEnv.attackSeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterTrigHold:
|
||||
@@ -230,9 +218,9 @@ void ReaSamplerEditor::applyControl(int id, PlaySeconds& play, double value,
|
||||
case ParamControl::kFilterTrigDecay:
|
||||
play.filter.trigEnv.decaySeconds = normToSec(value); break;
|
||||
case ParamControl::kFilterTrigAttackCurve:
|
||||
play.filter.trigEnv.attackCurve = curveFromNorm(value); break;
|
||||
play.filter.trigEnv.attackCurve = util::curveFromKnobNorm(value); break;
|
||||
case ParamControl::kFilterTrigDecayCurve:
|
||||
play.filter.trigEnv.decayCurve = curveFromNorm(value); break;
|
||||
play.filter.trigEnv.decayCurve = util::curveFromKnobNorm(value); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -385,7 +373,7 @@ std::string ReaSamplerEditor::deckValueLabel(int id) const {
|
||||
case ParamControl::kFilterEnvReleaseCurve:
|
||||
case ParamControl::kFilterTrigAttackCurve:
|
||||
case ParamControl::kFilterTrigDecayCurve:
|
||||
snprintf(buf, sizeof(buf), "^%.2f", curveFromNorm(controlValue(id, play)));
|
||||
snprintf(buf, sizeof(buf), "^%.2f", util::curveFromKnobNorm(controlValue(id, play)));
|
||||
break;
|
||||
default:
|
||||
// -2 (preview velocity) is labeled at its chrome call site; nothing else here.
|
||||
@@ -406,15 +394,6 @@ EnvClampBounds ReaSamplerEditor::envClampBounds() const {
|
||||
return b;
|
||||
}
|
||||
|
||||
ReaSamplerEditor::OverlayEnv ReaSamplerEditor::overlayEnvForRadio(int radioId) {
|
||||
switch (static_cast<ParamControl>(radioId)) {
|
||||
case ParamControl::kAmpEnvSelect: return OverlayEnv::kAmp;
|
||||
case ParamControl::kPitchEnvSelect: return OverlayEnv::kPitch;
|
||||
case ParamControl::kFilterEnvSelect: return OverlayEnv::kFilter;
|
||||
default: return OverlayEnv::kNone;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
// The two directions of the AHDSR <-> StageEnvelope copy, so a field can only be forgotten in
|
||||
// one place rather than two.
|
||||
|
||||
@@ -51,10 +51,7 @@ bool ReaSamplerEditor::mouseDownDeck(const FaceLayout& fl, int x, int y) {
|
||||
const DeckLayout dl = layoutDeck(fl.deckDescs, band.x, band.y, band.width);
|
||||
const DeckHit hit = hitTestDeck(dl, x, y);
|
||||
if (hit.kind == DeckHitKind::CaptionRadio) {
|
||||
// Exclusive across the three envelope decks, and clicking the active one clears it —
|
||||
// "no envelope shown" is a state the user can get back to, not an error.
|
||||
const OverlayEnv picked = overlayEnvForRadio(hit.id);
|
||||
overlayEnv_ = (overlayEnv_ == picked) ? OverlayEnv::kNone : picked;
|
||||
overlayEnv_ = nextOverlaySelection(overlayEnv_, hit.id);
|
||||
invalidate(); // view state only: no parameter write, no reload
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,13 @@ bool ReaSamplerEditor::mouseDownWaveform(const FaceLayout& fl, int x, int y) {
|
||||
const OverlayArea overlay = waveformOverlayArea(fl.bands.waveform);
|
||||
|
||||
// Envelope nodes first (they sit on top of the markers), then the wave markers. With no
|
||||
// envelope overlay-active there are no nodes at all and the markers take every grab.
|
||||
// envelope overlay-active — or with its deck group's enable toggle off, which makes the
|
||||
// same params' knobs inert — there are no grabbable nodes and the markers take every grab.
|
||||
const double rate = liveSampleRate();
|
||||
if (rate > 0.0 && overlayEnv_ != OverlayEnv::kNone) {
|
||||
const bool nodesLive =
|
||||
overlayEnv_ != OverlayEnv::kNone &&
|
||||
!overlayEnvInert(overlayEnv_, params_.play.pitchEnv.enabled, params_.play.filter.enabled);
|
||||
if (rate > 0.0 && nodesLive) {
|
||||
const std::int64_t startFrame = params_.startPoint.value_or(0);
|
||||
const StageEnvelope env = packEnvelope(overlayEnv_, params_.play, frames, startFrame);
|
||||
const double totalSeconds = static_cast<double>(frames) / rate;
|
||||
|
||||
@@ -81,10 +81,10 @@ private:
|
||||
enum class DragKind { kNone, kRootMarker, kWaveMarker, kScrollThumb, kEnvNode,
|
||||
kCurveNode, kDeckKnob };
|
||||
|
||||
// Which envelope the waveform overlay is drawing and editing. Exclusive, and kNone is a
|
||||
// valid resting state — the editor opens there. Transient view state: never persisted,
|
||||
// never a parameter.
|
||||
enum class OverlayEnv { kNone, kAmp, kPitch, kFilter };
|
||||
// Which envelope the waveform overlay is drawing and editing. The selection type and its
|
||||
// whole state machine are the pure deck_groups module's; this alias keeps the shell's
|
||||
// spelling.
|
||||
using OverlayEnv = instrument::ui::OverlayEnv;
|
||||
|
||||
// Controls on the setup surface. The int value is the opaque control id the pure
|
||||
// knob_deck hit-test returns; the shell maps it to the one parameter set or a
|
||||
@@ -335,10 +335,6 @@ private:
|
||||
// UNPACK (commit): an edited StageEnvelope -> the play params, in place.
|
||||
void unpackEnvelope(OverlayEnv which, const StageEnvelope& env, PlaySeconds& play) const;
|
||||
|
||||
// The radio control id that selects `which`, and its inverse. One table, so the deck's
|
||||
// radio and the overlay can never drift apart.
|
||||
static OverlayEnv overlayEnvForRadio(int radioId);
|
||||
|
||||
// Clamp bounds envelope_edit uses, matching the sliders' own domains so a node drag can
|
||||
// never produce a param a slider couldn't.
|
||||
EnvClampBounds envClampBounds() const;
|
||||
|
||||
Reference in New Issue
Block a user