theori-io/nrsc5

Supplying input IQ at lower sample rate

Closed this issue · 3 comments

Is there a way to feed NRSC5 with the input IQ stream at a lower sample rate, let us say 400ksps? I am assuming it does not require the entire 1.4Msps input bandwidth to function, does it?

argilo commented

HD Radio signals have a bandwidth of just under 400 kHz, so the input sample rate must be higher than that. Because of the OFDM spacing, 744187.5 Hz is a convenient sampling rate and nrsc5 uses this internally. 16-bit samples can be fed into the API at this rate:

nrsc5/include/nrsc5.h

Lines 602 to 611 in 6cbc106

/**
* Push an IQ input array of 16-bit signed samples into the demodulator.
*
* @param[in] st pointer to an `nrsc5_t` session object
* @param[in] samples pointer to an array 16-bit signed samples
* @param[in] length the number of samples in the array
* @return 0 on success, nonzero on error
*
*/
int nrsc5_pipe_samples_cs16(nrsc5_t *st, const int16_t *samples, unsigned int length);

The Python CLI application also accepts 16-bit samples at this rate (when the cs16 option is specified):

parser.add_argument("--iq-input-format", choices=["cu8", "cs16"], default="cu8")

Because the RTL-SDR only supports sample rates from 225-300 kHz, and > 900 kHz, the standard input rate is 744187.5 Hz * 2 = 1488375 Hz, which is converted to 744187.5 Hz by a half-band decimator.

If you'd like to use another rate, you'd have to do your own sample rate conversion outside nrsc5.

I hope this helps.

What if the input is coming from something else than RTL-SDR though? I am trying to connect NRSC5 to the OpenWebRX, for decoding HDRadio broadcasts. Since a lot of OpenWebRX is written in Python, it struggles at high sample rates. It can pipe 400ksps to the NRSC5 standard input though, with the analog FM signal at 0Hz. I guess it can even do 800ksps. 1.48Msps is a bit hard for it.

So, would it be possible to add somewhat arbitrary (selectable from several different choices?) input sampling rate to NRSC5?

argilo commented

I would suggest using the 744187.5 ksps input available in the API. Supporting other sample rates would require adding a fractional or arbitrary resampler to nrsc5, and I don't have any immediate plans to do that. I suppose it could be useful to support SDRs like Airspy which can only operate at a handful of sample rates.