theori-io / nrsc5

NRSC-5 receiver for rtl-sdr
Other
772 stars 100 forks source link

API Improvements: Document Requirements / Add Missing Constants #346

Open TheDaChicken opened 2 weeks ago

TheDaChicken commented 2 weeks ago

In the API,

nrsc5_pipe_samples_cs16 assumes input went through the half-band filter. This isn't documented as a requirement/function / is not labeled to require in the function name.

I encountered a problem using 16 bits as a constant type for piping data from different SDRs which required the half-band filter. I have to implement a half-band filter to pipe that type.

API does not include a few constants such as which may be required:

Silly small tidbit: __declspec(dllexport) is meant to be used in the header file.

argilo commented 2 weeks ago

nrsc5_pipe_samples_cs16 assumes input went through the half-band filter.

Actually there is no requirement to use a half-band filter. The only requirement is that the input sample rate is 744187.5. I agree that it would be useful to add the required sample rates to the API documentation (1488375 for nrsc5_pipe_samples_cu8, 744187.5 for nrsc5_pipe_samples_cs16).

We could also document that the audio sample rate is always 44100.

argilo commented 2 weeks ago

The reason for 744187.5 is that it is the most convenient sample rate for OFDM demodulation. Unfortunately, the RTL-SDR does not natively support this sample rate (it allows only 225000-300000 and 900000-3200000). Because of this limitation, nrsc5 samples at 744187.5 * 2 = 1488375 and uses a decimating half-band filter to reach the desired sample rate. The API allows samples to be injected either before or after nrsc5's filter. If samples are injected after the filter, the application can use whatever means it likes to achieve the correct sample rate.

TheDaChicken commented 2 weeks ago

Actually there is no requirement to use a half-band filter. The only requirement is that the input sample rate is 744187.5. I agree that it would be useful to add the required sample rates to the API documentation (1488375 for nrsc5_pipe_samples_cu8, 744187.5 for nrsc5_pipe_samples_cs16).

Thanks for letting me know. my oblivious nature is a good example that it should probably be documented

We could also document that the audio sample rate is always 44100.

Would be very useful. I have constants I added in my code that would make sense to be added.

TheDaChicken commented 1 week ago

Should i make pull request for this?

argilo commented 1 week ago

Yes, that would be useful.

pclov3r commented 1 week ago

On the topic, It would be nice to see CS16 supported in NRSC5 for I/Q input without use the of API. https://github.com/theori-io/nrsc5/issues/284

Also, Maybe some GNuradio flowgraphs for both cu8 and cs16 samples would be good to include?

I find myself taking I/Q files from say SDRconsole and running though GNUradio flowgraph to get a usable CU8 file for use in NRSC5. If I could keep those 16-bit I figure it should yield better performance.

TheDaChicken commented 1 week ago

I find myself taking I/Q files from say SDRconsole and running though GNUradio flowgraph to get a usable CU8 file for use in NRSC5. If I could keep those 16-bit I figure it should yield better performance.

A quick look, it looks like that would require another function in the API. For example something like: nrsc5_open_file_cs16 OR switch to loading the file in main.c? Would that be a good idea?

(directed towards argilo, wasn't clear when i made this post)

pclov3r commented 1 week ago

I find myself taking I/Q files from say SDRconsole and running though GNUradio flowgraph to get a usable CU8 file for use in NRSC5. If I could keep those 16-bit I figure it should yield better performance.

A quick look, it looks like that would require another function in the API. For example something like: nrsc5_open_file_cs16 OR switch to loading the file in main.c? Would that be a good idea?

That would have to be @argilo call to make :)

Trying to create a gnuradio flowgraph now for cs16.

pclov3r commented 1 week ago

I can't get CS16 input working with the the current Python cli in a file converted in GNUradio. Works perfectly fine for cu8 with flow graph over at https://github.com/theori-io/nrsc5/issues/33#issuecomment-668352103

I am feeding it 744187.5 resampled from GNUradio. Likely something I'm doing wrong.

Please excuse my poor DSP knowledge :)

Input sample rate here is 500,000 Singed 16-bit and the frequency doesn't need to be shifted.

image

pclov3r commented 1 week ago

Your probably busy @argilo but when you get chance to answer the question form @TheDaChicken and my issue that would be awesome :)