vumonitor/vumonitor.cc
/// Peek into the stream to get a pointer to floats.  Retain the peak
/// amplitude in the sample.  For multichannel data, this is
/// structured as a sequence of samples for each channel, e.g. for 2
/// channels: L0,R0, L1,R1, L2,R2, L3,R3, ... but we don't really care
/// about this for detecting silence.
///
Peek into the stream to get a pointer to floats.  Retain the peak
amplitude in the sample.  For multichannel data, this is
structured as a sequence of samples for each channel, e.g.
Peek into the stream to get a pointer to floats . Retain the peak amplitude in the sample . For multichannel data this is structured as a sequence of samples for each channel e . g .
void
VU_monitor::read_sample(pa_stream *pstream, size_t len)
{
    const void *pvoid {nullptr};
    if (len > m_max_samples) { m_max_samples = len; }  
    if (len) { m_accum_samples += len; }
    if (pa_stream_peek( pstream, &pvoid, &len ) < 0) {
        LOG_ERROR(Lgr) << "pa_stream_peek() failed: "
                  <<  pa_strerror(pa_context_errno(m_context));
        return;
    }
    const float *d = static_cast<const float*>( pvoid );
    unsigned nsamples = static_cast<unsigned>((len/sizeof(float)));
    while (nsamples) {
        float v = fabs(*d);
        if (v > m_level) m_level = v; 
        --nsamples;
        ++d;
    }
    pa_stream_drop( pstream );
}
void VU_monitor :: read_sample ( pa_stream * pstream , size_t len ) { const void * pvoid { nullptr } ; if ( len > m_max_samples ) { m_max_samples = len ; } if ( len ) { m_accum_samples += len ; } if ( pa_stream_peek ( pstream , & pvoid , & len ) < 0 ) { LOG_ERROR ( Lgr ) << " " << pa_strerror ( pa_context_errno ( m_context ) ) ; return ; } const float * d = static_cast < const float * > ( pvoid ) ; unsigned nsamples = static_cast < unsigned > ( ( len / sizeof ( float ) ) ) ; while ( nsamples ) { float v = fabs ( * d ) ; if ( v > m_level ) m_level = v ; -- nsamples ; ++ d ; } pa_stream_drop ( pstream ) ; }
Peek into the stream to get a pointer to floats.
Peek into the stream to get a pointer to floats .
// debug // retain peak