Class PABufferBackedSource
java.lang.Object
net.paulhertz.pixelaudio.granular.PABufferBackedSource
- All Implemented Interfaces:
PAFloatSource,PASource
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longBase offset applied to blockStart inrenderBlock(long, int, float[], float[]).private intprivate ddf.minim.analysis.WindowFunctionprivate final ddf.minim.MultiChannelBufferprivate final Stringprivate final PitchPolicyprivate final float -
Constructor Summary
ConstructorsConstructorDescriptionPABufferBackedSource(String name, float sampleRate, ddf.minim.MultiChannelBuffer mcb, PitchPolicy pitchPolicy) -
Method Summary
Modifier and TypeMethodDescriptionstatic PABufferBackedSourcefromChannels(String name, float sampleRate, float[]... channels) Copies per-channel arrays into an internal MultiChannelBuffer.static PABufferBackedSourceCopiesmonointo an internal 1-channel MultiChannelBuffer.static PABufferBackedSourcefromStereo(String name, float[] left, float[] right, float sampleRate) Copiesleft/rightinto an internal 2-channel MultiChannelBuffer.ddf.minim.MultiChannelBufferOptional access to an underlying MultiChannelBuffer, if this source is fundamentally buffer-backed (e.g., plain sample playback or a rendered granular "tape").floatConvenience (not required by PASource).longDuration in samples, or Long.MAX_VALUE if effectively infinite/streaming.name()Pitch policy hint for the instrument: should the instrument apply its pitch (playback rate) on top of this source?voidrenderBlock(long blockStart, int blockSize, float[] outL, float[] outR) Render audio into the given block buffers.voidseekTo(long absoluteSample) Optional seek/rewind hook, mainly for transport or "note-on" start time.voidsetGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples) toString()
-
Field Details
-
name
-
sampleRate
private final float sampleRate -
mcb
private final ddf.minim.MultiChannelBuffer mcb -
pitchPolicy
-
grainWindow
private ddf.minim.analysis.WindowFunction grainWindow -
grainLenSamples
private int grainLenSamples -
baseOffset
private volatile long baseOffsetBase offset applied to blockStart inrenderBlock(long, int, float[], float[]). Semantics: afterseekTo(long)with value T, a call to renderBlock(T, ...) begins reading from buffer index 0.
-
-
Constructor Details
-
PABufferBackedSource
public PABufferBackedSource(String name, float sampleRate, ddf.minim.MultiChannelBuffer mcb, PitchPolicy pitchPolicy)
-
-
Method Details
-
fromMono
Copiesmonointo an internal 1-channel MultiChannelBuffer. -
fromStereo
public static PABufferBackedSource fromStereo(String name, float[] left, float[] right, float sampleRate) Copiesleft/rightinto an internal 2-channel MultiChannelBuffer. -
fromChannels
Copies per-channel arrays into an internal MultiChannelBuffer. All channels must have the same length (frames). -
name
-
getSampleRate
public float getSampleRate()Convenience (not required by PASource). -
pitchPolicy
Description copied from interface:PASourcePitch policy hint for the instrument: should the instrument apply its pitch (playback rate) on top of this source?- Specified by:
pitchPolicyin interfacePASource
-
seekTo
public void seekTo(long absoluteSample) Description copied from interface:PASourceOptional seek/rewind hook, mainly for transport or "note-on" start time. Default implementation does nothing. -
getMultiChannelBuffer
public ddf.minim.MultiChannelBuffer getMultiChannelBuffer()Description copied from interface:PASourceOptional access to an underlying MultiChannelBuffer, if this source is fundamentally buffer-backed (e.g., plain sample playback or a rendered granular "tape"). Implementations that are not backed by a fixed buffer (true streams, procedural sources, etc.) should simply return null.- Specified by:
getMultiChannelBufferin interfacePASource
-
lengthSamples
public long lengthSamples()Description copied from interface:PAFloatSourceDuration in samples, or Long.MAX_VALUE if effectively infinite/streaming.- Specified by:
lengthSamplesin interfacePAFloatSource
-
setGrainWindow
public void setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples) - Specified by:
setGrainWindowin interfacePASource
-
renderBlock
public void renderBlock(long blockStart, int blockSize, float[] outL, float[] outR) Description copied from interface:PAFloatSourceRender audio into the given block buffers. Implementations should: - Assume outL/outR length >= blockSize. - Mix into outL/outR (add), not clear them. - Avoid allocation on the audio thread.- Specified by:
renderBlockin interfacePAFloatSource- Parameters:
blockStart- the absolute sample index in the source’s own sample domain (e.g., buffer index space).blockSize- number of samples in this block.outL- left channel buffer to mix into.outR- right channel buffer to mix into (may be same as outL for mono).
-
toString
-