mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-08 10:06:07 -05:00
Attempt best-match sample rate near "default"
- Fix hard-coded usage of DEFAULT_SAMPLE_RATE, now “suggested” rate
This commit is contained in:
parent
091ce26ed6
commit
d85c94ead0
@ -112,7 +112,7 @@ long long strToFrequency(std::string freqStr) {
|
||||
}
|
||||
|
||||
|
||||
CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0), ppm(0), snap(1), sampleRate(DEFAULT_SAMPLE_RATE), directSamplingMode(0),
|
||||
CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0), ppm(0), snap(1), sampleRate(0), directSamplingMode(0),
|
||||
sdrThread(NULL), sdrPostThread(NULL), spectrumVisualThread(NULL), demodVisualThread(NULL), pipeSDRIQData(NULL), pipeIQVisualData(NULL), pipeAudioVisualData(NULL), t_SDR(NULL), t_PostSDR(NULL) {
|
||||
|
||||
}
|
||||
@ -411,10 +411,20 @@ void CubicSDR::setDevice(SDRDeviceInfo *dev) {
|
||||
// frequency = freqLow;
|
||||
// }
|
||||
|
||||
int rateHigh, rateLow;
|
||||
rateLow = chan->getSampleRates()[0];
|
||||
rateHigh = chan->getSampleRates()[chan->getSampleRates().size()-1];
|
||||
// Try for a reasonable default sample rate.
|
||||
if (!sampleRate) {
|
||||
sampleRate = chan->getSampleRateNear(DEFAULT_SAMPLE_RATE);
|
||||
}
|
||||
|
||||
int rateHigh, rateLow;
|
||||
|
||||
rateHigh = rateLow = sampleRate;
|
||||
|
||||
if (chan->getSampleRates().size()) {
|
||||
rateLow = chan->getSampleRates()[0];
|
||||
rateHigh = chan->getSampleRates()[chan->getSampleRates().size()-1];
|
||||
}
|
||||
|
||||
if (sampleRate > rateHigh) {
|
||||
sampleRate = rateHigh;
|
||||
} else if (sampleRate < rateLow) {
|
||||
|
@ -144,7 +144,7 @@ public:
|
||||
int demodType;
|
||||
|
||||
DemodulatorThreadParameters() :
|
||||
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0),
|
||||
frequency(0), sampleRate(0), bandwidth(200000), audioSampleRate(0),
|
||||
demodType(DEMOD_TYPE_FM) {
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user