GNU Radio, the “Stream to Vector” block
In GNU Radio, the “Stream to Vector” block works with streamed sample data and groups it into fixed-length vectors.
Here’s a clear breakdown of how it works:
📡 Input Type
- Stream of individual items (e.g. float, complex, short, byte — depending on how the upstream flowgraph is configured).
- For example:
float32samples from an SDR, orcomplex64baseband IQ samples.
- For example:
🧱 Output Type
- Vectors of fixed length (you specify the length in the block’s parameters).
- If the vector length is
N, then everyNincoming scalar items are bundled into a single output vector of lengthN. - Output data type is the same as the input type, just in vector form (e.g. “complex vector”, “float vector”).
- If the vector length is
⚙️ Example
Say the input stream is:
[1, 2, 3, 4, 5, 6, 7, 8, ...]
and the vector length = 4.
The output will be:
[ [1, 2, 3, 4], [5, 6, 7, 8], ... ]
This is commonly used before:
- FFT blocks (which expect vector inputs).
- Correlators or filters that work on blocks of samples.
- Custom processing where a chunk of samples is required together.
🧭 Practical Notes
- If the number of incoming items is not divisible by the vector length, the last incomplete vector is held until more samples arrive.
- No resampling or conversion is done — just repackaging.
- If the vector length is too large for your buffer or processing block, it can stall or underflow.
✅ Typical use case:
In radio astronomy or SDR work, for example, you might stream complex baseband data from SDRplay RSPduo, use Stream to Vector to create 2048-sample vectors, and then feed those to an FFT block for spectral analysis.