I/O helpers
softlora.io
IQ file loading and packet persistence helpers.
iter_iq_chunks(path, chunk_samples=_DEFAULT_CHUNK_SAMPLES)
Stream a recording as complex64 chunks without loading it fully.
Yields complex64 chunks of up to chunk_samples samples from a raw
interleaved IQ file (float32 or int16, auto-detected) or a stereo WAV
(int16 PCM or float32 IEEE). The first chunk is a true prefix of the
stream, so concatenating the chunks reproduces :func:load_iq exactly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
Recording to read. |
required |
chunk_samples
|
int
|
Maximum number of complex samples per yielded chunk. |
_DEFAULT_CHUNK_SAMPLES
|
Yields:
| Type | Description |
|---|---|
ndarray
|
Complex baseband samples (complex64). |
Source code in softlora/io.py
load_iq(path)
Load a complex baseband IQ recording.
Supported formats (auto-detected):
- Stereo WAV (
.wav) -- channel 0 = I, channel 1 = Q (int16 or float32) - Raw interleaved I/Q float32 (
.cfile, GNU Radio File Sink output) - Raw interleaved I/Q int16 (
.dat) -- detected via a power check
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex baseband samples (complex64). |
Source code in softlora/io.py
sample_rate(path)
Sample rate stored in a WAV file header, or None for raw IQ files.
save_packets(packets, out_dir)
Persist decoded packets.
Writes, per packet, one raw payload packet_XXXX.bin plus an append-only
metadata.jsonl line with each packet's :meth:Packet.to_dict
serialization. An append-only packets.txt summary renders each packet
as its human-readable :meth:Packet.__str__ detail table for quick
inspection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packets
|
list of Packet
|
Packets to save. |
required |
out_dir
|
str or PathLike
|
Directory to create and write into. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
Absolute paths written. |