Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::FreezeLoopSamplerT< SampleType > Class Template Reference

#include <freeze_loop_sampler.hpp>

Public Types

enum class  CaptureResult { Success , InvalidLength , InsufficientHistory , ExceedsCapacity }

Public Member Functions

void prepare (int channels, int capacity, int crossfade)
int channels () const noexcept
int capacity () const noexcept
int available_history () const noexcept
bool frozen () const noexcept
int loop_length () const noexcept
std::size_t retained_bytes () const noexcept
void write (const SampleType *const *in, int n)
 Record n frames into the ring (call every block, always).
CaptureResult try_freeze_recent (int loop_samples) noexcept
 Capture exactly the most recent loop_samples frames.
SampleType loop_sample (int channel, int frame) const noexcept
void freeze (int loop_samples)
 Freeze the most recent loop_samples of recorded audio into a seamless loop.
void release ()
void read (SampleType *const *out, int n)
 Play the loop into out (frozen only).
void reset ()
void clear_history () noexcept
 Invalidate rolling input continuity without changing a captured loop.
std::vector< SampleType > snapshot () const
 Serialize the frozen loop: [channels][loop_len][crossfade][play_pos] then loop_len * channels samples.
bool restore (const std::vector< SampleType > &blob)
 Restore a loop produced by snapshot().

Member Enumeration Documentation

◆ CaptureResult

template<typename SampleType = float>
enum class pulp::signal::FreezeLoopSamplerT::CaptureResult
strong
Enumerator
Success 
InvalidLength 
InsufficientHistory 
ExceedsCapacity 

Member Function Documentation

◆ available_history()

template<typename SampleType = float>
int pulp::signal::FreezeLoopSamplerT< SampleType >::available_history ( ) const
inlinenoexcept

◆ capacity()

template<typename SampleType = float>
int pulp::signal::FreezeLoopSamplerT< SampleType >::capacity ( ) const
inlinenoexcept

◆ channels()

template<typename SampleType = float>
int pulp::signal::FreezeLoopSamplerT< SampleType >::channels ( ) const
inlinenoexcept

◆ clear_history()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::clear_history ( )
inlinenoexcept

Invalidate rolling input continuity without changing a captured loop.

State recall uses this after restoring the persistent loop because the pre-recall ring belongs to a different transport history.

◆ freeze()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::freeze ( int loop_samples)
inline

Freeze the most recent loop_samples of recorded audio into a seamless loop.

Clamped to what the ring can supply.

◆ frozen()

template<typename SampleType = float>
bool pulp::signal::FreezeLoopSamplerT< SampleType >::frozen ( ) const
inlinenoexcept

◆ loop_length()

template<typename SampleType = float>
int pulp::signal::FreezeLoopSamplerT< SampleType >::loop_length ( ) const
inlinenoexcept

◆ loop_sample()

template<typename SampleType = float>
SampleType pulp::signal::FreezeLoopSamplerT< SampleType >::loop_sample ( int channel,
int frame ) const
inlinenoexcept

◆ prepare()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::prepare ( int channels,
int capacity,
int crossfade )
inline
Parameters
channelschannel count
capacitymax samples per channel the record ring holds (must exceed the largest loop + crossfade + a block)
crossfadeloop-boundary crossfade length in samples RT contract: prepare(), snapshot(), and restore() allocate or copy variable-size storage and are not audio-thread safe. After prepare(), write(), freeze(), release(), read(), reset(), and accessors are allocation-free for the prepared channel/capacity bounds.

◆ read()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::read ( SampleType *const * out,
int n )
inline

Play the loop into out (frozen only).

Does nothing if not frozen — the caller passes the live signal through in that case.

◆ release()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::release ( )
inline

◆ reset()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::reset ( )
inline

◆ restore()

template<typename SampleType = float>
bool pulp::signal::FreezeLoopSamplerT< SampleType >::restore ( const std::vector< SampleType > & blob)
inline

Restore a loop produced by snapshot().

Returns false on a malformed or channel-mismatched blob without changing the current loop. Not RT-safe.

◆ retained_bytes()

template<typename SampleType = float>
std::size_t pulp::signal::FreezeLoopSamplerT< SampleType >::retained_bytes ( ) const
inlinenoexcept

◆ snapshot()

template<typename SampleType = float>
std::vector< SampleType > pulp::signal::FreezeLoopSamplerT< SampleType >::snapshot ( ) const
inline

Serialize the frozen loop: [channels][loop_len][crossfade][play_pos] then loop_len * channels samples.

Empty when not frozen. Not RT-safe.

◆ try_freeze_recent()

template<typename SampleType = float>
CaptureResult pulp::signal::FreezeLoopSamplerT< SampleType >::try_freeze_recent ( int loop_samples)
inlinenoexcept

Capture exactly the most recent loop_samples frames.

Unlike freeze(), this never clamps or pads: callers that own musical timing can reject a gesture without changing the current loop. The prepared ring and loop buffers exchange roles in constant time; the captured region remains circular and the former loop storage becomes an empty rolling history. No transition is baked into the captured region.

◆ write()

template<typename SampleType = float>
void pulp::signal::FreezeLoopSamplerT< SampleType >::write ( const SampleType *const * in,
int n )
inline

Record n frames into the ring (call every block, always).


The documentation for this class was generated from the following file: