mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-06 16:04:54 -04:00
Attempt best-match sample rate near "default"
- Fix hard-coded usage of DEFAULT_SAMPLE_RATE, now “suggested” rate
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user