DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::GranularProcessor< T > Class Template Reference

Granular clouds and spectral-freeze textures from live input. More...

#include <GranularProcessor.h>

Public Member Functions

void prepare (const AudioSpec &spec, double bufferSeconds=4.0)
 Allocates the capture ring and grain pool.
 
void reset () noexcept
 Kills all grains and clears the capture ring. RT-safe.
 
void setGrainSize (T ms) noexcept
 Grain duration in milliseconds [10, 500] (default 80). Non-finite values are ignored.
 
void setDensity (T perSecond) noexcept
 Grains per second [1, 200] (default 25). Non-finite values are ignored.
 
void setJitter (T amount) noexcept
 Position jitter [0, 1]: how far back grains may start (default 0.3). Non-finite values are ignored.
 
void setPitch (T semitones) noexcept
 Per-grain pitch shift in semitones [-24, +24] (default 0). Non-finite values are ignored.
 
void setPitchJitter (T semitones) noexcept
 Random pitch spread per grain in semitones [0, 12] (default 0). Non-finite values are ignored.
 
void setSpread (T amount) noexcept
 Stereo spread of grain panning [0, 1] (default 0.5). Non-finite values are ignored.
 
void setFreeze (bool frozen) noexcept
 Freezes capture: grains keep playing the held history.
 
void setMix (T mix) noexcept
 Dry/wet mix [0, 1] (default 1); smoothed linearly over one block. Non-finite values are ignored.
 
getGrainSize () const noexcept
 
getDensity () const noexcept
 
getJitter () const noexcept
 
getPitch () const noexcept
 
getPitchJitter () const noexcept
 
getSpread () const noexcept
 
bool getFreeze () const noexcept
 
getMix () const noexcept
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes a block in-place (1 or 2 channels). Pass-through until prepare() succeeds.
 

Static Public Member Functions

static constexpr int getLatency () noexcept
 Zero: the cloud is parallel to the dry path.
 

Static Public Attributes

static constexpr int kMaxGrains = 64
 

Detailed Description

template<FloatType T>
class dspark::GranularProcessor< T >

Granular clouds and spectral-freeze textures from live input.

Template Parameters
TSample type (float or double).

Definition at line 56 of file GranularProcessor.h.

Member Function Documentation

◆ getDensity()

template<FloatType T>
T dspark::GranularProcessor< T >::getDensity ( ) const
inlinenoexcept

Definition at line 176 of file GranularProcessor.h.

◆ getFreeze()

template<FloatType T>
bool dspark::GranularProcessor< T >::getFreeze ( ) const
inlinenoexcept

Definition at line 181 of file GranularProcessor.h.

◆ getGrainSize()

template<FloatType T>
T dspark::GranularProcessor< T >::getGrainSize ( ) const
inlinenoexcept

Definition at line 175 of file GranularProcessor.h.

◆ getJitter()

template<FloatType T>
T dspark::GranularProcessor< T >::getJitter ( ) const
inlinenoexcept

Definition at line 177 of file GranularProcessor.h.

◆ getLatency()

template<FloatType T>
static constexpr int dspark::GranularProcessor< T >::getLatency ( )
inlinestaticconstexprnoexcept

Zero: the cloud is parallel to the dry path.

Definition at line 185 of file GranularProcessor.h.

◆ getMix()

template<FloatType T>
T dspark::GranularProcessor< T >::getMix ( ) const
inlinenoexcept

Definition at line 182 of file GranularProcessor.h.

◆ getPitch()

template<FloatType T>
T dspark::GranularProcessor< T >::getPitch ( ) const
inlinenoexcept

Definition at line 178 of file GranularProcessor.h.

◆ getPitchJitter()

template<FloatType T>
T dspark::GranularProcessor< T >::getPitchJitter ( ) const
inlinenoexcept

Definition at line 179 of file GranularProcessor.h.

◆ getSpread()

template<FloatType T>
T dspark::GranularProcessor< T >::getSpread ( ) const
inlinenoexcept

