SoapyRTLSDR icon indicating copy to clipboard operation
SoapyRTLSDR copied to clipboard

No SoapySDR API returns the gain values list of RTLSDR dongles.

Open gmbertani opened this issue 3 years ago • 0 comments

The RTL-SDR valid tuner gains values are returned by librtlsdr:rtlsdr_get_tuner_gains(). These values change with the tuner type. For R820T tuner for instance it's a nonlinear list of 29 values: 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6

The SoapyRTLSDR::SoapyRTLSDR() constructor loads this full list from the dongle but - since the SoapySDR API getGainRange() returns only a range (3-values tuple) - only the minimum and maximum of these values, can be read (the third element, step, is zero):

//extract min/max overall gain range

int num_gains = rtlsdr_get_tuner_gains(dev, nullptr);

if (num_gains > 0)
{
    std::vector<int> gains(num_gains);
    rtlsdr_get_tuner_gains(dev, gains.data());
    gainMin = *std::min_element(gains.begin(), gains.end()) / 10.0;
    gainMax = *std::max_element(gains.begin(), gains.end()) / 10.0;
}

So it's matter to make the gains vector a class member and find a way (API) to return its contents to the application.

gmbertani avatar May 24 '21 21:05 gmbertani