Class WindowCache
WindowCache stores the arrays returned by
WindowFunction.generateCurve(int) so repeated granular voices can reuse the same
window data instead of regenerating it for every grain or playback event.
Cache entries are keyed by the concrete WindowFunction class and the requested
length. Two different instances of the same window-function class therefore share a cached
curve when the requested length is the same.
The cache is safe to access from multiple threads. For strict real-time audio behavior,
call prewarm(WindowFunction, int) during setup or scheduling so the audio thread
can later call getWindowCurve(WindowFunction, int) without triggering curve
generation.
The returned arrays are cached and shared. Callers should treat them as read-only.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final WindowCacheShared cache instance used by the granular synthesis engine.private final Map<WindowCache.Key,float[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloat[]getWindowCurve(ddf.minim.analysis.WindowFunction wf, int length) Returns a cached window curve for the given window function and length.float[]prewarm(ddf.minim.analysis.WindowFunction wf, int length) Precomputes and caches a window curve.
-
Field Details
-
INSTANCE
Shared cache instance used by the granular synthesis engine. -
windowCurves
-
-
Constructor Details
-
WindowCache
private WindowCache()
-
-
Method Details
-
prewarm
public float[] prewarm(ddf.minim.analysis.WindowFunction wf, int length) Precomputes and caches a window curve.Use this method during setup or scheduling to avoid first-use curve generation on the audio thread. If the curve is already cached, this method returns the existing shared array.
- Parameters:
wf- window function used to generate the curvelength- number of samples in the generated curve- Returns:
- the cached window curve; callers should treat the returned array as read-only
- Throws:
NullPointerException- ifwfis null
-
getWindowCurve
public float[] getWindowCurve(ddf.minim.analysis.WindowFunction wf, int length) Returns a cached window curve for the given window function and length.If no matching curve has been cached, this method generates one lazily and stores it. For strict real-time safety, prefer calling
prewarm(WindowFunction, int)ahead of time.- Parameters:
wf- window function used to generate the curvelength- number of samples in the generated curve- Returns:
- the cached window curve; callers should treat the returned array as read-only
- Throws:
NullPointerException- ifwfis null
-