Class PathGranularSource
java.lang.Object
net.paulhertz.pixelaudio.granular.PathGranularSource
- All Implemented Interfaces:
PAFloatSource,PASource
PathGranularSource
Granular source that:
- reads from a mono float[] source buffer,
- uses a GranularPath for where/how to place grains,
- applies per-grain gain and pan,
- can either:
* play grains on a fixed hop grid (hopSamples), or
* use per-grain timeOffsetMs to approximate the original gesture timing,
- uses a Minim WindowFunction.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final intprivate booleanprivate longprivate final intprivate final GranularPathprivate final floatprivate final GranularSettingsprivate final float[]private final WindowCacheprivate final ddf.minim.analysis.WindowFunction -
Constructor Summary
ConstructorsConstructorDescriptionPathGranularSource(float[] source, GranularPath path, GranularSettings settings, float sampleRate) -
Method Summary
Modifier and TypeMethodDescriptionprivate static floatclampPan(float p) getPath()float[]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.voidseekTo(long absoluteSample) Optional seek/rewind hook, mainly for transport or "note-on" start time.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.paulhertz.pixelaudio.granular.PASource
getMultiChannelBuffer, setGrainWindow
-
Field Details
-
source
private final float[] source -
path
-
settings
-
sampleRate
private final float sampleRate -
windowCache
-
hopSamples
private final int hopSamples -
defaultGrainLength
private final int defaultGrainLength -
windowFunction
private final ddf.minim.analysis.WindowFunction windowFunction -
numGrains
private final int numGrains -
noteStartSample
private long noteStartSample -
noteStarted
private boolean noteStarted
-
-
Constructor Details
-
PathGranularSource
public PathGranularSource(float[] source, GranularPath path, GranularSettings settings, float sampleRate)
-
-
Method Details
-
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. -
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
-
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
-
getSource
public float[] getSource() -
getPath
-
getSettings
-
clampPan
private static float clampPan(float p)
-