WaveReader
classin packageklyn.audio
public class WaveReader implements AutoClosable
WaveReader
All Implemented Interfaces: AutoClosable

Incremental, seekable RIFF/RF64 WAVE reader; never opens an audio device. PCM8/16/24/32 and IEEE Float32 are decoded into independent Float32 blocks. Each read is capped at 65536 frames; file contents are not cached in memory. RF64 permits files larger than 4 GiB. Extensible PCM/Float32 headers preserve interleaved file order without speaker remapping. RF64 bitstream/control channels, more than 4096 extended sizes and offsets beyond Long.MAX_VALUE are explicitly unsupported. Instances are not thread-safe; use one owned reader per decoding task.

Example
import klyn.audio
import klyn.io
try reader = WaveReader(FilePath("speech.wav")):
    while reader.position < reader.frames:
        block = reader.readFrames(4096l)
        print(block.frames)
Properties
Modifier and Type Member Description
public readonly property channels
channels as Int
Interleaved samples per frame.
public readonly property duration
duration as Double
Duration in seconds; frame counts retain exact timing information.
public readonly property frames
frames as ULong
Total complete frames, determined without reading PCM.
public readonly property isClosed
isClosed as Boolean
Whether the owned file has been closed.
public readonly property position
position as ULong
Next frame to read, not a byte or scalar-sample index.
public readonly property sampleRate
sampleRate as Int
Frames per second.
Constructors
Modifier and Type Member Description
public WaveReader
WaveReader(notnull path as FilePath)
Opens a WAV and scans its layout without decoding or reading its payload.
Methods
Modifier and Type Member Description
public close
close() as Void
Releases the owned file; repeated calls are harmless.
public readFrames
readFrames(maximum as Long = 4096l) as AudioClip
Decodes at most maximum frames, with an upper bound of 65536 per call.
public seek
seek(frame as Long) as Void
Positions the next read at an exact PCM frame, including EOF.
Inherited Methods
methodInherited Methods from AutoClosable: close