MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / actionOnMenuSampleRate

Method actionOnMenuSampleRate

src/AppFrame.cpp:1569–1624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1567}
1568
1569bool AppFrame::actionOnMenuSampleRate(wxCommandEvent& event) {
1570
1571 if (event.GetId() == wxID_BANDWIDTH_MANUAL) {
1572 wxGetApp().setSampleRate(manualSampleRate);
1573 return true;
1574 }
1575 else if (event.GetId() == wxID_BANDWIDTH_MANUAL_DIALOG) {
1576
1577 int rateHigh = 0, rateLow = 0;
1578
1579 SDRDeviceInfo *dev = wxGetApp().getDevice();
1580 if (dev != nullptr) {
1581
1582 std::vector<long> sampleRateList = dev->getSampleRates(SOAPY_SDR_RX, 0);
1583
1584 //default
1585 rateLow = MANUAL_SAMPLE_RATE_MIN;
1586 rateHigh = MANUAL_SAMPLE_RATE_MAX;
1587
1588 if (!sampleRateList.empty()) {
1589 rateLow = sampleRateList.front();
1590 rateHigh = sampleRateList.back();
1591 }
1592
1593 long bw = wxGetNumberFromUser("\n" + dev->getName() + "\n\n "
1594 + "min: " + std::to_string(rateLow) + " Hz"
1595 + ", max: " + std::to_string(rateHigh) + " Hz\n",
1596 "Sample Rate in Hz",
1597 "Manual Sample Rate Entry",
1598 //If a manual sample rate has already been input, recall this one.
1599 manualSampleRate > 0 ? manualSampleRate : wxGetApp().getSampleRate(),
1600 rateLow,
1601 rateHigh,
1602 this);
1603
1604 if (bw != -1) {
1605
1606 manualSampleRate = bw;
1607 sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->Enable(true);
1608
1609 sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->SetItemLabel(wxT("Manual : ") + frequencyToStr(manualSampleRate));
1610 sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->Check(true);
1611 wxGetApp().setSampleRate(manualSampleRate);
1612 }
1613 }
1614
1615 return true;
1616 }
1617 else if (event.GetId() >= wxID_BANDWIDTH_BASE && event.GetId() < wxID_BANDWIDTH_BASE + (int)sampleRates.size()) {
1618
1619 wxGetApp().setSampleRate(sampleRates[event.GetId() - wxID_BANDWIDTH_BASE]);
1620 return true;
1621 }
1622
1623 return false;
1624}
1625
1626bool AppFrame::actionOnMenuAudioSampleRate(wxCommandEvent& event) {

Callers

nothing calls this directly

Calls 8

frequencyToStrFunction · 0.85
getSampleRatesMethod · 0.80
setSampleRateMethod · 0.45
getDeviceMethod · 0.45
emptyMethod · 0.45
getNameMethod · 0.45
getSampleRateMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected