Attempt best-match sample rate near "default"

- Fix hard-coded usage of DEFAULT_SAMPLE_RATE, now “suggested” rate
This commit is contained in:
Charles J. Cliffe
2015-10-20 23:57:54 -04:00
parent 091ce26ed6
commit d85c94ead0
6 changed files with 33 additions and 7 deletions
+15
View File
@@ -1,4 +1,5 @@
#include "SDRDeviceInfo.h"
#include <cstdlib>
SDRDeviceRange::SDRDeviceRange() {
low = 0;
@@ -84,6 +85,20 @@ std::vector<long> &SDRDeviceChannel::getSampleRates() {
return sampleRates;
}
long SDRDeviceChannel::getSampleRateNear(long sampleRate_in) {
long returnRate = sampleRates[0];
long sDelta = (long)sampleRate_in-sampleRates[0];
long minDelta = abs(sDelta);
for (std::vector<long>::iterator i = sampleRates.begin(); i != sampleRates.end(); i++) {
long thisDelta = abs(sampleRate_in - (*i));
if (thisDelta < minDelta) {
minDelta = thisDelta;
returnRate = (*i);
}
}
return returnRate;
}
std::vector<long long> &SDRDeviceChannel::getFilterBandwidths() {
return filterBandwidths;
}
+1
View File
@@ -69,6 +69,7 @@ public:
SDRDeviceRange &getRFRange();
std::vector<long> &getSampleRates();
long getSampleRateNear(long sampleRate_in);
std::vector<long long> &getFilterBandwidths();
const bool& hasHardwareDC() const;
+1 -1
View File
@@ -11,7 +11,7 @@ SDRThread::SDRThread() : IOThread() {
deviceConfig.store(NULL);
deviceInfo.store(NULL);
sampleRate.store(DEFAULT_SAMPLE_RATE);
sampleRate.store(0);
frequency.store(0);
offset.store(0);
ppm.store(0);
+1 -1
View File
@@ -22,7 +22,7 @@ public:
std::vector<liquid_float_complex> data;
SDRThreadIQData() :
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), dcCorrected(true), numChannels(0) {
frequency(0), sampleRate(0), dcCorrected(true), numChannels(0) {
}