Skip to main content

RtNoise

Namespace: RTPROCESSINGLIB  ·  Library: DSP Library

#include <dsp/rt_noise.h>

class RTPROCESSINGLIB::RtNoise

Controller that manages RtNoiseWorker for real-time noise spectrum estimation.

src/examples/ex_dsp_rt/main.cpp
RtNoiseWorker noiseWorker(64, info200, 10); // 64-point FFT over 10 accumulated blocks
MatrixXd spectrum;
QObject::connect(&noiseWorker, &RtNoiseWorker::resultReady, [&](const MatrixXd& psd) { spectrum = psd; });
for (int b = 0; b < 10; ++b) {
noiseWorker.doWork(tones.middleCols(64 * b, 64)); // dB re unit^2/Hz, channels x (fft/2 + 1)
}

Inheritance​


Public Methods​

RtNoise(iFftLength, pFiffInfo, iDataLength, parent)​

Creates the real-time noise estimation object.

Parameters:

  • iFftLength : qint32 Number of samples per FFT window.

  • pFiffInfo : FIFFLIB::FiffInfo::SPtr Associated Fiff Information.

  • iDataLength : qint32 Number of blocks to accumulate before computing.

  • parent : *QObject ** Parent QObject (optional).


~RtNoise()​

Destroys the real-time noise estimation object.


append(matData)​

Submit incoming data for noise estimation.

Parameters:

  • matData : const Eigen::MatrixXd & Data block (channels x samples).

isRunning()​

Returns whether the worker thread is running.

Returns:

  • bool — True between start() and stop(), false otherwise.

start()​

Starts the worker thread.

Returns:

  • bool — true on success.

stop()​

Stops the worker thread.

Returns:

  • bool — true on success.

wait(time)​

Blocks until the worker thread has finished, or until the timeout (ms) expires.

Parameters:

  • time : unsigned long Timeout in ms; ULONG_MAX waits indefinitely.

Returns:

  • bool — True if the thread finished, false if the timeout expired.

Example​

Used in examples​

ex_dsp_rt​

DSP real-time workers: averaging, covariance, noise spectrum, connectivity, HPI fitting and inverse operators.

src/examples/ex_dsp_rt/main.cpp, line 228
RtNoise rtNoise(64, info200, 10);
bool noiseDone = false;
QObject::connect(&rtNoise, &RtNoise::SpecCalculated, [&](const MatrixXd& psd) { noiseDone = psd.topRows(2).isApprox(spectrum.topRows(2)); }); // the empty stim row is -inf dB
rtNoise.start();
for (int b = 0; b < 10; ++b) {
rtNoise.append(tones.middleCols(64 * b, 64));
}
ok &= expect(waitFor(noiseDone, 5000), "RtNoise emits the same spectrum from its worker thread");
rtNoise.stop();
rtNoise.wait(2000);

Authors of this file​