sigmf.siggen.SigMFGenerator
- class sigmf.siggen.SigMFGenerator(seed: int | None = None)
Bases:
objectBuilder pattern class for generating synthetic RF signals as SigMF files.
Supports deterministic generation (with specified parameters) and random generation (parameterless methods with seed-controlled randomness).
- Parameters:
seed (int, optional) – Random seed for reproducible signal generation.
Examples
>>> # deterministic 1khz tone >>> gen = SigMFGenerator(seed=42) >>> signal = gen.tone(1000).sample_rate(48000).duration(1.0).generate()
>>> # multiple tones combined >>> signal = gen.tone(1000).tone(1500).tone(2000).generate()
>>> # tone plus sweep >>> signal = SigMFGenerator().sample_rate(100e3).tone(440).sweep(1000, 5000).duration(0.5).generate()
Methods
Set signal amplitude.
Set author metadata.
Set comment metadata.
Set description metadata.
Set signal duration.
Add frequency offset to signal.
Generate the synthetic signal and return as sigmf file.
Add phase offset to signal.
Set sample rate.
Add white gaussian noise at specified snr.
Add a linear frequency sweep to the signal.
Add a sinusoidal tone to the signal.
- amplitude(amplitude: float)
Set signal amplitude.
- Parameters:
amplitude (float) – Signal amplitude (linear scale).
- Returns:
Self for method chaining.
- Return type:
- author(author: str)
Set author metadata.
- Parameters:
author (str) – Author name/email.
- Returns:
Self for method chaining.
- Return type:
- comment(comment: str)
Set comment metadata.
- Parameters:
comment (str) – Comment text.
- Returns:
Self for method chaining.
- Return type:
- description(description: str)
Set description metadata.
- Parameters:
description (str) – Signal description.
- Returns:
Self for method chaining.
- Return type:
- duration(duration_s: float)
Set signal duration.
- Parameters:
duration_s (float) – Duration in seconds.
- Returns:
Self for method chaining.
- Return type:
- frequency_offset(offset_hz: float)
Add frequency offset to signal.
- Parameters:
offset_hz (float) – Frequency offset in Hz.
- Returns:
Self for method chaining.
- Return type:
- generate() SigMFFile
Generate the synthetic signal and return as sigmf file.
- Returns:
Generated signal file with metadata.
- Return type:
- Raises:
SigMFGeneratorError – If required parameters are missing or invalid.
- phase_offset(offset_rad: float)
Add phase offset to signal.
- Parameters:
offset_rad (float) – Phase offset in radians.
- Returns:
Self for method chaining.
- Return type:
- sample_rate(rate_hz: float)
Set sample rate.
- Parameters:
rate_hz (float) – Sample rate in Hz.
- Returns:
Self for method chaining.
- Return type:
- snr(snr_db: float)
Add white gaussian noise at specified snr.
- Parameters:
snr_db (float) – Signal-to-noise ratio in dB.
- Returns:
Self for method chaining.
- Return type:
- sweep(start_frequency_hz: float | None = None, end_frequency_hz: float | None = None, amplitude: float | None = None)
Add a linear frequency sweep to the signal.
- Parameters:
- Returns:
Self for method chaining.
- Return type: