Class: Toybox.Math.Filter

Inherits:
Toybox.Lang.Object show all

Overview

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.

See Also:

Note:

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

Example:

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;
    }

Since:

API Level 2.3.0

Direct Known Subclasses

Math.FirFilter, Math.IirFilter

Instance Method Summary collapse

Instance Method Details

apply(data as Lang.Array<Lang.Numeric>) as Lang.Array<Lang.Float>

Apply the Filter to an Array of samples.

Note:

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

Parameters:

  • data

    Array of samples to apply filter

Returns:

  • Array of samples with filter applied.

Since:

API Level 2.3.0

Throws:

initialize(dictionary as Lang.Dictionary)

Constructor

Parameters:

  • dictionary(Lang.Dictionary)

    Unused. Preserves argument count for compatibility

Since:

API Level 2.3.0


Generated Apr 17, 2024 9:40:37 AM