Class MCBufferSource
java.lang.Object
net.paulhertz.pixelaudio.granular.MCBufferSource
- All Implemented Interfaces:
PAFloatSource,PASource
MCBufferSource
A simple PASource that wraps a Minim MultiChannelBuffer for linear playback.
This is a natural building block for PASamplerInstrument when you want
to work directly with buffer-backed sample sources.
NOTE:
- This class does not manage playback position on its own; typically a
PASamplerVoice will determine which segment to read and call
renderBlock(...) accordingly.
- For mono buffers, MultiChannelBuffer should have 1 channel.
- For stereo or multi-channel, the mixing logic belongs in renderBlock().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ddf.minim.MultiChannelBufferprivate intprivate ddf.minim.analysis.WindowFunctionprivate final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionddf.minim.MultiChannelBufferOptional access to an underlying MultiChannelBuffer, if this source is fundamentally buffer-backed (e.g., plain sample playback or a rendered granular "tape").longDuration in samples, or Long.MAX_VALUE if effectively infinite/streaming.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.voidsetGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples)
-
Field Details
-
buffer
private final ddf.minim.MultiChannelBuffer buffer -
lengthSamples
private final long lengthSamples -
grainWindow
private ddf.minim.analysis.WindowFunction grainWindow -
grainLenSamples
private int grainLenSamples
-
-
Constructor Details
-
MCBufferSource
public MCBufferSource(ddf.minim.MultiChannelBuffer buffer)
-
-
Method Details
-
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).
-
lengthSamples
public long lengthSamples()Description copied from interface:PAFloatSourceDuration in samples, or Long.MAX_VALUE if effectively infinite/streaming.- Specified by:
lengthSamplesin interfacePAFloatSource
-
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
-
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
-
setGrainWindow
public void setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples) - Specified by:
setGrainWindowin interfacePASource
-