These two get mixed up all the time in GNU Radio because they sound similar but solve slightly different problems.
I’ll explain them intuitively first, then a bit more technically, and finish with a couple of “when do I use which?” rules of thumb.
Big picture (one-liner version)
- Selector block: Choose which input stream goes to the output
- Switch block: Choose whether data flows through at all (and from where)
Think selector = multiplexer, switch = gate / traffic controller.
Selector block
What it does
A Selector has:
- Multiple inputs
- Usually one output
- A control value (integer)
It forwards exactly one input stream to the output, based on the selector index.
Mental model
Like a rotary switch or audio mixer channel selector:
“Give me input 0… no, now input 1… now input 2…”
Example
You have:
- Input 0 → raw antenna
- Input 1 → filtered signal
- Input 2 → simulated test tone
Set selector value to:
0→ antenna1→ filtered2→ test tone
Everything else is ignored.
Key properties
- Control input is an integer
- Switching happens on the fly
- Other inputs still exist but are not forwarded
- Very commonly used for:
- Debug paths
- Mode switching
- A/B comparisons
- Choosing antennas, demodulators, or signal sources
Switch block
What it does
A Switch routes data based on a boolean condition.
Depending on the variant:
- It may have:
- Two inputs → one output
- One input → two outputs
- Controlled by a true/false (or nonzero/zero) signal
Mental model
Like a valve or gate:
“If condition is true, let data through this path; otherwise, use the other path or block it.”
Common variants
- 2-to-1 switch: choose between two inputs
- 1-to-2 switch: route one input to one of two outputs
- Enabled / disabled path (effectively mute/unmute)
Key properties
- Control signal is usually boolean
- Often used for:
- Gating data
- Threshold-based decisions
- Conditional routing
- Turning processing on/off dynamically
Selector vs Switch — side-by-side
| Feature | Selector | Switch |
| Control type | Integer index | Boolean / condition |
| Typical use | Choose which input | Decide whether / where data flows |
| Inputs | Many → 1 | Usually 2 → 1 or 1 → 2 |
| Think of it as | Multiplexer | Gate / conditional router |
| Common use case | Mode selection | Threshold logic, enable/disable |
GNU Radio gotchas (important)
1. Switching is not sample-accurate
Changing selector/switch values mid-stream can:
- Drop samples
- Repeat samples
- Cause brief discontinuities
That’s normal. If you need phase-continuous switching (e.g. interferometry), you usually:
- Align streams
- Or switch at block boundaries
- Or cross-fade instead of hard switching
2. Unselected inputs still run
Selector blocks do not stop upstream blocks from running — they just don’t forward their data.
If you need to actually stop computation, you’ll want:
- Enable blocks
- Or separate flowgraphs
- Or message-based control
Practical radio examples (your world 😉)
Use a Selector when:
- Choosing between antennas
- Switching between real SDR input and a test signal
- Selecting different filter chains
- Debugging stages of a receiver
Use a Switch when:
- Muting output below an SNR threshold
- Gating data when lock is achieved
- Routing signal only when a detector fires
- Turning recording on/off based on power
Quick rule of thumb
If you’re choosing which stream, use a Selector.
If you’re choosing whether data flows or which path it takes, use a Switch.
Next is a sketch a small GNU Radio Companion example for:
- Antenna selection
- Threshold-triggered recording
- An interferometry-friendly approach that avoids phase jumps
Perfect — let’s walk through all three, step-by-step, in a way that maps cleanly onto GNU Radio Companion and real radio work. I’ll keep it practical and slightly opinionated.
1️⃣ Antenna / Source selection (Selector block)
Use case
You want to switch between:
- Antenna A
- Antenna B
- A signal generator (test tone / noise source)
…without rewiring the flowgraph.
GRC structure
[Antenna A] ─┐
├──► Selector ───► Rest of receiver
[Antenna B] ─┤
│
[Test Src ] ─┘
Key blocks
- Selector
- Number of inputs = 3
- Output index = variable (e.g.
src_sel)
- QT GUI Range or Variable
src_sel = 0, 1, 2
How it behaves
src_sel = 0→ Antenna Asrc_sel = 1→ Antenna Bsrc_sel = 2→ Test source
Upstream blocks keep running, but only one stream reaches the receiver.
Pro tip
If you’re doing interferometry or phase-sensitive work, do not switch rapidly — change only when stopped or during dead time. Selector switching is a hard cut.
2️⃣ Threshold-triggered recording (Switch block)
Use case
Record data only when signal power exceeds a threshold
(e.g. Jovian bursts, meteor scatter, RFI detection)
GRC structure
[Signal] ───►┬──────────────► Switch ───► File Sink
│
└──► Power ─► Compare ─► Control
Key blocks
- Complex to Mag² (or RMS)
- Moving Average
- Compare (e.g.
>threshold) - Switch
- Data input 0 = signal
- Data input 1 = zeros (or null source)
- Control = compare output
Logic
- Power > threshold → control = 1 → signal flows
- Power ≤ threshold → control = 0 → muted
This avoids filling disks with noise.
Gotcha
The switch is not sample-perfect. Expect:
- Slight truncation at start/end
- That’s fine for detection, not for phase science
Upgrade path
For cleaner edges:
- Gate with a burst tagger
- Or record continuously and post-filter offline
3️⃣ Phase-safe switching for interferometry (important one)
Use case
You want to:
- Select between signal paths
- Enable/disable correlation
- Change modes
…but without destroying phase continuity.
Hard switches will ruin fringes.
❌ What NOT to do
- Selector mid-stream
- Switch based on a boolean
- Stop/start streams independently
These introduce phase jumps.
✅ Correct approach: keep streams running, select later
Pattern A — Parallel processing + Selector after correlation
[Antenna 1] ─┬─► Corr ─┬─► Selector ─► Display / Save
[Antenna 2] ─┘ │
└─► Alternate Corr
All signal paths:
- Run continuously
- Stay phase-locked
- Only results are switched
Pattern B — Cross-fade instead of switch (advanced, very clean)
Instead of switching:
- Multiply Path A by
(1 - α) - Multiply Path B by
α - Add them
Where α ramps smoothly 0 → 1.
Path A ─► Multiply (1-α) ─┐
├──► Add ─► Output
Path B ─► Multiply (α) ───┘
This:
- Preserves phase
- Avoids spectral splatter
- Is gold-standard for precision work
Pattern C — Message-based enable/disable
If you want to pause recording or processing without breaking phase:
- Keep DSP running
- Use Enable blocks or message-controlled sinks
- Ignore data instead of stopping it
Summary table (radio-astronomy mindset)
| Task | Best block | Why |
| Choose antenna/source | Selector | Simple, explicit |
| Trigger recording | Switch | Boolean logic |
| Preserve phase | Neither | Use parallel paths |
| Mode switching in interferometry | Selector on results | DSP stays coherent |
| Clean transitions | Cross-fade | No discontinuities |
Next we will:
- Build a full GRC interferometer flowgraph
- Add real-time fringe stopping
- Or design a selector-driven test harness for debugging SDR chains
Alright — let’s build all three properly, as if you were about to drop them straight into GNU Radio Companion. I’ll give you exact block lists, variables, and wiring, plus a few “radio-astronomer sanity notes” along the way 📡
I’ll assume complex baseband everywhere unless stated otherwise.
1️⃣ Antenna / Source Selection (Selector block)
Goal
Select between multiple signal sources (e.g. two antennas + test source) without rewiring.
Blocks you need
Sources
Osmocom Source(Antenna A)Osmocom Source(Antenna B)
(or second channel if using RSPduo)Signal Source(test tone or noise)
Control
QT GUI Range- ID:
src_sel - Min:
0 - Max:
2 - Step:
1
- ID:
Routing
Selector- Input type:
Complex - Number of inputs:
3 - Output index:
src_sel
- Input type:
Wiring
Antenna A ─┐
├─► Selector ──► Filter ─► Demod ─► Sink
Antenna B ─┤
│
Test Src ─┘
Behaviour
src_sel = 0→ Antenna Asrc_sel = 1→ Antenna Bsrc_sel = 2→ Test source
💡 Important
All sources continue running. Only the output changes.
📡 Astronomy note
Do not change src_sel mid-observation if phase matters. Stop, switch, restart.
2️⃣ Threshold-Triggered Recording (Switch block)
Goal
Record data only when signal power exceeds a threshold
(e.g. Jovian bursts, meteors, RFI spikes)
Blocks you need
Signal path
Complex to Mag²Moving Average- Length: e.g.
1024 - Scale:
1/1024
- Length: e.g.
Threshold logic
QT GUI Range- ID:
pwr_thresh
- ID:
Compare- Operation:
> - Input A: averaged power
- Input B:
pwr_thresh
- Operation:
Routing
Switch- Data input 0: signal
- Data input 1:
Null Source(or zeros) - Control: output of Compare
Sink
File Sink(complex)
Wiring
Signal ──────────────┬────────► Switch ─► File Sink
│
└─► Mag² ─► Avg ─► Compare ─► Control
Behaviour
- Power > threshold → recording ON
- Power ≤ threshold → recording muted
📌 Expected artefacts
- First few samples clipped
- Slight truncation on drop-out
📡 Astronomy note This is detection-grade, not correlation-grade.
Great for burst hunting, not phase science.
3️⃣ Phase-Safe Interferometry Switching (the “right” way)
This is the one that actually matters for you.
❌ What we are avoiding
- Selector on raw antenna signals
- Switches before correlation
- Stop/start data streams
All of these break phase.
✅ Correct pattern: parallel DSP, select results
3A️⃣ Parallel correlators + Selector
Goal
Choose which correlation result you view or save — without touching the RF streams.
Blocks
Inputs
Osmocom Source(Ch 0)Osmocom Source(Ch 1)
DSP
FFT / Delay / Fringe Stop(as required)Complex Multiply Conjugate(correlator)
Selector
- Number of inputs: e.g.
2 - Output index:
corr_sel
Wiring
Ant 1 ─┬─► DSP ─► Corr A ─┐
│ ├─► Selector ─► Display / File
Ant 2 ─┘ │
└─► Corr B
All paths run continuously.
Switching affects only what you look at, not the coherence.
3B️⃣ Cross-fade switching (ultra-clean, recommended)
Goal
Transition between two paths without phase jumps or spectral splatter
Blocks
Multiply Const×2AddQT GUI Range- ID:
alpha - Range:
0 → 1 - Smooth ramp (slow slider or scripted)
- ID:
Wiring
Path A ─► × (1 - α) ─┐
├─► Add ─► Output
Path B ─► × (α) ─────┘
When:
α = 0→ Path A onlyα = 1→ Path B only
🎯 This preserves
- Phase
- Amplitude continuity
- Fringe integrity
📡 This is interferometry gold
3C️⃣ Enable/Disable recording without phase loss
Instead of switching signals:
- Keep DSP alive
- Gate only the sink
Use:
Tagged Stream BlocksMessage StrobeFile Sink (message-controlled)
Data keeps flowing → you just decide whether to store it.
Final decision table (bookmark-worthy)
| Task | Correct solution |
| Choose antenna/source | Selector |
| Trigger recording | Switch |
| Interferometry | Parallel paths |
| Clean transitions | Cross-fade |
| Phase safety | Never switch RF |