コード例 #1
0
ファイル: Breakpoint.C プロジェクト: gesellkammer/loristrck
// ---------------------------------------------------------------------------
//	addNoiseEnergy
// ---------------------------------------------------------------------------
//!	Add noise (bandwidth) energy to this Breakpoint by computing new 
//!	amplitude and bandwidth values. enoise may be negative, but 
//!	noise energy cannot be removed (negative energy added) in excess 
//!	of the current noise energy.
//!	
//!	\param enoise is the amount of noise energy to add to
//!	this Breakpoint.
//
void 
Breakpoint::addNoiseEnergy( double enoise )
{
	//	compute current energies:
	double e = amplitude() * amplitude();	//	current total energy
	double n = e * bandwidth();				//	current noise energy
	
	//	Assert( e >= n );
	//	could complain, but its recoverable, just fix it:
	if ( e < n )
    {
		e = n;
	}
    
	//	guard against divide-by-zero, and don't allow
	//	the sinusoidal energy to decrease:
	if ( n + enoise > 0. ) 
	{
		//	if new noise energy is positive, total
		//	energy must also be positive:
		//	Assert( e + enoise > 0 );
		setBandwidth( (n + enoise) / (e + enoise) );
		setAmplitude( std::sqrt(e + enoise) );
	}
	else 
	{
		//	if new noise energy is negative, leave 
		//	all sinusoidal energy:
		setBandwidth( 0. );
		setAmplitude( std::sqrt( e - n ) );
	}
}
Filter::Filter(void)
{
  m_resonance = ONE_OVER_SQRT2;
  m_r2 = 1/m_resonance;
  m_h = 0.5f;
  m_c_low=m_c_band=m_c_high=0.0f;
#ifdef VSTI
  m_samplerate = SAMPLERATE;
#endif
  m_base_freq=0.0f;
  m_mod=0.0f;
  m_staticmod=0.0f;
  m_bandwidth=2.0f;
  setMode(0.0f);
  setCutoff(0.5f);
  setMod(0.0f,0.0f);
  setBandwidth(2.0f);
  setDrive(0.0f);
  m_staticmod = 0.0f;
  setOutputLevel(1.0f);
  m_cutoff = 0.0f;
  calculateCoefficients();
  m_calc_coefficients = false;
  m_calc_interval = STATE_CALC_INTERVAL;
  reset(); 
}
コード例 #3
0
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
    setGain(getGain());
    if (demodulatorPreThread) {
        std::string currentDemodType = demodulatorPreThread->getDemodType();
        if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
            lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
            lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
        }
#if ENABLE_DIGITAL_LAB
        if (activeOutput) {
            activeOutput->Hide();
        }
#endif

        demodulatorPreThread->setDemodType(demod_type_in);
        int lastbw = 0;
        if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
            lastbw = lastModemBandwidth[demod_type_in];
        }
        if (!lastbw) {
            lastbw = Modem::getModemDefaultSampleRate(demod_type_in);
        }
        if (lastbw) {
            setBandwidth(lastbw);
        }
    }
}
コード例 #4
0
// bandwidth: Bandwidth     (Hz)
bool RfSystem::setSlotBandwidth(Basic::Number* const num)
{
    bool ok = false;
    if (num != 0) {

        LCreal bw = -1.0f;

        const Basic::Frequency* p = dynamic_cast<const Basic::Frequency*>(num);
        if (p != 0) {
            // Has frequency and we need hertz
            bw = Basic::Hertz::convertStatic(*p);
        }
        else {
            // Just a Number
            bw = num->getReal();
        }

        if (bw >= 1.0) {
            ok = setBandwidth(bw);
        }
        else {
            std::cerr << "RfSystem::setSlotBandwidth: Bandwidth must be greater than or equal to one!" << std::endl;
        }
    }
    return ok;
}
コード例 #5
0
ファイル: Gaussian.cpp プロジェクト: Abhishekpatil/SonATA
/**
 * Set up the noise/signal generator
 *
 * Description:\n
 * 	Set the parameters for the noise generator, including seed, average
 *  noise power and bandwidth.\n\n
 * Notes:\n
 *  This initializes the signal generator, resetting all counters and
 *  summing registers.  Any previously added signals are removed.
 */
void
Gaussian::setup(int32_t seed_, float64_t bandwidthMHz_, float64_t avgPower_)
{
	setSeed(seed_);
	setBandwidth(bandwidthMHz_);
	setNoisePower(avgPower_);
	sampleCnt = 0;
	power = ComplexFloat64(0, 0);
	sum = ComplexFloat64(0, 0);
	for (SigList::iterator s = signals.begin(); s != signals.end(); ++s)
		delete s->sig;
	signals.clear();
}
コード例 #6
0
ファイル: NotchFilterPlugin.cpp プロジェクト: KDE/kwave
//***************************************************************************
void Kwave::NotchFilterPlugin::updateFilter(Kwave::SampleSource *filter,
                                            bool force)
{
    double sr = signalRate();

    if (!filter) return;

    if (!qFuzzyCompare(m_frequency, m_last_freq) || force)
	filter->setAttribute(SLOT(setFrequency(QVariant)),
	    QVariant((m_frequency * 2.0 * M_PI) / sr));

    if (!qFuzzyCompare(m_bw, m_last_bw) || force)
	filter->setAttribute(SLOT(setBandwidth(QVariant)),
	    QVariant((m_bw * 2.0 * M_PI) / sr));

    m_last_freq  = m_frequency;
    m_last_bw    = m_bw;
}
コード例 #7
0
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
    setGain(getGain());
    if (demodulatorPreThread) {
        std::string currentDemodType = demodulatorPreThread->getDemodType();
        if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
            lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
            lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
        }
#if ENABLE_DIGITAL_LAB
        if (activeOutput) {
            activeOutput->Hide();
        }
#endif

        demodulatorPreThread->setDemodType(demod_type_in);
        int lastbw = 0;
        if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
            lastbw = lastModemBandwidth[demod_type_in];
        }
        if (!lastbw) {
            lastbw = Modem::getModemDefaultSampleRate(demod_type_in);
        }
        if (lastbw) {
            setBandwidth(lastbw);
        }

#if ENABLE_DIGITAL_LAB
        if (isModemInitialized() && getModemType() == "digital") {
            ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
            outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
        }
