mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 03:36:24 -05:00
Better initial sample rate setup, remove hard-coded default rate and use device info matching /w fallback
This commit is contained in:
parent
4147582d2a
commit
d5d44b0b30
@ -175,10 +175,12 @@ IF(USE_AUDIO_PULSE)
|
|||||||
ENDIF(USE_AUDIO_PULSE)
|
ENDIF(USE_AUDIO_PULSE)
|
||||||
|
|
||||||
IF(USE_AUDIO_JACK)
|
IF(USE_AUDIO_JACK)
|
||||||
SET (OTHER_LIBRARIES ${OTHER_LIBRARIES} jack)
|
find_package(Jack)
|
||||||
|
SET (OTHER_LIBRARIES ${OTHER_LIBRARIES} ${JACK_LIBRARIES})
|
||||||
ADD_DEFINITIONS(
|
ADD_DEFINITIONS(
|
||||||
-D__UNIX_JACK__
|
-D__UNIX_JACK__
|
||||||
)
|
)
|
||||||
|
include_directories(${JACK_INCLUDE_DIRS})
|
||||||
ENDIF(USE_AUDIO_JACK)
|
ENDIF(USE_AUDIO_JACK)
|
||||||
|
|
||||||
IF(USE_AUDIO_ALSA)
|
IF(USE_AUDIO_ALSA)
|
||||||
|
50
cmake/Modules/FindJack.cmake
Normal file
50
cmake/Modules/FindJack.cmake
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Try to find JACK
|
||||||
|
# This will define the following variables:
|
||||||
|
#
|
||||||
|
# JACK_FOUND - Whether Jack was found.
|
||||||
|
# JACK_INCLUDE_DIRS - Jack include directories.
|
||||||
|
# JACK_LIBRARIES - Jack libraries.
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
if(JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
# in cache already
|
||||||
|
set(JACK_FOUND TRUE)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if(PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(_JACK jack)
|
||||||
|
endif(PKG_CONFIG_FOUND)
|
||||||
|
|
||||||
|
find_path(JACK_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
jack/jack.h
|
||||||
|
PATHS
|
||||||
|
${_JACK_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(JACK_LIBRARY
|
||||||
|
NAMES
|
||||||
|
jack
|
||||||
|
PATHS
|
||||||
|
${_JACK_LIBDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(JACK_INCLUDE_DIRS
|
||||||
|
${JACK_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(JACK_LIBRARIES
|
||||||
|
${JACK_LIBRARY}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(Jack DEFAULT_MSG JACK_LIBRARIES JACK_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
# show the JACK_INCLUDE_DIRS and JACK_LIBRARIES variables only in the advanced view
|
||||||
|
mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY JACK_INCLUDE_DIRS JACK_LIBRARIES)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
@ -164,7 +164,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
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?"));
|
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;
|
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++) {
|
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||||
new wxMenu;
|
new wxMenu;
|
||||||
@ -250,8 +272,7 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
srateName << ((float)(*srate)/1000.0f) << "kHz";
|
srateName << ((float)(*srate)/1000.0f) << "kHz";
|
||||||
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?"));
|
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?"));
|
||||||
|
|
||||||
if ((*srate) == DEFAULT_AUDIO_SAMPLE_RATE) {
|
if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
|
||||||
AudioThread::deviceSampleRate[mdevices_i->first] = DEFAULT_AUDIO_SAMPLE_RATE;
|
|
||||||
itm->Check(true);
|
itm->Check(true);
|
||||||
}
|
}
|
||||||
audioSampleRateMenuItems[menu_id+j] = itm;
|
audioSampleRateMenuItems[menu_id+j] = itm;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static char *cubicsdr_xpm[] = {
|
static char const *cubicsdr_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"256 256 256 2 ",
|
"256 256 256 2 ",
|
||||||
" c #010101",
|
" c #010101",
|
||||||
|
@ -42,7 +42,6 @@ const char filePathSeparator =
|
|||||||
#define DEFAULT_FFT_SIZE 2048
|
#define DEFAULT_FFT_SIZE 2048
|
||||||
|
|
||||||
#define DEFAULT_FREQ 100000000
|
#define DEFAULT_FREQ 100000000
|
||||||
#define DEFAULT_AUDIO_SAMPLE_RATE 44100
|
|
||||||
#define DEFAULT_DEMOD_TYPE 1
|
#define DEFAULT_DEMOD_TYPE 1
|
||||||
#define DEFAULT_DEMOD_BW 200000
|
#define DEFAULT_DEMOD_BW 200000
|
||||||
|
|
||||||
|
@ -303,8 +303,10 @@ void AudioThread::setupDevice(int deviceId) {
|
|||||||
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
|
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
|
||||||
sampleRate = deviceSampleRate[parameters.deviceId];
|
sampleRate = deviceSampleRate[parameters.deviceId];
|
||||||
} else {
|
} else {
|
||||||
sampleRate = DEFAULT_AUDIO_SAMPLE_RATE;
|
std::cout << "Error, device sample rate wasn't initialized?" << std::endl;
|
||||||
deviceSampleRate[parameters.deviceId] = sampleRate;
|
return;
|
||||||
|
// sampleRate = AudioThread::getDefaultAudioSampleRate();
|
||||||
|
// deviceSampleRate[parameters.deviceId] = sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
|
if (deviceController.find(parameters.deviceId) == deviceController.end()) {
|
||||||
|
@ -132,8 +132,8 @@ public:
|
|||||||
int demodType;
|
int demodType;
|
||||||
|
|
||||||
DemodulatorThreadParameters() :
|
DemodulatorThreadParameters() :
|
||||||
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(
|
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(0),
|
||||||
DEFAULT_AUDIO_SAMPLE_RATE), demodType(DEMOD_TYPE_FM) {
|
demodType(DEMOD_TYPE_FM) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ void DemodulatorThread::threadMain() {
|
|||||||
demodStereoData.resize(bufSize);
|
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) {
|
if (stereoShiftFrequency != freq) {
|
||||||
nco_crcf_set_frequency(stereoShifter, freq);
|
nco_crcf_set_frequency(stereoShifter, freq);
|
||||||
|
Loading…
Reference in New Issue
Block a user