Input formats - windytan/redsea GitHub Wiki
Redsea can read RDS signals in many ways. Choose one of these options depending on your input -
Via stdin:
-
--input mpx: raw PCM FM multiplex (default) -
--input hex: RDS Spy hex format -
--input bits: ASCII bits -
--input tef: TEF6686 serial data
Or from a file:
-
-f <file>: MPX from any audio file supported by libsndfile
FM multiplex as raw PCM is the default input format if no command-line option is given. It gets read via stdin.
- format: PCM (no headers)
- encoding: signed 16-bit little-endian
- channels: 1
You should at least set the sample rate with -r <rate_hz>.
MPX means a demodulated FM multiplex signal at baseband, with its RDS subcarrier at 56 kHz. You can get an MPX signal by demodulating a radio station in "NFM mode", without stereo decoding and de-emphasis. It looks like this:
A sample rate of 171,000 Hz works fastest, as a neat multiple of the data speed. Any other rate will be resampled internally; see benchmarks for how this affects performance. The rate can't be lower than 128,000 Hz though.
MPX can also be read from a WAV file (or FLAC, any other format supported by libsndfile) using -f filename.wav. In this case, sample rate and the number of channels are detected automatically from the header.
Note that even though a WAV file can contain PCM samples (and may accidentally work via stdin) it is a different format and contains a header.
Multiple stations can be decoded simultaneously using multi-channel MPX input, specified with --channels. This format consists of multi-channel frames; a frame is a block of samples, one sample for each channel. Each channel is demodulated independently and a channel field is added into the JSON output.
frame0 frame2
C0C1C2C0C1C2C0C1C2....
frame1
If your WAV has multiple channels, multi-channel decoding gets activated automatically.
Redsea can read demodulated RDS data in the hex format created by RDS Spy. These files often
have the extension .spy or .rds. This format has:
- One RDS group per line written as ASCII hexadecimals (without the checkword bits).
- These lines must be in the order they were received.
- Each line must start with the group; space characters are ignored.
- Bad blocks must be replaced by
----. - Lines shorter than 16 characters are ignored.
- Any text following the group (comments, timestamps, ...) is ignored.
Example:
$ redsea --input hex
6403 0440 CB41 594C
6403 1440 00E1 7C54
6403 E443 2020 6202
6403 0441 B741 4520
6403 245D 2020 2020
{"pi":"0x6403","group":"0A","di":{"stereo":false},"is_music":false,"prog_type":"
Current affairs","ta":false,"tp":true}
{"pi":"0x6403","group":"1A","country":"fi","has_linkage":false,"prog_item_number
":31828,"prog_item_started":{"day":15,"time":"17:20"},"prog_type":"Current affai
rs","tp":true}
{"pi":"0x6403","group":"14A","other_network":{"pi":"0x6202","tp":false},"prog_ty
pe":"Current affairs","tp":true}
{"pi":"0x6403","group":"0A","di":{"artificial_head":false},"is_music":false,"pro
g_type":"Current affairs","ta":false,"tp":true}
{"pi":"0x6403","group":"2A","prog_type":"Current affairs","tp":true}
The ASCII bits input is very simple; just the raw RDS data as a stream of ASCII '0's and '1's. All other characters like spaces and line feeds are ignored.
$ redsea --input bits
10001011100001011100110010000101100001010011001001110000101011110110101100010010
00110100000011010010000010001011100001011100110000000101100010101000101011101001
10101100111110100101010100100010000011001001110010001011100001011100110000100101
10010110100110010101000101010100110101100000010101000100010101111110110010001011
10000101110
{"pi":"0x22E1","group":"2A","prog_type":"Easy listening","tp":true}
The TEF6686 outputs USB serial data that looks like this:
R34104000cd4600
Ss66.2,7,34
Pa502
Ss66.1,8,34
Pa502
Ss66.0,10,34
Redsea can read this via stdin and decode into RDS groups with redsea --input tef.
