1- =================
2- Format Converters
3- =================
1+ ==========
2+ Converters
3+ ==========
44
5- The SigMF Python library includes converters to import data from various file formats into SigMF format .
5+ The SigMF Python library includes converters to import data from various RF recording formats into SigMF.
66Converters can create standard SigMF file pairs or Non-Conforming Datasets (NCDs) that reference the original files.
77
88Overview
99--------
1010
11- Converters are available for:
11+ Conversion is available for:
1212
13- * **BLUE files ** - MIDAS Blue and Platinum BLUE RF recordings (``.cdif ``)
13+ * **BLUE files ** - MIDAS Blue and Platinum BLUE RF recordings (usually ``.cdif ``)
1414* **WAV files ** - Audio recordings (``.wav ``)
1515
16- All converters return a :class: `~sigmf.SigMFFile ` object. Auto-detection is available through :func: ` ~sigmf.sigmffile.fromfile ` .
16+ All converters return a :class: `~sigmf.SigMFFile ` object with converted metadata .
1717
1818
19- Auto-Detection
20- ~~~~~~~~~~~~~~
19+ Fromfile Auto-Detection
20+ ~~~~~~~~~~~~~~~~~~~~~~~
2121
2222The :func: `~sigmf.sigmffile.fromfile ` function automatically detects file formats and creates Non-Conforming Datasets:
2323
@@ -30,35 +30,66 @@ The :func:`~sigmf.sigmffile.fromfile` function automatically detects file format
3030 meta = sigmf.fromfile(" recording.wav" ) # WAV file
3131 meta = sigmf.fromfile(" recording.sigmf" ) # SigMF archive
3232
33- samples = meta.read_samples()
33+ all_samples = meta.read_samples()
34+ sample_rate = meta.sample_rate
35+
36+
37+ Python API
38+ ~~~~~~~~~~~
39+
40+ For programmatic access, use the individual converter functions directly:
41+
42+ .. code-block :: python
43+
44+ from sigmf.convert.wav import wav_to_sigmf
45+ from sigmf.convert.blue import blue_to_sigmf
46+
47+ # convert WAV to SigMF archive
48+ _ = wav_to_sigmf(wav_path = " recording.wav" , out_path = " recording" , create_archive = True )
49+
50+ # convert BLUE to SigMF pair and return metadata for new files
51+ meta = blue_to_sigmf(blue_path = " recording.cdif" , out_path = " recording" )
3452
3553
3654 Command Line Usage
3755~~~~~~~~~~~~~~~~~~
3856
39- Converters can be used from the command line:
57+ Converters are accessed through a unified command- line interface that automatically detects file formats :
4058
4159.. code-block :: bash
4260
43- sigmf_convert_blue recording.cdif
44- sigmf_convert_wav recording.wav
45-
46- or by using module execution:
61+ # unified converter
62+ sigmf_convert input_file output_file
4763
48- .. code-block :: bash
64+ # examples
65+ sigmf_convert recording.cdif recording.sigmf
66+ sigmf_convert recording.wav recording.sigmf
4967
50- python -m sigmf.convert.blue recording.cdif
51- python -m sigmf.convert.wav recording.wav
68+ The converter uses magic byte detection to automatically identify BLUE and WAV file formats.
69+ No need to remember format-specific commands!
5270
5371
5472Output Options
5573~~~~~~~~~~~~~~
5674
57- Converters support multiple output modes:
75+ The unified converter supports multiple output modes:
76+
77+ .. code-block :: bash
78+
79+ # standard conversion (creates out.sigmf-data and out.sigmf-meta files)
80+ sigmf_convert in.wav out
5881
59- * **Standard conversion **: Creates ``.sigmf-data `` and ``.sigmf-meta `` files
60- * **Archive mode **: Creates single ``.sigmf `` archive with ``--archive ``
61- * **Non-Conforming Dataset **: Creates metadata-only file referencing original data with ``--ncd ``
82+ # archive mode (creates single out.sigmf archive)
83+ sigmf_convert in.wav out --archive
84+
85+ # non-conforming dataset (creates out.sigmf-meta only, references original file)
86+ sigmf_convert in.wav out --ncd
87+
88+ # extra verbose output
89+ sigmf_convert in.wav out -vv
90+
91+ **Important **: When using ``--ncd ``, the input and output files must be in the same directory.
92+ This ensures proper relative path references in the metadata.
6293
6394
6495BLUE Converter
@@ -73,19 +104,22 @@ The BLUE converter handles CDIF (.cdif) recordings while placing BLUE header inf
73104
74105.. autofunction :: sigmf.convert.blue.blue_to_sigmf
75106
107+ Examples
108+ ~~~~~~~~
109+
76110.. code-block :: python
77111
78112 from sigmf.convert.blue import blue_to_sigmf
79113
80114 # standard conversion
81115 meta = blue_to_sigmf(blue_path = " recording.cdif" , out_path = " recording" )
82116
83- # create NCD automatically (metadata-only, references original file)
117+ # create NCD automatically (metadata-only, references original file) but don't save any output file
84118 meta = blue_to_sigmf(blue_path = " recording.cdif" )
85119
86120 # access standard SigMF data & metadata
87121 all_samples = meta.read_samples()
88- sample_rate_hz = meta.sample_rate
122+ sample_rate = meta.sample_rate
89123
90124 # access BLUE-specific metadata
91125 blue_type = meta.get_global_field(" blue:fixed" )[" type" ] # e.g., 1000
@@ -99,6 +133,9 @@ Converts WAV audio recordings to SigMF format.
99133
100134.. autofunction :: sigmf.convert.wav.wav_to_sigmf
101135
136+ Examples
137+ ~~~~~~~~
138+
102139.. code-block :: python
103140
104141 from sigmf.convert.wav import wav_to_sigmf
0 commit comments