mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-04 06:54:41 -04:00
Better initial sample rate setup, remove hard-coded default rate and use device info matching /w fallback
This commit is contained in:
+25
-4
@@ -164,7 +164,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||
wxMenuItem *itm = menu->AppendRadioItem(wxID_RT_AUDIO_DEVICE + mdevices_i->first, mdevices_i->second.name, wxT("Description?"));
|
||||
@@ -236,7 +235,30 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
|
||||
menu = new wxMenu;
|
||||
|
||||
i = 0;
|
||||
|
||||
#define NUM_RATES_DEFAULT 4
|
||||
int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
|
||||
|
||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||
int desired_rate = 0;
|
||||
int desired_rank = NUM_RATES_DEFAULT+1;
|
||||
|
||||
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
|
||||
for (i = 0; i < NUM_RATES_DEFAULT; i++) {
|
||||
if (desired_rates[i] == (*srate)) {
|
||||
if (desired_rank > i) {
|
||||
desired_rank = i;
|
||||
desired_rate = (*srate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (desired_rank > NUM_RATES_DEFAULT) {
|
||||
desired_rate = mdevices_i->second.sampleRates.back();
|
||||
}
|
||||
AudioThread::deviceSampleRate[mdevices_i->first] = desired_rate;
|
||||
}
|
||||
|
||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||
new wxMenu;
|
||||
@@ -250,8 +272,7 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
srateName << ((float)(*srate)/1000.0f) << "kHz";
|
||||
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?"));
|
||||
|
||||
if ((*srate) == DEFAULT_AUDIO_SAMPLE_RATE) {
|
||||
AudioThread::deviceSampleRate[mdevices_i->first] = DEFAULT_AUDIO_SAMPLE_RATE;
|
||||
if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
|
||||
itm->Check(true);
|
||||
}
|
||||
audioSampleRateMenuItems[menu_id+j] = itm;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* XPM */
|
||||
static char *cubicsdr_xpm[] = {
|
||||
static char const *cubicsdr_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"256 256 256 2 ",
|
||||
" c #010101",
|
||||
|
||||
@@ -42,7 +42,6 @@ const char filePathSeparator =
|
||||
#define DEFAULT_FFT_SIZE 2048
|
||||
|
||||
#define DEFAULT_FREQ 100000000
|
||||
#define DEFAULT_AUDIO_SAMPLE_RATE 44100
|
||||
#define DEFAULT_DEMOD_TYPE 1
|
||||
#define DEFAULT_DEMOD_BW 200000
|
||||
|
||||
|
||||
@@ -303,8 +303,10 @@ void AudioThread::setupDevice(int deviceId) {
|
||||
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
|
||||
sampleRate = deviceSampleRate[parameters.deviceId];
|
||||
} else {
|
||||
sampleRate = DEFAULT_AUDIO_SAMPLE_RATE;
|
||||
deviceSampleRate[parameters.deviceId] = sampleRate;
|
||||
std::cout << "Error, device sample rate wasn't initialized?" << std::endl;
|
||||
return;
|
||||
// sampleRate = AudioThread::getDefaultAudioSampleRate();
|
||||
// deviceSampleRate[parameters.deviceId] = sampleRate;
|
||||
}
|
||||
|
||||
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
|
||||
|
||||
@@ -132,8 +132,8 @@ public:
|
||||
int demodType;
|
||||
|
||||
DemodulatorThreadParameters() :
|
||||
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(
|
||||
DEFAULT_AUDIO_SAMPLE_RATE), demodType(DEMOD_TYPE_FM) {
|
||||
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0),
|
||||
demodType(DEMOD_TYPE_FM) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ void DemodulatorThread::threadMain() {
|
||||
demodStereoData.resize(bufSize);
|
||||
}
|
||||
|
||||
double freq = (2.0 * M_PI) * (((double) abs(38000)) / ((double) inp->sampleRate));
|
||||
double freq = (2.0 * M_PI) * ((double) 38000) / ((double) inp->sampleRate);
|
||||
|
||||
if (stereoShiftFrequency != freq) {
|
||||
nco_crcf_set_frequency(stereoShifter, freq);
|
||||
|
||||
Reference in New Issue
Block a user