PipeWire 1.4.8

Loading...
Searching...
No Matches
spa_io_rate_match Struct Reference
SPA » Node

Rate matching. More...

`#include <spa/node/io.h>`

## Data Fields
uint32_t | delay
| resampling delay, in samples at node rate
uint32_t | size
| requested input size for resampler
double | rate
| rate for resampler (set by node)
uint32_t | flags
| extra flags (set by node)
int32_t | delay_frac
| resampling delay fractional part, in units of nanosamples (1/10^9 sample) at node rate
uint32_t | padding [6]

## Detailed Description

Rate matching.

It is usually set on the nodes that process resampled data, by the component (audioadapter) that handles resampling between graph and node rates. The flags and rate fields may be modified by the node.

The node can request a correction to the resampling rate in its process(), by setting SPA_IO_RATE_MATCH_ACTIVE on flags, and setting rate to the desired rate correction. Usually the rate is obtained from DLL or other adaptive mechanism that e.g. drives the node buffer fill level toward a specific value.

When resampling to (graph->node) direction, the number of samples produced by the resampler varies on each cycle, as the rates are not commensurate.

When resampling to (node->graph) direction, the number of samples consumed by the resampler varies. Node output ports in process() should produce size number of samples to match what the resampler needs to produce one graph quantum of output samples.

Resampling filters introduce processing delay, given by delay and delay_frac, in samples at node rate. The delay varies on each cycle e.g. when resampling between noncommensurate rates.

The first sample output (graph->node) or consumed (node->graph) by the resampler is offset by delay + delay_frac / 1e9 node samples relative to the nominal graph cycle start position:

first_resampled_sample_nsec =
first_original_sample_nsec
- (rate_match->delay * SPA_NSEC_PER_SEC + rate_match->delay_frac) / node_rate

## Field Documentation

## ◆ delay

uint32_t spa_io_rate_match::delay

resampling delay, in samples at node rate

## ◆ size

uint32_t spa_io_rate_match::size

requested input size for resampler

## ◆ rate

double spa_io_rate_match::rate

rate for resampler (set by node)

## ◆ flags

uint32_t spa_io_rate_match::flags

extra flags (set by node)

## ◆ delay_frac

int32_t spa_io_rate_match::delay_frac

resampling delay fractional part, in units of nanosamples (1/10^9 sample) at node rate

## ◆ padding

uint32_t spa_io_rate_match::padding[6]

The documentation for this struct was generated from the following file:

- spa/node/io.h