Class: Toybox::Math::Filter

Inherits:
Lang::Object show all

Overview

Note:

An exception will be thrown if the base Filter class version of this method is called.

This is the base class for filters.

Filters are devices or processes that remove some unwanted components or features from a signal or set of data. More detailed examples of filters can be found in the FirFilter and IirFilter definitions.

Examples:

This shows how a filter's method can be used on a set of data

using Toybox.Math;
    var exampleFilter;
    var interestingCoefficients;
    var importantGain;
    var messyData;
    var filteredData;

    // Constructor
    function initialize() {

    // initialize filter
    var options = {:coefficients => [interestingCoefficients],
                   :gain => importantGain};
    try {
        exampleFilter = new Math.FirFilter(options);
    }
    catch(e) {
        System.println(e.getErrorMessage());
    }
    }

    // apply filter
    function exampleApplyFilter(messyData) {
        filteredData = exampleFilter.apply(messyData);

        return filteredData;
    }

See Also:

Since:

  • 2.3.0

Direct Known Subclasses

FirFilter, IirFilter

Direct Known Subclasses

FirFilter, IirFilter

Instance Method Summary collapse

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(dictionary) ⇒ Filter

Initialize the filter.

Parameters:

Raises:

Since:

  • 2.3.0


6776
6777
# File 'Monkeybrains.rb', line 6776

def initialize(dictionary)
end

Instance Method Details

apply(data) ⇒ Object

Note:

An Exception will be thrown if the base Filter class version of this method is called.

Apply the Filter to an Array of samples.

Parameters:

  • data

    Array of samples to apply filter

Returns:

  • Array of samples with filter applied.

Raises:

Since:

  • 2.3.0


6786
6787
# File 'Monkeybrains.rb', line 6786

def apply(data)
end