public class WaveReader implements 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.
import klyn.audio
import klyn.io
try reader = WaveReader(FilePath("speech.wav")):
while reader.position < reader.frames:
block = reader.readFrames(4096l)
print(block.frames)| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | channelschannels as Int |
Interleaved samples per frame. |
| public readonly property | durationduration as Double |
Duration in seconds; frame counts retain exact timing information. |
| public readonly property | framesframes as ULong |
Total complete frames, determined without reading PCM. |
| public readonly property | isClosedisClosed as Boolean |
Whether the owned file has been closed. |
| public readonly property | positionposition as ULong |
Next frame to read, not a byte or scalar-sample index. |
| public readonly property | sampleRatesampleRate as Int |
Frames per second. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | WaveReaderWaveReader(notnull path as FilePath) |
Opens a WAV and scans its layout without decoding or reading its payload. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | closeclose() as Void |
Releases the owned file; repeated calls are harmless. |
| public | readFrames | Decodes at most maximum frames, with an upper bound of 65536 per call. |
| public | seekseek(frame as Long) as Void |
Positions the next read at an exact PCM frame, including EOF. |