Class PathGranularSource

java.lang.Object
net.paulhertz.pixelaudio.granular.PathGranularSource
All Implemented Interfaces:
PAFloatSource, PASource

public class PathGranularSource extends Object implements 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 Details

    • source

      private final float[] source
    • path

      private final GranularPath path
    • settings

      private final GranularSettings settings
    • sampleRate

      private final float sampleRate
    • windowCache

      private final WindowCache 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

  • Method Details

    • seekTo

      public void seekTo(long absoluteSample)
      Description copied from interface: PASource
      Optional seek/rewind hook, mainly for transport or "note-on" start time. Default implementation does nothing.
      Specified by:
      seekTo in interface PASource
      Parameters:
      absoluteSample - absolute sample index to seek to.
    • renderBlock

      public void renderBlock(long blockStart, int blockSize, float[] outL, float[] outR)
      Description copied from interface: PAFloatSource
      Render 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:
      renderBlock in interface PAFloatSource
      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: PAFloatSource
      Duration in samples, or Long.MAX_VALUE if effectively infinite/streaming.
      Specified by:
      lengthSamples in interface PAFloatSource
    • pitchPolicy

      public PitchPolicy pitchPolicy()
      Description copied from interface: PASource
      Pitch policy hint for the instrument: should the instrument apply its pitch (playback rate) on top of this source?
      Specified by:
      pitchPolicy in interface PASource
    • getSource

      public float[] getSource()
    • getPath

      public GranularPath getPath()
    • getSettings

      public GranularSettings getSettings()
    • clampPan

      private static float clampPan(float p)