Ejemplo n.º 1
0
void EngineVuMeter::process(const CSAMPLE* pIn, CSAMPLE*, const int iBufferSize) {
    CSAMPLE fVolSumL, fVolSumR;
    SampleUtil::sumAbsPerChannel(&fVolSumL, &fVolSumR, pIn, iBufferSize);
    m_fRMSvolumeSumL += fVolSumL;
    m_fRMSvolumeSumR += fVolSumR;

    m_iSamplesCalculated += iBufferSize/2;

    // Are we ready to update the VU meter?:
    if (m_iSamplesCalculated > (44100/2/UPDATE_RATE)) {
        doSmooth(m_fRMSvolumeL, log10(SHRT_MAX * m_fRMSvolumeSumL/(m_iSamplesCalculated*1000)+1));
        doSmooth(m_fRMSvolumeR, log10(SHRT_MAX * m_fRMSvolumeSumR/(m_iSamplesCalculated*1000)+1));

        const double epsilon = .0001;

        // Since VU meters are a rolling sum of audio, the no-op checks in
        // ControlObject will not prevent us from causing tons of extra
        // work. Because of this, we use an epsilon here to be gentle on the GUI
        // and MIDI controllers.
        if (fabs(m_fRMSvolumeL - m_ctrlVuMeterL->get()) > epsilon)
            m_ctrlVuMeterL->set(m_fRMSvolumeL);
        if (fabs(m_fRMSvolumeR - m_ctrlVuMeterR->get()) > epsilon)
            m_ctrlVuMeterR->set(m_fRMSvolumeR);

        double fRMSvolume = (m_fRMSvolumeL + m_fRMSvolumeR) / 2.0;
        if (fabs(fRMSvolume - m_ctrlVuMeter->get()) > epsilon)
            m_ctrlVuMeter->set(fRMSvolume);

        // Reset calculation:
        m_iSamplesCalculated = 0;
        m_fRMSvolumeSumL = 0;
        m_fRMSvolumeSumR = 0;
    }
}
Ejemplo n.º 2
0
void EngineVuMeter::process(CSAMPLE* pIn, const int iBufferSize) {
    CSAMPLE fVolSumL, fVolSumR;

    int sampleRate = (int)m_pSampleRate->get();

    bool clipped = SampleUtil::sumAbsPerChannel(&fVolSumL, &fVolSumR, pIn, iBufferSize);
    m_fRMSvolumeSumL += fVolSumL;
    m_fRMSvolumeSumR += fVolSumR;

    m_iSamplesCalculated += iBufferSize/2;

    // Are we ready to update the VU meter?:
    if (m_iSamplesCalculated > (sampleRate/VU_UPDATE_RATE)) {
        doSmooth(m_fRMSvolumeL, log10(SHRT_MAX * m_fRMSvolumeSumL/(m_iSamplesCalculated*1000)+1));
        doSmooth(m_fRMSvolumeR, log10(SHRT_MAX * m_fRMSvolumeSumR/(m_iSamplesCalculated*1000)+1));

        const double epsilon = .0001;

        // Since VU meters are a rolling sum of audio, the no-op checks in
        // ControlObject will not prevent us from causing tons of extra
        // work. Because of this, we use an epsilon here to be gentle on the GUI
        // and MIDI controllers.
        if (fabs(m_fRMSvolumeL - m_ctrlVuMeterL->get()) > epsilon)
            m_ctrlVuMeterL->set(m_fRMSvolumeL);
        if (fabs(m_fRMSvolumeR - m_ctrlVuMeterR->get()) > epsilon)
            m_ctrlVuMeterR->set(m_fRMSvolumeR);

        double fRMSvolume = (m_fRMSvolumeL + m_fRMSvolumeR) / 2.0;
        if (fabs(fRMSvolume - m_ctrlVuMeter->get()) > epsilon)
            m_ctrlVuMeter->set(fRMSvolume);

        // Reset calculation:
        m_iSamplesCalculated = 0;
        m_fRMSvolumeSumL = 0;
        m_fRMSvolumeSumR = 0;
    }

    if (clipped) {
        m_ctrlPeakIndicator->set(1.);
        m_peakDuration = PEAK_DURATION * sampleRate / iBufferSize / 2000;
    } else if (m_peakDuration <= 0) {
        m_ctrlPeakIndicator->set(0.);
    } else {
        --m_peakDuration;
    }
}
Ejemplo n.º 3
0
IplImage *DehazeBase::doDehaze(const IplImage *src)
{
	int airlight;
	double *TranMap  = new double[src->height * src->width];

	m_Result = cvCreateImage( cvGetSize(src), src->depth, src->nChannels );
	m_DarkestImage = cvCreateImage( cvGetSize(src), src->depth, 1 );
	m_TranMapImage = cvCreateImage( cvGetSize(src), src->depth, 1 );
	m_SmoothImage  = cvCreateImage( cvGetSize(src), src->depth, 1 );
	m_BilaFilImage = cvCreateImage( cvGetSize(src), src->depth, 1 );
	m_DarkBilImage = cvCreateImage( cvGetSize(src), src->depth, 1 );

	// The input is m_DarkestImage
	generateDarkestImage(src);
	// The input is m_DarkestImage
	airlight = generateAirligth();

	// The output is in m_SmoothImage and the input is m_DarkestImage
	doSmooth();

	// The input is m_DarkestImage
	preDoEnhance(m_DarkBilImage);
	// The input is m_SmoothImage and the output is in m_BilaFilImage
	doEnhance(m_DarkBilImage);
	// doEnhance(m_DarkestImage);

	// The input is m_BilaFilImage
	generateTranMap(airlight, TranMap);
	// The output is in m_TranMapImage
	generateTranImage(TranMap);

	// The output is in m_Result
	doDehaze(src, TranMap, airlight);
	
	delete TranMap;
	return m_Result;
}