Class PABurstGranularSource

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

public final class PABurstGranularSource extends Object implements PASource
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
     
    private final int
     
    private float
     
    private int
     
    private ddf.minim.analysis.WindowFunction
     
    private final int
     
    private boolean
     
    private long
     
    private final float
     
    private final float[]
     
    private final int
     
    private float[]
     
    private float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PABurstGranularSource(float[] source, int baseIndex, int grainLengthSamples, int burstGrains, int timeHopSamples, int indexHopSamples, float pitchRatio)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    ensureWSum(int blockSize)
     
    float
     
    long
    Duration 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?
    private static float
    readLinear(float[] buf, float pos)
     
    void
    renderBlock(long blockStart, int blockSize, float[] outL, float[] outR)
    Render audio into the given block buffers.
    void
    seekTo(long absoluteSample)
    Optional seek/rewind hook, mainly for transport or "note-on" start time.
    void
    setGain(float gain)
    Optional: set multiplicative gain applied after OLA normalization.
    void
    setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.paulhertz.pixelaudio.granular.PASource

    getMultiChannelBuffer
  • Field Details

    • source

      private final float[] source
    • baseIndex

      private final int baseIndex
    • burstGrains

      private final int burstGrains
    • timeHopSamples

      private final int timeHopSamples
    • indexHopSamples

      private final int indexHopSamples
    • pitchRatio

      private final float pitchRatio
    • gain

      private float gain
    • grainLength

      private int grainLength
    • grainWindow

      private ddf.minim.analysis.WindowFunction grainWindow
    • windowCurve

      private float[] windowCurve
    • noteStartSample

      private long noteStartSample
    • noteStarted

      private boolean noteStarted
    • wsum

      private float[] wsum
  • Constructor Details

    • PABurstGranularSource

      public PABurstGranularSource(float[] source, int baseIndex, int grainLengthSamples, int burstGrains, int timeHopSamples, int indexHopSamples, float pitchRatio)
  • Method Details

    • setGain

      public void setGain(float gain)
      Optional: set multiplicative gain applied after OLA normalization.
    • getGain

      public float getGain()
    • 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
    • setGrainWindow

      public void setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples)
      Specified by:
      setGrainWindow in interface PASource
    • ensureWSum

      private void ensureWSum(int blockSize)
    • readLinear

      private static float readLinear(float[] buf, float pos)