Data Processor

Data processors are functions in the firmware that filter or transform sensor data and are represented by the MblMwDataProcessor struct. In the C++ API, data processors can be thought of as a data signal whose data is produced by the on-board data processor. As such, a MblMwDataProcessor can be safely typecasted to a MblMwDataSignal.

This section will focus on the MblMwDataProcessor struct. Details on supported processors and how to create them are covered in the Data Processor Types section.


Data processors are identified by a unique numerical ID; you can retrieve this id by calling mbl_mw_dataprocessor_get_id. The data processor ID is used to lookup a previously created MblMwDataProcessor object with the mbl_mw_dataprocessor_lookup_id function.


Some processors have an internal state that can be read and modified; the internal state is treated as a readable MblMwDataSignal.

#include "metawear/core/datasignal.h"
#include "metawear/processor/dataprocessor.h"

// Assume input processor is a Buffer processor
void subscribe_state_signal(MblMwDataProcessor* buffer_processor) {
    auto state_signal = mbl_mw_dataprocessor_get_state_data_signal(buffer_processor);
    mbl_mw_datasignal_subscribe(state_signal, data_printer);


Removing a processor is handled by calling mbl_mw_dataprocessor_remove. When a processor is removed, all processors that consume its output will also be removed.

#include "metawear/core/datasignal_fwd.h"
#include "metawear/processor/dataprocessor.h"
#include "metawear/processor/math.h"

void remove_processors(MblMwDataSignal* temp_signal) {
    static MblMwDataProcessor* first_processor= nullptr;

    static auto add_32_created = [](MblMwDataProcessor* processor) -> void {
        // Removes all 3 processors in the chain
    static auto div_10_created = [](MblMwDataProcessor* processor) -> void {
        mbl_mw_dataprocessor_math_create((MblMwDataSignal*) processor, MBL_MW_MATH_OP_ADD, 32.f,
    static auto mul_18_created = [](MblMwDataProcessor* processor) -> void {
        first_processor = processor;
        mbl_mw_dataprocessor_math_create((MblMwDataSignal*) processor, MBL_MW_MATH_OP_DIVIDE,
                10.f, div_10_created);
    mbl_mw_dataprocessor_math_create(temp_signal, MBL_MW_MATH_OP_MULTIPLY, 18.f, mul_18_created);