Definition at line 180 of file GranularProcessor.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::GranularProcessor< T >::getState ( ) const
inline

Serializes the parameter state (setup/UI threads; allocates).

Definition at line 188 of file GranularProcessor.h.

◆ prepare()

template<FloatType T>
void dspark::GranularProcessor< T >::prepare ( const AudioSpec spec,
double  bufferSeconds = 4.0 
)
inline

Allocates the capture ring and grain pool.

Invalid specs (non-positive/non-finite rate, block size or channel count) are ignored: the previous state is kept and an unprepared instance stays pass-through. A non-finite bufferSeconds falls back to the 4 s default.

Parameters
specAudio environment specification.
bufferSecondsCapture history length, clamped to [0.5, 16] s (default 4 s).

Definition at line 75 of file GranularProcessor.h.

◆ processBlock()

template<FloatType T>
void dspark::GranularProcessor< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes a block in-place (1 or 2 channels). Pass-through until prepare() succeeds.

Definition at line 224 of file GranularProcessor.h.

◆ reset()

template<FloatType T>
void dspark::GranularProcessor< T >::reset ( )
inlinenoexcept

Kills all grains and clears the capture ring. RT-safe.

Definition at line 100 of file GranularProcessor.h.

◆ setDensity()

template<FloatType T>
void dspark::GranularProcessor< T >::setDensity ( perSecond)
inlinenoexcept

Grains per second [1, 200] (default 25). Non-finite values are ignored.

Definition at line 123 of file GranularProcessor.h.

◆ setFreeze()

template<FloatType T>
void dspark::GranularProcessor< T >::setFreeze ( bool  frozen)
inlinenoexcept

Freezes capture: grains keep playing the held history.

Definition at line 162 of file GranularProcessor.h.

◆ setGrainSize()

template<FloatType T>
void dspark::GranularProcessor< T >::setGrainSize ( ms)
inlinenoexcept

Grain duration in milliseconds [10, 500] (default 80). Non-finite values are ignored.

Definition at line 115 of file GranularProcessor.h.

◆ setJitter()

template<FloatType T>
void dspark::GranularProcessor< T >::setJitter ( amount)
inlinenoexcept

Position jitter [0, 1]: how far back grains may start (default 0.3). Non-finite values are ignored.

Definition at line 131 of file GranularProcessor.h.

◆ setMix()

template<FloatType T>
void dspark::GranularProcessor< T >::setMix ( mix)
inlinenoexcept

Dry/wet mix [0, 1] (default 1); smoothed linearly over one block. Non-finite values are ignored.

Definition at line 169 of file GranularProcessor.h.

◆ setPitch()

template<FloatType T>
void dspark::GranularProcessor< T >::setPitch ( semitones)
inlinenoexcept

Per-grain pitch shift in semitones [-24, +24] (default 0). Non-finite values are ignored.

Definition at line 139 of file GranularProcessor.h.

◆ setPitchJitter()

template<FloatType T>
void dspark::GranularProcessor< T >::setPitchJitter ( semitones)
inlinenoexcept

Random pitch spread per grain in semitones [0, 12] (default 0). Non-finite values are ignored.

Definition at line 147 of file GranularProcessor.h.

◆ setSpread()

template<FloatType T>
void dspark::GranularProcessor< T >::setSpread ( amount)
inlinenoexcept

Stereo spread of grain panning [0, 1] (default 0.5). Non-finite values are ignored.

Definition at line 155 of file GranularProcessor.h.

◆ setState()

template<FloatType T>
bool dspark::GranularProcessor< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores parameters from a blob (tolerant; rejects foreign ids).

Definition at line 205 of file GranularProcessor.h.

Member Data Documentation

◆ kMaxGrains

template<FloatType T>
constexpr int dspark::GranularProcessor< T >::kMaxGrains = 64
staticconstexpr

Definition at line 59 of file GranularProcessor.h.


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