This is fairly deep technical question that applies to all SDRs, purely my curiosity, posting on the chance there is an SDR expert out there who can answer it in a simple manner, or post a hyperlink...
I have always wondered how the raw ADC samples in the RTLSDR dongle (28.8 megasamples/second?) are processed and downsampled to the lower rates needed to transfer data out of the dongle to the PC software for a given bandwidth setting. In other words, a 2 MHz bandwidth setting requires a lot more bits/second from the USB connection than a 1 MHz setting, but how exactly is the original raw data from the ADC sampling transformed in the dongle? Is a FFT done, followed by filtering at the selected the bandwidth, then a reverse transform? Or some kind of mathematical averaging on the entire stream to downconvert it?
Direct sampling to bandwidth output, how done?

 Posts: 6
 Joined: Wed Jan 29, 2020 12:18 am
Re: Direct sampling to bandwidth output, how done?
The mathematically correct solution is to use a perfect bandlimiting antialiasing or lowpass filter before decimation or interpolation. In reality, no filter is perfect. So an antialiasing filter should have a stop band attenuation below the radio's desired noise floor at and above the new downsampled sample rate.
Antialias filtering can be implemented in software or hardware by many different methods, including using a highorder IIR filter, or using a windowed Sinc or computer optimized FIR filter. An IIR is usually implemented by sections of recursive arithmetic (biquads, corresponding to sections of analog LC filters). A IIR works similar to averaging, but due to feedback and multiple sections, is a lot smoother in the frequency domain. A FIR filter can be implemented by straight convolution (a lot of vector arithmetic), perhaps using a polyphase filter bank or Farrow interpolator for each set of FIR filter coefficients. or by overlapadd/save FFT/IFFT fast convolution for greater efficiency. There are other solutions including CIC filters and incremental multirate filtering and downsampling (reducing the sample rate in steps).
For fractional sample rate ratio changes, one can also upsample before downsampling, but I prefer polyphase interpolation methods to upsampling as more computationally efficient.
Bandpass filtering plus undersampling can also be used for downsampling a tuned spectrum slice. But, more commonly, heterodyning down to complex or IQ baseband before lowpass filtering seems to be a more efficient and commonly implemented algorithm.
Antialias filtering can be implemented in software or hardware by many different methods, including using a highorder IIR filter, or using a windowed Sinc or computer optimized FIR filter. An IIR is usually implemented by sections of recursive arithmetic (biquads, corresponding to sections of analog LC filters). A IIR works similar to averaging, but due to feedback and multiple sections, is a lot smoother in the frequency domain. A FIR filter can be implemented by straight convolution (a lot of vector arithmetic), perhaps using a polyphase filter bank or Farrow interpolator for each set of FIR filter coefficients. or by overlapadd/save FFT/IFFT fast convolution for greater efficiency. There are other solutions including CIC filters and incremental multirate filtering and downsampling (reducing the sample rate in steps).
For fractional sample rate ratio changes, one can also upsample before downsampling, but I prefer polyphase interpolation methods to upsampling as more computationally efficient.
Bandpass filtering plus undersampling can also be used for downsampling a tuned spectrum slice. But, more commonly, heterodyning down to complex or IQ baseband before lowpass filtering seems to be a more efficient and commonly implemented algorithm.
Re: Direct sampling to bandwidth output, how done?
Antialias filtering can be done in hardware only for analog signal (before ADC). This is impossible in software (in digital domain after ADC output). The only way is to apply antialias filter to the analog signal before ADC input.
For example you can use lowpass filter before ADC. If you don't apply antialias filter, you will get aliasing on the ADC output for frequency components above Fs/2 and you cannot remove it in digital domain, because there is no way to distinguish aliased components from real components.
RTLSDR ADC running at 28.8 MHz, so the ADC output bandwidth is 14.4 MHz. So, there is needs LPF with about 14 MHz cutoff. But RTLSDRv3 uses LPF for 30 MHz or something like that, so you can listen stations above 14 MHz through aliases. If you want to eliminate aliasing effect there is needs to add external LPF or BPF filter on the RTLSDR dongle input for specific frequency band. Just make sure that your filter pass band doesn't intersects with 14.4 MHz boundary.
Re: Direct sampling to bandwidth output, how done?
If you decimate in software, and the sampled signal has a bandwidth higher than the new target sample rate, then it is required to do antialias filtering in software. Thus software filtering has to be possible (DSP IIR or FIR typically).
Whether antialiasing filtering is required in hardware before sampling depends on the bandwidth of the analog signal. A narrowband signal from a signal generator may not need it. But, yes, typical RF signals require filtering before sampling.