class Filter

Defined at line 20 of file ../../src/media/audio/lib/processing/filter.h

This class represents a symmetric, convolution-based filter, to be applied to an audio stream.

Public Methods

float ComputeSample (int64_t frac_offset, float * center)

Computes sample at `center` frame with `frac_offset`.

void Display ()

Displays the filter table values. Used for debugging purposes only.

void EagerlyPrepare ()

Eagerly precomputes needed data. If not called, needed data will be lazily computed on the

first `ComputeSample` call.

TODO(https://fxbug.dev/42121558): This is for tests only and can be removed once filter

creation is eager.

void Filter (int32_t source_rate, int32_t dest_rate, int64_t side_length, int32_t num_frac_bits)

`side_length` is the number of subframes included on each side, including center subframe 0.

Defined at line 23 of file ../../src/media/audio/lib/processing/filter.h

int32_t source_rate ()

Defined at line 49 of file ../../src/media/audio/lib/processing/filter.h

int32_t dest_rate ()

Defined at line 50 of file ../../src/media/audio/lib/processing/filter.h

int64_t side_length ()

Defined at line 51 of file ../../src/media/audio/lib/processing/filter.h

int32_t num_frac_bits ()

Defined at line 52 of file ../../src/media/audio/lib/processing/filter.h

int64_t frac_size ()

Defined at line 53 of file ../../src/media/audio/lib/processing/filter.h

double rate_conversion_ratio ()

Defined at line 54 of file ../../src/media/audio/lib/processing/filter.h

Protected Methods

float ComputeSampleFromTable (const CoefficientTable & filter_coefficients, int64_t frac_offset, float * center)

For `frac_offset` in [0.0, 1.0) we require source frames on each side depending on filter length.

Source frames are at integral positions, but we treat `frac_offset` as filter center, so source

frames appear to be fractionally positioned.

Filter coefficients cover the entire discrete space of fractional positions, but any calculation

references only a subset of these, using a one-frame stride (`frac_size_`). Coefficient tables

internally store values with an integer stride contiguously, which is what these loops want.

Ex:

coefficient_ptr[1] == filter_coefficients[frac_offset + frac_size_];

We first calculate the contribution of the negative side of the filter, and then the contribution

of the positive side. To avoid double-counting it, we include center subframe 0 only in the

negative-side calculation.

Defined at line 66 of file ../../src/media/audio/lib/processing/filter.cc

void DisplayTable (const CoefficientTable & filter_coefficients)

Defined at line 22 of file ../../src/media/audio/lib/processing/filter.cc