sdrplayWorker::sdrplayWorker (int32_t deviceRate, int32_t bandWidth, int32_t defaultFreq, sdrplayLoader *f, RingBuffer<int16_t> *buf, bool *OK) { int err; this -> deviceRate = float(deviceRate) / MHz (1); this -> bandWidth = bandWidth / MHz (1); this -> defaultFreq = float(defaultFreq) / MHz (1); this -> functions = f; _I_Buffer = buf; *OK = false; // just the default mir_sdr_Bw_MHzT aa = bandWidth <= 200 * KHz (1) ? mir_sdr_BW_0_200 : bandWidth <= 300 * KHz (1) ? mir_sdr_BW_0_300 : bandWidth <= 600 * KHz (1) ? mir_sdr_BW_0_600 : bandWidth <= 1536 * KHz (1) ? mir_sdr_BW_1_536 : bandWidth <= 5000 * KHz (1) ? mir_sdr_BW_5_000 : bandWidth <= 6000 * KHz (1) ? mir_sdr_BW_6_000 : bandWidth <= 7000 * KHz (1) ? mir_sdr_BW_7_000 : bandWidth <= 8000 * KHz (1) ? mir_sdr_BW_8_000 : mir_sdr_BW_8_000; // Note: the "API check" has been done by the owner of this thread err = functions -> my_mir_sdr_Init (40, this -> deviceRate, this -> defaultFreq, aa, mir_sdr_IF_Zero, &sps); if (err != 0) { fprintf (stderr, "Probleem init\n"); return; } err = functions -> my_mir_sdr_SetDcMode (4, 1); err = functions -> my_mir_sdr_SetDcTrackTime (63); // // some defaults: lastFrequency = defaultFreq; // the parameter!!!! lastGain = 25; // dummy runnable = true; anyChange = 0; start (); *OK = true; }
/** * \brief set_channelSelect * Depending on the GUI the user might select a channel * or some magic will cause a channel to be selected */ void RadioInterface::set_channelSelect (QString s) { int16_t i; struct dabFrequencies *finger; bool localRunning = running; int32_t tunedFrequency; if (localRunning) { soundOut -> stop (); inputDevice -> stopReader (); inputDevice -> resetBuffer (); } clear_showElements (); tunedFrequency = 0; if (dabBand == BAND_III) finger = bandIII_frequencies; else finger = Lband_frequencies; for (i = 0; finger [i]. key != NULL; i ++) { if (finger [i]. key == s) { tunedFrequency = KHz (finger [i]. fKHz); break; } } if (tunedFrequency == 0) return; inputDevice -> setVFOFrequency (tunedFrequency); if (localRunning) { soundOut -> restart (); inputDevice -> restartReader (); my_ofdmProcessor -> reset (); running = true; } emit displayCurrentChannel(s, tunedFrequency); }
#include <hw/cpu_freq_sampling.hpp> #include <common> #include <vector> #include <algorithm> #include <os> #include <irq_manager.hpp> /** @note C-style code here, since we're dealing with interrupt handling. The hardware expects a pure function pointer, and asm can't (easily) call class member functions. */ // This is how you provide storage for a static constexpr variable. constexpr MHz PIT::frequency_; extern "C" double _CPUFreq_ = 0; extern "C" constexpr uint16_t _cpu_sampling_freq_divider_ = KHz(PIT::frequency()).count() * 10; // Run 1 KHz Lowest: 0xffff static constexpr int do_samples_ = 20; std::vector<uint64_t> _cpu_timestamps; std::vector<double> _cpu_freq_samples; constexpr MHz test_frequency(){ return MHz(PIT::frequency().count() / _cpu_sampling_freq_divider_); } MHz calculate_cpu_frequency(){ // We expect the cpu_sampling_irq_handler to push in samples; while (_cpu_timestamps.size() < do_samples_) OS::halt();
int32_t dabStick::defaultFrequency (void) { return KHz (94700); }
void dabStick::setupDevice (int32_t rateIn, int32_t rateOut) { int r; int16_t deviceIndex; int16_t i; // libraryLoaded = false; workerHandle = NULL; d_filter = NULL; _I_Buffer = NULL; open = false; statusLabel -> setText ("setting up"); #ifdef __MINGW32__ Handle = LoadLibrary ((wchar_t *)L"rtlsdr.dll"); #else Handle = dlopen ("librtlsdr.so", RTLD_NOW); #endif if (Handle == NULL) { fprintf (stderr, "Failed to open rtlsdr.dll\n"); statusLabel -> setText ("no rtlsdr lib"); return; } libraryLoaded = true; fprintf (stderr, "rtlsdr is loaded\n"); if (!load_rtlFunctions ()) { statusLabel -> setText ("load failed"); goto err; } // vfoFrequency is the VFO frequency vfoFrequency = KHz (94700); // just a dummy vfoOffset = 0; deviceCount = (this -> rtlsdr_get_device_count) (); if (deviceCount == 0) { statusLabel -> setText ("no device"); fprintf (stderr, "No devices found\n"); goto err; } deviceIndex = 0; // default if (deviceCount > 1) { dongleSelector = new dongleSelect (); for (deviceIndex = 0; deviceIndex < deviceCount; deviceIndex ++) { dongleSelector -> addtoDongleList (rtlsdr_get_device_name (deviceIndex)); } deviceIndex = dongleSelector -> QDialog::exec (); delete dongleSelector; } // // OK, now open the hardware r = this -> rtlsdr_open (&device, deviceIndex); if (r < 0) { fprintf (stderr, "Opening dabstick failed\n"); statusLabel -> setText ("opening failed"); goto err; } open = true; r = (this -> rtlsdr_set_sample_rate) (device, rateIn); if (r < 0) { fprintf (stderr, "Setting samplerate failed\n"); statusLabel -> setText ("samplerate"); goto err; } gainsCount = rtlsdr_get_tuner_gains (device, NULL); fprintf(stderr, "Supported gain values (%d): ", gainsCount); gains = new int [gainsCount]; gainsCount = rtlsdr_get_tuner_gains (device, gains); for (i = 0; i < gainsCount; i++) fprintf(stderr, "%.1f ", gains [i] / 10.0); rtlsdr_set_tuner_gain_mode (device, 1); rtlsdr_set_tuner_gain (device, gains [gainsCount / 2]); gainSlider -> setMaximum (gainsCount); gainSlider -> setValue (8); _I_Buffer = new RingBuffer<uint8_t>(1024 * 1024); workerHandle = NULL; d_filter = new DecimatingFIR (rateIn / rateOut * 5 - 1, - rateOut / 2, rateOut / 2, rateIn, rateIn / rateOut); connect (gainSlider, SIGNAL (valueChanged (int)), this, SLOT (setExternalGain (int))); connect (f_correction, SIGNAL (valueChanged (int)), this, SLOT (setCorrection (int))); connect (khzOffset, SIGNAL (valueChanged (int)), this, SLOT (setKhzOffset (int))); connect (hzOffset, SIGNAL (valueChanged (int)), this, SLOT (setHzOffset (int))); connect (rateSelector, SIGNAL (activated (const QString &)), this, SLOT (set_rateSelector (const QString &))); connect (checkAgc, SIGNAL (stateChanged (int)), this, SLOT (setAgc (int))); if (dabSettings != NULL) { dabSettings -> beginGroup ("dabStick"); int k = dabSettings -> value ("dab_externalGain", 24). toInt (); gainSlider -> setValue (k); k = dabSettings -> value ("dab_correction", 0). toInt (); f_correction -> setValue (k); k = dabSettings -> value ("dab_khzOffset", 0). toInt (); khzOffset -> setValue (k); k = dabSettings -> value ("dab_hzOffset", 0). toInt (); hzOffset -> setValue (k); dabSettings -> endGroup (); } statusLabel -> setText ("Loaded"); return; err: if (open) rtlsdr_close (device); #ifdef __MINGW32__ FreeLibrary (Handle); #else dlclose (Handle); #endif libraryLoaded = false; open = false; return; }
// // Our wrapper is a simple classs dabStick::dabStick (QSettings *s, bool *success) { int16_t deviceCount; int32_t r; int16_t deviceIndex; int16_t i; QString temp; int k; dabstickSettings = s; *success = false; // just the default this -> myFrame = new QFrame (NULL); setupUi (this -> myFrame); this -> myFrame -> show (); inputRate = 2048000; libraryLoaded = false; open = false; _I_Buffer = NULL; workerHandle = NULL; lastFrequency = KHz (94700); // just a dummy this -> sampleCounter= 0; this -> vfoOffset = 0; gains = NULL; #ifdef __MINGW32__ const char *libraryString = "rtlsdr.dll"; Handle = LoadLibrary ((wchar_t *)L"rtlsdr.dll"); #else const char *libraryString = "librtlsdr.so"; Handle = dlopen ("librtlsdr.so", RTLD_NOW); #endif if (Handle == NULL) { fprintf (stderr, "failed to open %s\n", libraryString); return; } libraryLoaded = true; if (!load_rtlFunctions ()) goto err; // // Ok, from here we have the library functions accessible deviceCount = this -> rtlsdr_get_device_count (); if (deviceCount == 0) { fprintf (stderr, "No devices found\n"); return; } deviceIndex = 0; // default if (deviceCount > 1) { dongleSelector = new dongleSelect (); for (deviceIndex = 0; deviceIndex < deviceCount; deviceIndex ++) { dongleSelector -> addtoDongleList (rtlsdr_get_device_name (deviceIndex)); } deviceIndex = dongleSelector -> QDialog::exec (); delete dongleSelector; } // // OK, now open the hardware r = this -> rtlsdr_open (&device, deviceIndex); if (r < 0) { fprintf (stderr, "Opening dabstick failed\n"); *success = false; return; } open = true; r = this -> rtlsdr_set_sample_rate (device, inputRate); if (r < 0) { fprintf (stderr, "Setting samplerate failed\n"); *success = false; return; } r = this -> rtlsdr_get_sample_rate (device); fprintf (stderr, "samplerate set to %d\n", r); gainsCount = rtlsdr_get_tuner_gains (device, NULL); fprintf(stderr, "Supported gain values (%d): ", gainsCount); gains = new int [gainsCount]; gainsCount = rtlsdr_get_tuner_gains (device, gains); for (i = gainsCount; i > 0; i--) { fprintf(stderr, "%.1f ", gains [i - 1] / 10.0); combo_gain -> addItem (QString::number (gains [i - 1])); } rtlsdr_set_tuner_gain_mode (device, 1); rtlsdr_set_tuner_gain (device, gains [gainsCount / 2]); _I_Buffer = new RingBuffer<uint8_t>(1024 * 1024); dabstickSettings -> beginGroup ("dabstickSettings"); temp = dabstickSettings -> value ("externalGain", "10"). toString (); k = combo_gain -> findText (temp); if (k != -1) { combo_gain -> setCurrentIndex (k); rtlsdr_set_tuner_gain (device, temp. toInt ()); } temp = dabstickSettings -> value ("autogain", "autogain off"). toString (); rtlsdr_set_tuner_gain_mode (device, temp == "autogain off" ? 0 : 1); f_correction -> setValue (dabstickSettings -> value ("f_correction", 0). toInt ()); KhzOffset -> setValue (dabstickSettings -> value ("KhzOffset", 0). toInt ()); dabstickSettings -> endGroup (); set_fCorrection (f_correction -> value ()); set_KhzOffset (KhzOffset -> value ()); connect (combo_gain, SIGNAL (activated (const QString &)), this, SLOT (setExternalGain (const QString &))); connect (combo_autogain, SIGNAL (activated (const QString &)), this, SLOT (set_autogain (const QString &))); connect (f_correction, SIGNAL (valueChanged (int)), this, SLOT (set_fCorrection (int))); connect (KhzOffset, SIGNAL (valueChanged (int)), this, SLOT (set_KhzOffset (int))); *success = true; return; err: if (open) this -> rtlsdr_close (device); #ifdef __MINGW32__ FreeLibrary (Handle); #else dlclose (Handle); #endif libraryLoaded = false; open = false; *success = false; return; }
Kbps(96), Kbps(112), Kbps(128), Kbps(160), Kbps(192), Kbps(224), Kbps(256), Kbps(320)}}; AcceptedBitrates DLNA_BITRATES_MPEG1_L3X_VBR = { true, { Kbps(8), Kbps(320) }}; AcceptedBitrates DLNA_BITRATES_MPEG1_L3X_CBR = { false, { Kbps(8), Kbps(16), Kbps(24), Kbps(32), Kbps(40), Kbps(48), Kbps(56), Kbps(64), Kbps(80), Kbps(96), Kbps(112), Kbps(128), Kbps(160), Kbps(192), Kbps(224), Kbps(256), Kbps(320)}}; AcceptedBitrates DLNA_BITRATES_MPEG1_L2 = { true, { Kbps(32), Kbps(384) }}; AcceptedSamplingRates DLNA_SAMPLINGRATES_MPEG1_L1_DVB = {{ KHz(16), KHz(22.05), KHz(24), KHz(32), KHz(44.1), KHz(48) }}; AcceptedSamplingRates DLNA_SAMPLINGRATES_MPEG1_L2 = {{ KHz(32), KHz(44.1), KHz(48) }}; AcceptedSamplingRates DLNA_SAMPLINGRATES_MPEG1_L2_DVB = {{ KHz(16), KHz(22.05), KHz(24), KHz(32), KHz(44.1), KHz(48) }}; AcceptedSamplingRates DLNA_SAMPLINGRATES_MPEG1_L3 = {{ KHz(32), KHz(44.1), KHz(48) }}; AcceptedSamplingRates DLNA_SAMPLINGRATES_MPEG1_L3X = {{ KHz(16), KHz(22.05), KHz(24), KHz(32), KHz(44.1), KHz(48) }}; AcceptedAudioChannels DLNA_AUDIOCHANNELS_MPEG1_L1_DVB = { 6, { CHANNEL_LAYOUT_10, CHANNEL_LAYOUT_20, CHANNEL_LAYOUT_21, CHANNEL_LAYOUT_22, CHANNEL_LAYOUT_30, CHANNEL_LAYOUT_31, CHANNEL_LAYOUT_32, }, false }; AcceptedAudioChannels DLNA_AUDIOCHANNELS_MPEG1_L2_DVB = { 6, { CHANNEL_LAYOUT_10, CHANNEL_LAYOUT_20, CHANNEL_LAYOUT_21, CHANNEL_LAYOUT_22, CHANNEL_LAYOUT_30, CHANNEL_LAYOUT_31,
int32_t virtualInput::getRate (void) { return KHz (192); }
// distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //#define DEBUG #include <hw/cpu_freq_sampling.hpp> #include <kernel/irq_manager.hpp> #include <common> #include <vector> #include <algorithm> #include <os> double _CPUFreq_ = 0; extern "C" const uint16_t _cpu_sampling_freq_divider_ = KHz(hw::PIT::frequency()).count() * 10; // Run 1 KHz Lowest: 0xffff namespace hw { /** @note C-style code here, since we're dealing with interrupt handling. The hardware expects a pure function pointer, and asm can't (easily) call class member functions. */ // This is how you provide storage for a static constexpr variable. constexpr MHz PIT::frequency_; static constexpr int do_samples_ = 20; std::vector<uint64_t> _cpu_timestamps; std::vector<double> _cpu_freq_samples; constexpr MHz test_frequency(){