class Sampler

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

Interface that takes an array of source samples in any format, and processes corresponding array

of destination samples in normalized 32-bit float format with a specified gain scale applied.

The source and destination samples can be in different frame rates, channel configurations or

sample formats. The samples that are processed from the source format will be converted into the

destination format accordingly during `Process` call with respect to the derived implementation.

Each `Process` call assumes a contiguous stream of source and destination samples. The caller

must ensure that the requested source and destination samples are aligned with respect to their

audio format and timeline.

Each sampler define their positive and negative lengths of the filter that are expressed in

fixed-point fractional source subframe units. These lengths convey which source frames will be

referenced by the filter, when producing corresponding destination frames for a specific instant

in time.

Positive filter length refers to how far forward (positively) the filter looks, from the PTS in

question; while negative filter length refers to how far backward (negatively) the filter looks,

from that same PTS. The center frame position is included in the length. For example, a pure

"sample and hold" sampler might have a positive filter length of `Fixed::FromRaw(1)` and a

negative filter length of `kOneFrame`:

center

VV

***************

^ ^^

+---++

n p

This class is not safe for concurrent use.

Public Methods

void ~Sampler ()

Default destructor.

Defined at line 259 of file ../../src/media/audio/lib/processing/sampler.h

std::shared_ptr<Sampler> Create (const Format & source_format, const Format & dest_format, Type type)

Creates an appropriate `Sampler` for a given `source_format` and `dest_format`. If a sampler

`type` is specified explicitly (i.e. `type != Type::kDefault`), this will either return a

`Sampler` of that requested `type`, or `nullptr` if a `Sampler` with that `type` cannot be

created with the given configuration.

Defined at line 296 of file ../../src/media/audio/lib/processing/sampler.cc

void EagerlyPrepare ()

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

first call to `Process`.

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

creation is eager.

void Process (Source source, Dest dest, Gain gain, bool accumulate)

Processes `source` into `dest` with `gain`.

Fixed pos_filter_length ()

Returns positive filter length in frames.

Defined at line 271 of file ../../src/media/audio/lib/processing/sampler.h

Fixed neg_filter_length ()

Returns negative filter length in frames.

Defined at line 274 of file ../../src/media/audio/lib/processing/sampler.h

const State & state ()

Returns state.

Defined at line 277 of file ../../src/media/audio/lib/processing/sampler.h

State & state ()

Defined at line 278 of file ../../src/media/audio/lib/processing/sampler.h

Protected Methods

void Sampler (Fixed pos_filter_length, Fixed neg_filter_length)

Defined at line 281 of file ../../src/media/audio/lib/processing/sampler.h

int64_t Ceiling (int64_t frac_position)

Ceils `frac_position` in frames.

Defined at line 285 of file ../../src/media/audio/lib/processing/sampler.h

int64_t Floor (int64_t frac_position)

Floors `frac_position` in frames.

Defined at line 290 of file ../../src/media/audio/lib/processing/sampler.h

Enumerations

enum Type
Name Value
kDefault 0
kSincSampler 1

Sampler type.

Defined at line 246 of file ../../src/media/audio/lib/processing/sampler.h

Records