Package net.paulhertz.pixelaudio.sampler
PixelAudio's sampler engine follows the chain
PASamplerInstrumentPoolMulti -> PASamplerInstrumentPool ->
PASamplerInstrument -> PASharedBufferSampler -> PASamplerVoice. Small sketches may
use PASamplerInstrument
directly, while larger gesture-driven sketches can route playback through one or more
instrument pools.
The package provides shared-buffer sample playback, polyphonic sampler instruments, ADSR envelope support, pitch and pan controls, gain staging, and event objects used by gesture-driven sampler workflows. It is built on the Minim library for Processing.
Immediate playback and scheduled playback both follow the same hierarchy. Calls made
on PASamplerInstrumentPoolMulti, PASamplerInstrumentPool, or
PASamplerInstrument are forwarded to the level below, ending in
PASharedBufferSampler,
where voices are allocated and mixed. The scheduled playback API mirrors the granular
synthesis API with startAtSampleTime(...) and startAfterDelaySamples(...)
methods. These methods schedule against the sampler's local audio-thread sample clock,
exposed by getCurrentSampleTime().
For cross-engine alignment, such as playing sampler and granular instruments from the same generated beat brush, application code should choose a shared transport clock and convert gesture or beat times to absolute sample times before calling either synth. The sampler-local clock is the timing mechanism for one sampler backend; it is not, by itself, a global application transport.
Sampler playback can optionally wrap finite source-buffer reads across the buffer boundary. This is distinct from looping: a wrapped event still ends according to its requested duration and envelope, but reads that pass the end of the buffer continue from the beginning.
Sampler playback processing chain
PASamplerInstrumentPoolMultimanages named sampler pools and routes playback to the active pool or a tagged pool.PASamplerInstrumentPoolowns a reusable group of sampler instruments, selects an available instrument for each event, and propagates buffer, gain, pan, pitch, and envelope defaults.PASamplerInstrumentapplies instrument-level gain, pitch, pan, envelope defaults, and sample-rate correction, then forwards playback requests to the sampler backend.PASharedBufferSamplerowns the voice pool for one shared mono buffer, starts voices, mixes active voices into Minim's audio callback, and applies mix normalization and soft clipping.PASamplerVoicereads samples from the source buffer, applies per-voice gain, pan, pitch, envelope state, looping state, and release/finish lifecycle handling.
Sampler synthesis engine
PASamplerInstrumentprovides the high-level instrument API for pan, gain, pitch scaling, envelopes, buffer replacement, and sampler backend access.PASamplerInstrumentPoolmanages a collection of sampler instruments for polyphony, reuse, and group gain.PASamplerInstrumentPoolMultimanages multiple sampler pools for multi-buffer or multi-sample playback.PASharedBufferSamplermanages sampler voices, voice pooling, looping defaults, panning, gain, smooth voice stealing, finite-event wrap-around, and mix profiles.PASamplerVoicerenders individual sampler voices with gain, pitch, pan, and optional ADSR envelope.
Interfaces and event data
PAPlayabledefines the minimal playable audio API used by sampler instruments and pools.PASamplerdefines the backend sampler contract, including immediate playback, scheduled playback, looping, stop, source-buffer playback sample rate, and buffer update methods.PASamplerPlayableextends PAPlayable for sample-based playback with buffer position, duration, gain, pitch, pan, and envelope parameters.PlaybackInfostores computed duration and timing information for triggered sampler events.PitchPolicydefines pitch behavior for sample playback.SamplerBrushEventstores gesture-derived sampler event data such as location, timing, sample position, gain, pitch, pan, and envelope.
Envelope support
ADSRParamsstores parameters for ADSR envelopes and can create Minim ADSR instances.ADSRUtilsprovides utility methods for fitting envelope times to event durations.SimpleADSRprovides a sample-by-sample ADSR envelope used by sampler voices.
-
ClassDescriptionValue object describing an ADSR envelope.Utility functions for ADSRParams.Generic interface for anything that can be "played." Provides a minimal playback API plus backward-compatible overloads for sampler instruments and other PAPlayable classes.Backend engine contract for sampler implementations.Represents a playable instrument that uses a PASampler instantiated as a PASharedBufferSampler to trigger audio playback from a shared buffer that is (currently) a Minim MultiChannelBuffer.Manages a group of PASamplerInstruments sharing the same source buffer and audio output.PASamplerInstrumentPoolMulti Manages multiple PASamplerInstrumentPool instances, each keyed by name.Specialized playable interface for sample-based instruments.PASamplerVoice - a single playback "voice" reading from a shared mono buffer.UGen-based sampler that plays multiple PASamplerVoice instances from a single shared mono buffer (channel 0 of a MultiChannelBuffer) which is an array of floating point samples over (-1.0..1.0).Mix-density normalization profiles for polyphonic sampler output, used to control noise and distortion.PitchPolicy determines how PASamplerInstrument / PASamplerVoice should interpret their pitch parameter in combination with a given PASource.Holds information about a triggered playback event.Stores values used for SamplerBrush event staging, used in tutorial examples such as
TutorialOne_03_Drawing.SimpleADSR - software envelope generator with optional exponential curves.