/** * Windows in seconds, resolved to records and then to samples. * * Layer 4. Pure and synchronous, both halves of it. `resolveTimeWindow` answers "which records * does this window cost?" before a byte is read, so the price of a window is auditable rather * than discovered; `trimToWindow` narrows a record-aligned chunk to the samples actually asked * for. * * The window is the half-open interval `[startSeconds, startSeconds + durationSeconds)` in * elapsed recording time — `t = 0` is the start of record 0, the axis `time/timeline.ts` fixes. * * Every comparison below is integer or rational arithmetic on ticks, records and * `samplesPerRecord`. `round(t * sampleRateHz)` appears nowhere: `sampleRateHz` is derived and * often not representable (256/3 Hz is a real record duration of 3 s with 256 samples), so * rounding through it walks the answer off by a sample near every large `t` — which is the exact * mistake edfcore exists to stop a consumer from re-implementing. */ import type { EdfChunkSignal, EdfHeader, EdfRecordIndex, EdfTimeline, RecordRange } from '../types.js'; /** * The chunk signal, before the header is asked anything about its index. * * `EdfSignal` and `EdfChunkSignal` are the two per-signal shapes in this package, and they name the * index differently: `index` on the header's, `signalIndex` on the chunk's. Passing the header's — * the one a reader already holds, from `getSignal` or `header.signals[i]` — sent `undefined` into * `signalAt` and earned "signalIndex undefined is not one of the 7 signals in this header … Next: * pass the header the chunk was read with". The header was the argument that was right, and the * advice named it (fixed in 0.6.97). */ export declare function assertChunkSignal(chunkSignal: EdfChunkSignal, call: string, verb: string): void; /** * The records a window needs, one `RecordRange` per contiguous run it overlaps, in time order. * * Empty when the window falls entirely inside a gap, entirely outside the recording, or has a * non-positive duration — the interval is half-open, so a zero-length window contains no time * and therefore no samples. * * Ranges are RECORD-ALIGNED and are therefore usually wider than the window: a record is the * smallest unit the file can be read by, and `trimToWindow` is how a caller narrows the samples * afterwards. * * With `index.segments` present (`coverage === 'complete'`) the answer is exact. With a probed * index it is exact only while the file is contiguous, which is precisely what * `spanTicks === coveredTicks` states; when it is not, the records a window maps to depend * on onsets nobody has read, and this function refuses rather than guessing them. */ export declare function resolveTimeWindow(timeline: EdfTimeline, index: EdfRecordIndex, startSeconds: number, durationSeconds: number): readonly RecordRange[]; /** * The exact per-signal trim of a record-aligned chunk to `[startSeconds, startSeconds + duration)`. * * Sample `j` of the chunk is inside the window when the tick edfcore PUBLISHES for it — * `ceil(j * recordDuration / samplesPerRecord)`, the value `gridSampleStartTicks` and * `sampleStartTicksOf` report — falls in `[relativeStart, relativeEnd)`. Since `ceil(x) >= R` iff * `x > R - 1`, both edges stay integer bigint products of on-disk quantities: no division, no * sample rate, no float bound, so the boundary sample is the same one on every platform. * * The comparison is against the PUBLISHED tick, not the sample's exact rational start. Those * differ whenever a boundary is not a whole tick — 256 samples in a one-second record puts sample 1 * at 39,062.5 ticks, published as 39,063 — and selecting on the exact start excluded the sample a * caller had aligned the window to. This docblock stated that older rule until 0.3.95, three * releases after 0.3.56 replaced it. * * The chunk must be one contiguous run of records (what `readWindow` returns), because that is * what makes the sample grid uniform across it. * * `digital` in the result is a SUBARRAY view of the input's, so trimming allocates nothing and * the two share memory. A window that only partly overlaps the chunk is clamped to the samples * that exist; one that misses it entirely yields a zero-length result rather than an error. */ export declare function trimToWindow(header: EdfHeader, chunkSignal: EdfChunkSignal, startSeconds: number, durationSeconds: number): EdfChunkSignal; //# sourceMappingURL=window.d.ts.map