Class OverlapUtil
OverlapUtil works with half-open sample intervals. A span is represented as
[spanStart, spanEnd), and the current audio block is represented as
[blockStart, blockStart + blockSize). The returned OverlapUtil.Slice gives the portion
of the block that overlaps the span, expressed as indices into the current block.
The main use is granular rendering, where each grain occupies an absolute sample span
but each audio callback renders only one block at a time. PABurstGranularSource
uses this class to find the loop bounds for samples that belong to the active grain.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBlock-local overlap range returned bycomputeBlockSlice(long, int, long, long). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OverlapUtil.SlicecomputeBlockSlice(long blockStart, int blockSize, long spanStart, long spanEnd) Computes the portion of the current block overlapped by an absolute sample span.
-
Constructor Details
-
OverlapUtil
private OverlapUtil()
-
-
Method Details
-
computeBlockSlice
public static OverlapUtil.Slice computeBlockSlice(long blockStart, int blockSize, long spanStart, long spanEnd) Computes the portion of the current block overlapped by an absolute sample span.The span and block are treated as half-open intervals. Touching endpoints do not count as overlap: for example, a span ending exactly at
blockStart, or starting exactly atblockStart + blockSize, produceshasOverlap == false.For overlapping intervals, the returned indices are clamped to the range
[0, blockSize]and are suitable as loop bounds into block-sized audio buffers.- Parameters:
blockStart- absolute sample index of the first sample in the blockblockSize- number of samples in the blockspanStart- absolute start of the span, inclusivespanEnd- absolute end of the span, exclusive- Returns:
- a
Sliceindicating[startIndex, endIndex)within the block, orhasOverlap == falseif there is no overlap
-