Class thl::dsp::utils::MorphWindow#

class MorphWindow#

A bank of grain windows morphed by a continuous shape value and skewed by a tilt.

shape runs 0 .. NumShapes - 1: an integer lands exactly on that shape, a fraction is the linear blend of its two neighbours. tilt in [-1, 1] moves the window’s peak — 0 leaves it centred, +1 pushes it to the end, -1 to the start — by warping time piecewise-linearly around the peak, so the shape’s rise and fall keep their character. The rectangle (and anything within 2 % of it) is flat and ignores tilt.

Every shape is a k_resolution-point table normalised to peak 1 with both end points at 0, so a grain always starts and ends in silence. shared() is one process-wide instance built at static initialisation: no audio thread pays for the tables.

Public Functions

MorphWindow()#
float at(float phase, float shape, float tilt) const#

Window value at phase in [0, 1) for shape in [0, k_max_shape] and tilt in [-1, 1].

Inputs are clamped.

float shape_at(WindowShape shape, float phase) const#

One shape, untilted, at phase.

Public Static Functions

static float warp(float phase, float tilt)#

The tilt time-warp on its own: output phase -> source phase.

static std::string_view name(WindowShape shape)#
static const MorphWindow &shared()#

The process-wide bank.

Public Static Attributes

static constexpr size_t k_num_shapes = static_cast<size_t>(WindowShape::NumShapes)#
static constexpr size_t k_resolution = 512#
static constexpr float k_max_shape = static_cast<float>(k_num_shapes - 1)#