DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
GranularProcessor.h File Reference

Real-time granular engine: clouds, freeze, per-grain pitch/spread. More...

#include "../Core/AudioBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/DenormalGuard.h"
#include "../Core/DspMath.h"
#include "../Core/StateBlob.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <vector>
Include dependency graph for GranularProcessor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::GranularProcessor< T >
 Granular clouds and spectral-freeze textures from live input. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Real-time granular engine: clouds, freeze, per-grain pitch/spread.

A continuously captured stereo ring feeds a cloud of up to 64 overlapping grains. Each grain reads from a jittered position behind the write head with its own playback rate (pitch), Hann envelope (shared table) and equal-power pan; freeze stops capture so the cloud orbits the held buffer - the classic texture/freeze instrument.

Spawning uses a fractional accumulator (exact average density), grain parameters are randomized per spawn with deterministic LCG state, and everything is preallocated: zero allocation, zero latency.

Threading model: parameter setters/getters are std::atomic based and safe from any thread (non-finite values are ignored). prepare() is setup-thread only (allocates; invalid specs are ignored and an unprepared instance passes audio through). reset() belongs to the stream owner. getState()/setState() are setup/UI threads. The dry/wet mix is smoothed linearly over one block (the grain cloud is decorrelated from the dry signal, so an unsmoothed step would click). Channels beyond the first two pass through untouched.

Dependencies: Core/AudioSpec.h, Core/AudioBuffer.h, Core/DspMath.h, Core/DenormalGuard.h, Core/StateBlob.h.

Definition in file GranularProcessor.h.