#endif
    }
    
    wxGetApp().getBookmarkMgr().updateActiveList();
}
コード例 #8
0
ファイル: Estimator.cpp プロジェクト: Re-bort/NNDK
Estimator2D<Mahalanobis2D>::Estimator2D(const VECTOR& X, const VECTOR& Y)
    : X_(&X), Y_(&Y)
{
    setBandwidth(scottBandwidth(X.size(), 2.0, 1.0));
    setCovariance(var(X), var(Y), covar(X, Y));
}
コード例 #9
0
ファイル: Estimator.cpp プロジェクト: Re-bort/NNDK
Estimator<Mahalanobis>::Estimator(const MATRIX& X)
    : X_(&X)
{
    setBandwidth(scottBandwidth(X.rows(), X.columns(), 1.0));
    setCovariance(X.transpose()*X);
}
コード例 #10
0
ファイル: demod_am.cpp プロジェクト: oldscienceguy/PebbleSDR
Demod_AM::Demod_AM(int _inputRate, int _numSamples) :
    Demod(_inputRate, _numSamples)
{
	m_amDc = m_amDcLast = 0.0;
	setBandwidth(16000); //For testing
}
void Filter::setResonance(float resonance)
{
  m_resonance = ONE_OVER_SQRT2 + 99.0f * (resonance*resonance*resonance);
  setBandwidth(40.0f * (resonance * resonance) + 0.001f);
  m_calc_coefficients = true;
}
コード例 #12
0
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
    tex_update.lock();
    wxPaintDC dc(this);
    
    const wxSize ClientSize = GetClientSize();
    long double currentZoom = zoom;
    
    if (mouseZoom != 1) {
        currentZoom = mouseZoom;
        mouseZoom = mouseZoom + (1.0 - mouseZoom) * 0.2;
        if (fabs(mouseZoom-1.0)<0.01) {
            mouseZoom = 1;
        }
    }
    
    if (scaleMove != 0) {
        SpectrumVisualProcessor *sp = wxGetApp().getSpectrumProcessor();
        FFTVisualDataThread *wdt = wxGetApp().getAppFrame()->getWaterfallDataThread();
        SpectrumVisualProcessor *wp = wdt->getProcessor();
        float factor = sp->getScaleFactor();

        factor += scaleMove * 0.02;
        
        if (factor < 0.25) {
            factor = 0.25;
        }
        if (factor > 10.0) {
            factor = 10.0;
        }
        
        sp->setScaleFactor(factor);
        wp->setScaleFactor(factor);
    }
    
    if (freqMove != 0.0) {
        long long newFreq = getCenterFrequency() + (long long)((long double)getBandwidth()*freqMove) * 0.01;
        
        long long minFreq = bandwidth/2;
        if (newFreq < minFreq) {
            newFreq = minFreq;
        }

        updateCenterFrequency(newFreq);
        
        if (!freqMoving) {
            freqMove -= (freqMove * 0.2);
            if (fabs(freqMove) < 0.01) {
                freqMove = 0.0;
            }
        }
    }
    
    long long bw;
    if (currentZoom != 1) {
        long long freq = wxGetApp().getFrequency();
        bw = getBandwidth();

        double mpos = 0;
        float mouseInView = false;

        if (mouseTracker.mouseInView()) {
            mpos = mouseTracker.getMouseX();
            mouseInView = true;
        } else if (spectrumCanvas && spectrumCanvas->getMouseTracker()->mouseInView()) {
            mpos = spectrumCanvas->getMouseTracker()->getMouseX();
            mouseInView = true;
        }

        if (currentZoom < 1) {
            bw = (long long) ceil((long double) bw * currentZoom);
            if (bw < minBandwidth) {
                bw = minBandwidth;
            }
            if (mouseInView) {
                long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth());
                long long mfreqB = getFrequencyAt(mpos, centerFreq, bw);
                centerFreq += mfreqA - mfreqB;
            }
            
            setView(centerFreq, bw);
        } else {
            if (isView) {
                bw = (long long) ceil((long double) bw * currentZoom);

                if (bw >= wxGetApp().getSampleRate()) {
                    disableView();
                    if (spectrumCanvas) {
                        spectrumCanvas->disableView();
                    }
                    bw = wxGetApp().getSampleRate();
                    centerFreq = wxGetApp().getFrequency();
                } else {
                    if (mouseInView) {
                        long long mfreqA = getFrequencyAt(mpos, centerFreq, getBandwidth());
                        long long mfreqB = getFrequencyAt(mpos, centerFreq, bw);
                        centerFreq += mfreqA - mfreqB;
                        setBandwidth(bw);
                    } else {
                        setBandwidth(bw);
                    }
                }
            }
        }
        if (centerFreq < freq && (centerFreq - bandwidth / 2) < (freq - wxGetApp().getSampleRate() / 2)) {
            centerFreq = (freq - wxGetApp().getSampleRate() / 2) + bandwidth / 2;
        }
        if (centerFreq > freq && (centerFreq + bandwidth / 2) > (freq + wxGetApp().getSampleRate() / 2)) {
            centerFreq = (freq + wxGetApp().getSampleRate() / 2) - bandwidth / 2;
        }

        if (spectrumCanvas) {
            if ((spectrumCanvas->getCenterFrequency() != centerFreq) || (spectrumCanvas->getBandwidth() != bw)) {
                if (getViewState()) {
                    spectrumCanvas->setView(centerFreq,bw);
                } else {
                    spectrumCanvas->disableView();
                    spectrumCanvas->setCenterFrequency(centerFreq);
                    spectrumCanvas->setBandwidth(bw);
                }
            }
        }
    }
    

    glContext->SetCurrent(*this);
    initGLExtensions();
    glViewport(0, 0, ClientSize.x, ClientSize.y);
    
    if (fft_size_changed.load()) {
        fft_size = new_fft_size;
        waterfallPanel.setup(fft_size, waterfall_lines);
        fft_size_changed.store(false);
    }

    glContext->BeginDraw(0,0,0);

    waterfallPanel.calcTransform(CubicVR::mat4::identity());
    waterfallPanel.draw();

    std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators();

    DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
    DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();

    bool isNew = shiftDown
            || (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive());

    int currentBandwidth = getBandwidth();
    long long currentCenterFreq = getCenterFrequency();

    ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme;
    std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();

    if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) {
        hoverAlpha += (1.0f-hoverAlpha)*0.1f;
        if (hoverAlpha > 1.5f) {
            hoverAlpha = 1.5f;
        }
        glContext->setHoverAlpha(hoverAlpha);
        if (nextDragState == WF_DRAG_RANGE) {
            float width = (1.0 / (float) ClientSize.x);
            float rangeWidth = mouseTracker.getOriginDeltaMouseX();
            float centerPos;

            if (mouseTracker.mouseDown()) {
                if (rangeWidth) {
                    width = rangeWidth;
                }
                centerPos = mouseTracker.getOriginMouseX() + width / 2.0;
            } else {
                centerPos = mouseTracker.getMouseX();
            }

            glContext->DrawDemod(lastActiveDemodulator, isNew?currentTheme->waterfallHighlight:currentTheme->waterfallDestroy, currentCenterFreq, currentBandwidth);

            if ((last_type == "LSB" || last_type == "USB") && mouseTracker.mouseDown()) {
                centerPos = mouseTracker.getMouseX();
                glContext->DrawRangeSelector(centerPos, centerPos-width, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover);
            } else {
                glContext->DrawFreqSelector(centerPos, isNew?currentTheme->waterfallNew:currentTheme->waterfallHover, width, currentCenterFreq, currentBandwidth);
            }
        } else {
            if (lastActiveDemodulator) {
                glContext->DrawDemod(lastActiveDemodulator, ((isNew && activeDemodulator == NULL) || (activeDemodulator != NULL))?currentTheme->waterfallHighlight:currentTheme->waterfallDestroy, currentCenterFreq, currentBandwidth);
            }
            if (activeDemodulator == NULL) {
                glContext->DrawFreqSelector(mouseTracker.getMouseX(), ((isNew && lastActiveDemodulator) || (!lastActiveDemodulator) )?currentTheme->waterfallNew:currentTheme->waterfallHover, 0, currentCenterFreq, currentBandwidth);
            } else {
                glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHover, currentCenterFreq, currentBandwidth);
            }
        }
    } else {
        hoverAlpha += (0.0f-hoverAlpha)*0.05f;
        if (hoverAlpha < 1.0e-5f) {
            hoverAlpha = 0;
        }
        glContext->setHoverAlpha(hoverAlpha);
        if (activeDemodulator) {
            glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
        }
        if (lastActiveDemodulator) {
            glContext->DrawDemod(lastActiveDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
        }
    }

    glContext->setHoverAlpha(0);

    for (int i = 0, iMax = demods.size(); i < iMax; i++) {
        if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) {
            continue;
        }
        glContext->DrawDemod(demods[i], currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
    }

    glContext->EndDraw();

    SwapBuffers();
    tex_update.unlock();
}
コード例 #13
0
ファイル: Stats.cpp プロジェクト: mtdxc/licode
  void Stats::processRtcpPacket(RtcpHeader* chead) {
    unsigned int ssrc = chead->getSSRC();

    ELOG_DEBUG("RTCP SubPacket: PT %d, SSRC %u,  block count %d ",
               chead->packettype, chead->getSSRC(), chead->getBlockCount());
    switch (chead->packettype) {
      case RTCP_SDES_PT:
        ELOG_DEBUG("SDES");
        break;
      case RTCP_BYE:
        ELOG_DEBUG("RTCP BYE");
        break;
      case RTCP_Receiver_PT:
        setFractionLost(chead->getFractionLost(), ssrc);
        setPacketsLost(chead->getLostPackets(), ssrc);
        setJitter(chead->getJitter(), ssrc);
        setSourceSSRC(chead->getSourceSSRC(), ssrc);
        break;
      case RTCP_Sender_PT:
        setRtcpPacketSent(chead->getPacketsSent(), ssrc);
        setRtcpBytesSent(chead->getOctetsSent(), ssrc);
        break;
      case RTCP_RTP_Feedback_PT:
        ELOG_DEBUG("RTP FB: Usually NACKs: %u", chead->getBlockCount());
        ELOG_DEBUG("PID %u BLP %u", chead->getNackPid(), chead->getNackBlp());
        accountNACKMessage(ssrc);
        break;
      case RTCP_PS_Feedback_PT:
        ELOG_DEBUG("RTCP PS FB TYPE: %u", chead->getBlockCount() );
        switch (chead->getBlockCount()) {
          case RTCP_PLI_FMT:
            ELOG_DEBUG("PLI Message");
            accountPLIMessage(ssrc);
            break;
          case RTCP_SLI_FMT:
            ELOG_DEBUG("SLI Message");
            accountSLIMessage(ssrc);
            break;
          case RTCP_FIR_FMT:
            ELOG_DEBUG("FIR Message");
            accountFIRMessage(ssrc);
            break;
          case RTCP_AFB:
            {
              char *uniqueId = reinterpret_cast<char*>(&chead->report.rembPacket.uniqueid);
              if (!strncmp(uniqueId, "REMB", 4)) {
                uint64_t bitrate = chead->getBrMantis() << chead->getBrExp();
                // ELOG_DEBUG("REMB Packet numSSRC %u mantissa %u exp %u, tot %lu bps",
                //             chead->getREMBNumSSRC(), chead->getBrMantis(), chead->getBrExp(), bitrate);
                setBandwidth(bitrate, ssrc);
              } else {
                ELOG_DEBUG("Unsupported AFB Packet not REMB")
              }
              break;
            }
          default:
            ELOG_WARN("Unsupported RTCP_PS FB TYPE %u", chead->getBlockCount());
            break;
        }
        break;
      default:
        ELOG_DEBUG("Unknown RTCP Packet, %d", chead->packettype);
        break;
    }
  }
コード例 #14
0
ファイル: Gaussian.cpp プロジェクト: Re-bort/NNDK
Gaussian::Gaussian(const double& bandwidth)
{
    setBandwidth(bandwidth);
}   
コード例 #15
0
ファイル: BMA150.cpp プロジェクト: shettyprabodh/Mr.Haha
/** Power on and prepare for general usage. This sets the full scale range of 
 * the sensor, as well as the bandwidth
 */
void BMA150::initialize() {
	setRange(BMA150_RANGE_2G);
	setBandwidth(BMA150_BW_25HZ);
}