Package net.paulhertz.pixelaudio.granular


package net.paulhertz.pixelaudio.granular
Granular synthesis classes for PixelAudio.

PixelAudio's granular synthesis engine follows the chain PAGranularInstrumentDirector -> PAGranularInstrument -> PAGranularSampler -> PAGranularVoice -> PASource. Example code makes exclusive use of PABurstGranularSource as the primary granular PASource.

Granular synthesis processing chain

  1. PAGranularInstrumentDirector receives a mono source buffer, gesture schedule, runtime synthesis parameters, and per-event parameters. It prepares event timing, resolves defaults, creates one PABurstGranularSource per gesture event, and schedules each source at an absolute sample time.
  2. PAGranularInstrument applies instrument-level gain, pan, and envelope defaults, then forwards immediate or scheduled playback requests to the sampler.
  3. PAGranularSampler owns the voice pool and sample-accurate scheduler. It starts voices immediately or when scheduled sample times arrive.
  4. PAGranularVoice applies the macro envelope, voice gain, pan, and lifecycle state while asking its PASource to render audio blocks.
  5. PABurstGranularSource renders the actual burst grains sample by sample, including source-buffer lookup, pitch-ratio playback, windowing, and overlap-add normalization.

Granular synthesis engine

  • PAGranularInstrumentDirector coordinates gesture playback, scheduling, event parameters, and granular source creation.
  • PAGranularInstrument provides the high-level instrument API for pan, gain, envelopes, looping, and scheduled starts.
  • PAGranularSampler manages granular voices, voice pooling, and sample-accurate scheduling.
  • PAGranularVoice renders individual granular voices with envelope, pan, gain, and optional looping.

Sources and audio data

  • PAFloatSource defines the minimal audio source abstraction used by granular voices.
  • PASource extends PAFloatSource with pitch-policy and buffer-access support.
  • PABurstGranularSource provides windowed granular synthesis with normalization and powers the granular synthesis engine.

Gesture configuration and event data

  • GestureGranularConfig stores editable gesture, timing, and synthesis settings, with builder support.
  • GestureGranularParams provides immutable granular playback parameters used by the engine.
  • GestureEventParams stores schedule-aligned sample indices and optional per-event pan, gain, and pitch data.

Utilities

  • WindowCache caches generated window curves for granular playback.
  • OverlapUtil computes block/span overlaps for sample-accurate audio processing.