Package net.paulhertz.pixelaudio.granular

# Class WindowCache

java.lang.Object
net.paulhertz.pixelaudio.granular.WindowCache

public final class WindowCache extends Object
WindowCache Simple cache for windowFunction.generateCurve(length) results. Avoids recomputing window curves for the same (WindowFunction class, length) pairs. Implementation is thread-safe. For strict real-time safety, prewarm curves during setup, not from the audio thread. Used by the PixelAudio granular synthesis engine. Calling chain: PAGranularInstrumentDirector -> PAGranularInstrument -> PAGranularSampler -> PAGranularVoice, where PABurstGranularSource handles the complexities of the granular synthesis sample by sample.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `private static final class`
  `WindowCache.Key`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final WindowCache`
  `INSTANCE`
  `private final Map<WindowCache.Key,float[]>`
  `windowCurves`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `private`
  `WindowCache()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float[]`
  `getWindowCurve(ddf.minim.analysis.WindowFunction wf, int length)`
  Get a cached window curve for the given WindowFunction and length.
  `float[]`
  `prewarm(ddf.minim.analysis.WindowFunction wf, int length)`
  Precompute and cache a window curve.

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### INSTANCE

    public static final WindowCache INSTANCE

  - ### windowCurves

    private final Map<WindowCache.Key,float[]> windowCurves

- ## Constructor Details

  - ### WindowCache

    private WindowCache()

- ## Method Details

  - ### prewarm

    public float[] prewarm(ddf.minim.analysis.WindowFunction wf, int length)
    Precompute and cache a window curve. Call this during setup, not from the audio thread.

  - ### getWindowCurve

    public float[] getWindowCurve(ddf.minim.analysis.WindowFunction wf, int length)
    Get a cached window curve for the given WindowFunction and length. If not cached, this will lazily generate it. For strict real-time safety, prefer calling prewarm(...) ahead of time.