Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio Namespace Reference

Audio frames and audio processing. More...

Classes

class  BuiltinResampler
 Built-in resampler. More...
 
class  ChannelMapper
 Channel mapper. More...
 
class  ChannelMapperMatrix
 Channel mapping matrix. More...
 
class  ChannelMapperReader
 Channel mapper reader. Reads frames from nested reader and maps them to another channel mask. More...
 
class  ChannelMapperWriter
 Channel mapper writer. Reads frames from nested writer and maps them to another channel mask. More...
 
class  ChannelSet
 Channel set. Multi-word bitmask with bits corresponding to enabled channels. Meaning of each channel is defined by ChannelLayout. Order of serialized channels is defined by ChannelOrder. More...
 
class  channel_set_to_str
 Format ChannelSet to string. More...
 
struct  ChannelPositionName
 Defines string name for channel position. More...
 
struct  ChannelMaskName
 Defines string name for pre-defined channel mask. More...
 
struct  ChannelMapRule
 Defines multiplication coefficient for a pair of channels. More...
 
struct  ChannelMapTable
 Defines multiplication matrix for two channel masks. More...
 
struct  ChannelOrderTable
 Defines ordered list of channels. More...
 
class  DecimationResampler
 Decimating resampler. More...
 
class  Depacketizer
 Depacketizer. More...
 
class  Fanout
 Fanout. Duplicates audio stream to multiple output writers. More...
 
struct  FeedbackConfig
 Feedback monitor configuration. More...
 
class  FeedbackMonitor
 Feedback monitor. More...
 
class  Frame
 Audio frame. More...
 
class  FrameFactory
 Frame factory. More...
 
struct  FreqEstimatorConfig
 FreqEstimator tunable parameters. More...
 
class  FreqEstimator
 Evaluates sender's frequency to receivers's frequency ratio. More...
 
class  IFrameDecoder
 Audio frame decoder interface. More...
 
class  IFrameEncoder
 Audio frame encoder interface. More...
 
class  IFrameReader
 Frame reader interface. More...
 
class  IFrameWriter
 Frame writer interface. More...
 
class  IResampler
 Audio writer interface. More...
 
class  LatencyMonitor
 Latency monitor. More...
 
struct  LatencyConfig
 Latency settings. More...
 
struct  LatencyMetrics
 Latency-related metrics. More...
 
class  LatencyTuner
 Latency tuner. More...
 
class  Mixer
 Mixer. Mixes multiple input streams into one output stream. More...
 
class  NullWriter
 Null writer. More...
 
struct  PacketizerMetrics
 Metrics of packetizer. More...
 
class  Packetizer
 Packetizer. More...
 
class  PcmDecoder
 PCM decoder. More...
 
class  PcmEncoder
 PCM encoder. More...
 
struct  PcmTraits
 PCM format meta-information. More...
 
class  PcmMapper
 PCM format mapper. Convert between PCM formats. More...
 
class  PcmMapperReader
 Pcm mapper reader. Reads frames from nested reader and maps them to another pcm mask. More...
 
class  PcmMapperWriter
 Pcm mapper writer. Reads frames from nested writer and maps them to another pcm mask. More...
 
struct  ProfilerConfig
 Profiler Configuration Parameters. Controls profiling interval and duration of each circular buffer chunk. More...
 
class  Profiler
 Profiler The role of the profiler is to report the average processing speed (# of samples processed per time unit) during the last N seconds. We want to calculate the average processing speed efficiently (with O(1) complexity, without allocations, and as lightweight as possible). The problems with this are that we have variable-sized frames and SMA requires fixed-size chunks. To efficiently perform this calculation a ring buffer is employed. The idea behind the ring buffer is that each chunk of the buffer is the average speed of 10ms worth of samples. The ring buffer is initialized with fixed size (N * 1000)ms / (10ms) chunks. Within each chunk a weighted mean is used to calculate the average speed during those 10ms. Each frame will contribute a different number of samples to each chunk, the chunk speed is then weighted based on how many samples are contributed at what frame speed. As the chunks get populated the moving average is calculated. When the buffer is not entirely full the cumulative moving average algorithm is used and once the buffer is full the simple moving average algorithm is used. More...
 
class  ProfilingReader
 Profiling reader. More...
 
class  ProfilingWriter
 Profiling writer. More...
 
struct  ResamplerConfig
 Resampler config. More...
 
class  ResamplerMap
 Factory class for IResampler objects, according to the ResamplerBackend input. More...
 
class  ResamplerReader
 Resampler element for reading pipeline. More...
 
class  ResamplerWriter
 Resampler element for writing pipeline. More...
 
class  SampleSpec
 Sample specification. Describes sample rate and channels. More...
 
class  sample_spec_to_str
 Format SampleSpec to string. More...
 
class  SpeexResampler
 Speex resampler. More...
 
struct  WatchdogConfig
 Watchdog parameters. More...
 
class  Watchdog
 Watchdog. More...
 

Typedefs

typedef uint32_t ChannelMask
 Channel mask. More...
 
typedef void(* PcmMapFn) (const uint8_t *in_data, size_t &in_bit_off, uint8_t *out_data, size_t &out_bit_off, size_t n_samples)
 PCM mapping function. More...
 
typedef float sample_t
 Raw audio sample. More...
 

Enumerations

enum  ChannelLayout { ChanLayout_None , ChanLayout_Surround , ChanLayout_Multitrack }
 Channel layout. Defines meaning of channels in ChannelSet. ChannelMapper uses channel layout to decide how to perform mapping. More...
 
enum  ChannelOrder { ChanOrder_None , ChanOrder_Smpte , ChanOrder_Alsa , ChanOrder_Max }
 Surround channel order. More...
 
enum  ChannelPosition {
  ChanPos_FrontLeft , ChanPos_FrontLeftOfCenter , ChanPos_FrontCenter , ChanPos_FrontRightOfCenter ,
  ChanPos_FrontRight , ChanPos_SideLeft , ChanPos_SideRight , ChanPos_BackLeft ,
  ChanPos_BackCenter , ChanPos_BackRight , ChanPos_TopFrontLeft , ChanPos_TopFrontRight ,
  ChanPos_TopMidLeft , ChanPos_TopMidRight , ChanPos_TopBackLeft , ChanPos_TopBackRight ,
  ChanPos_LowFrequency , ChanPos_Max
}
 Surround channel position. More...
 
enum  FreqEstimatorProfile { FreqEstimatorProfile_Responsive , FreqEstimatorProfile_Gradual }
 FreqEstimator paremeter preset. More...
 
enum  LatencyTunerBackend { LatencyTunerBackend_Default , LatencyTunerBackend_Niq , LatencyTunerBackend_E2e }
 Latency tuner backend. Defines which latency we monitor and tune to achieve target. More...
 
enum  LatencyTunerProfile { LatencyTunerProfile_Default , LatencyTunerProfile_Intact , LatencyTunerProfile_Responsive , LatencyTunerProfile_Gradual }
 Latency tuner profile. Defines whether and how we tune latency on fly to compensate clock drift and jitter. More...
 
enum  PcmFormat {
  PcmFormat_Invalid , PcmFormat_SInt8 , PcmFormat_SInt8_Be , PcmFormat_SInt8_Le ,
  PcmFormat_UInt8 , PcmFormat_UInt8_Be , PcmFormat_UInt8_Le , PcmFormat_SInt16 ,
  PcmFormat_SInt16_Be , PcmFormat_SInt16_Le , PcmFormat_UInt16 , PcmFormat_UInt16_Be ,
  PcmFormat_UInt16_Le , PcmFormat_SInt18 , PcmFormat_SInt18_Be , PcmFormat_SInt18_Le ,
  PcmFormat_UInt18 , PcmFormat_UInt18_Be , PcmFormat_UInt18_Le , PcmFormat_SInt18_3 ,
  PcmFormat_SInt18_3_Be , PcmFormat_SInt18_3_Le , PcmFormat_UInt18_3 , PcmFormat_UInt18_3_Be ,
  PcmFormat_UInt18_3_Le , PcmFormat_SInt18_4 , PcmFormat_SInt18_4_Be , PcmFormat_SInt18_4_Le ,
  PcmFormat_UInt18_4 , PcmFormat_UInt18_4_Be , PcmFormat_UInt18_4_Le , PcmFormat_SInt20 ,
  PcmFormat_SInt20_Be , PcmFormat_SInt20_Le , PcmFormat_UInt20 , PcmFormat_UInt20_Be ,
  PcmFormat_UInt20_Le , PcmFormat_SInt20_3 , PcmFormat_SInt20_3_Be , PcmFormat_SInt20_3_Le ,
  PcmFormat_UInt20_3 , PcmFormat_UInt20_3_Be , PcmFormat_UInt20_3_Le , PcmFormat_SInt20_4 ,
  PcmFormat_SInt20_4_Be , PcmFormat_SInt20_4_Le , PcmFormat_UInt20_4 , PcmFormat_UInt20_4_Be ,
  PcmFormat_UInt20_4_Le , PcmFormat_SInt24 , PcmFormat_SInt24_Be , PcmFormat_SInt24_Le ,
  PcmFormat_UInt24 , PcmFormat_UInt24_Be , PcmFormat_UInt24_Le , PcmFormat_SInt24_4 ,
  PcmFormat_SInt24_4_Be , PcmFormat_SInt24_4_Le , PcmFormat_UInt24_4 , PcmFormat_UInt24_4_Be ,
  PcmFormat_UInt24_4_Le , PcmFormat_SInt32 , PcmFormat_SInt32_Be , PcmFormat_SInt32_Le ,
  PcmFormat_UInt32 , PcmFormat_UInt32_Be , PcmFormat_UInt32_Le , PcmFormat_SInt64 ,
  PcmFormat_SInt64_Be , PcmFormat_SInt64_Le , PcmFormat_UInt64 , PcmFormat_UInt64_Be ,
  PcmFormat_UInt64_Le , PcmFormat_Float32 , PcmFormat_Float32_Be , PcmFormat_Float32_Le ,
  PcmFormat_Float64 , PcmFormat_Float64_Be , PcmFormat_Float64_Le , PcmFormat_Max
}
 PCM format. Defines PCM sample coding and endian. More...
 
enum  ResamplerBackend { ResamplerBackend_Default , ResamplerBackend_Builtin , ResamplerBackend_Speex , ResamplerBackend_SpeexDec }
 Resampler backends. More...
 
enum  ResamplerProfile { ResamplerProfile_Low , ResamplerProfile_Medium , ResamplerProfile_High }
 Resampler parameters presets. More...
 
enum  SampleFormat { SampleFormat_Invalid , SampleFormat_Pcm }
 Sample format. Defines representation of samples in memory. Does not define sample rate and channel set. More...
 

Functions

const char * channel_layout_to_str (ChannelLayout)
 Get string name of channel layout. More...
 
const char * channel_order_to_str (ChannelOrder)
 Get string name of channel order. More...
 
const char * channel_pos_to_str (ChannelPosition)
 Get string name from channel position. More...
 
const char * channel_mask_to_str (ChannelMask)
 Get string name from channel mask. More...
 
void format_channel_set (const ChannelSet &ch_set, core::StringBuilder &bld)
 Format ChannelSet to string. More...
 
const char * latency_tuner_backend_to_str (LatencyTunerBackend backend)
 Get string name of latency backend. More...
 
const char * latency_tuner_profile_to_str (LatencyTunerProfile tuner)
 Get string name of latency tuner. More...
 
PcmMapFn pcm_format_mapfn (PcmFormat in_format, PcmFormat out_format)
 Get mapping function for given PCM format pair. More...
 
PcmTraits pcm_format_traits (PcmFormat format)
 Get format traits for given PCM format. More...
 
const char * pcm_format_to_str (PcmFormat format)
 Get string name of PCM format. More...
 
PcmFormat pcm_format_from_str (const char *str)
 Get PCM format from string name. More...
 
ROC_ATTR_NODISCARD bool print_supported ()
 Print supported encodings. More...
 
const char * resampler_backend_to_str (ResamplerBackend backend)
 Get string name of resampler backend. More...
 
const char * resampler_profile_to_str (ResamplerProfile profile)
 Get string name of resampler profile. More...
 
const char * sample_format_to_str (SampleFormat format)
 Get string name of sample format. More...
 
ROC_ATTR_NODISCARD bool parse_sample_spec (const char *str, SampleSpec &result)
 Parse sample spec from string. More...
 
void format_sample_spec (const SampleSpec &sample_spec, core::StringBuilder &bld)
 Format sample spec to string. More...
 

Variables

const ChannelPositionName ChanPositionNames [ChanPos_Max]
 Defines mapping between channel position and its name. More...
 
const ChannelMaskName ChanMaskNames [17]
 Defines mapping between channel mask and its name. More...
 
const ChannelOrderTable ChanOrderTables [ChanOrder_Max]
 Defines mapping of channel order identifier to list of channel positions in corresponding order. More...
 
const ChannelMapTable ChanMapTables [71]
 Defines list of mappings between all supported surround channel mask pairs. More...
 
const double fe_decim_h [fe_decim_len]
 Impulse response of decimation filter with factor of 10. More...
 
const double fe_decim_h_gain
 Filters gain, sum(fe_decim_h). More...
 
const PcmFormat Sample_RawFormat
 Format description for raw audio samples. More...
 
const sample_t Sample_Min
 Minimum possible value of a raw sample. More...
 
const sample_t Sample_Max
 Maximum possible value of a raw sample. More...
 

Detailed Description

Audio frames and audio processing.

Typedef Documentation

◆ ChannelMask

typedef uint32_t roc::audio::ChannelMask

Channel mask.

Remarks
Used to construct short channel sets (up to 32 channels) for ChanLayout_Surround layout.

Definition at line 148 of file channel_defs.h.

◆ PcmMapFn

typedef void(* roc::audio::PcmMapFn) (const uint8_t *in_data, size_t &in_bit_off, uint8_t *out_data, size_t &out_bit_off, size_t n_samples)

PCM mapping function.

Definition at line 235 of file pcm_format.h.

◆ sample_t

typedef float roc::audio::sample_t

Raw audio sample.

Definition at line 22 of file sample.h.

Enumeration Type Documentation

◆ ChannelLayout

Channel layout. Defines meaning of channels in ChannelSet. ChannelMapper uses channel layout to decide how to perform mapping.

Enumerator
ChanLayout_None 

Channel layout is not set.

Remarks
This is never valid and indicates that ChannelSet is not fully initialized.
ChanLayout_Surround 

Multi-channel mono / stereo / surround sound.

Remarks
The meaning of channel index is defined by ChannelPosition enum. Channels are mapped according to their position in space, e.g. if top-left channel is missing, it can be mixed from front-left and side-left channels.
ChanLayout_Multitrack 

Multi-channel multi-track sound.

Remarks
There is no special meaning of channels, they are considered to be independent tracks. Channels are mapped according to their numbers; channel N is mapped to channel N and nothing else.

Definition at line 23 of file channel_defs.h.

◆ ChannelOrder

Surround channel order.

Remarks
Should be used with ChannelLayout_Surround. Defines order in which channels from ChannelSet are (de)serialized.
Enumerator
ChanOrder_None 

Channel order is not set.

Remarks
For ChanLayout_Surround, this is never valid and indicates that ChannelSet is not fully initialized. For ChanLayout_Multitrack, in contrast, this is the only valid value.
ChanOrder_Smpte 

ITU/SMPTE channel order. Order: FL, FR, FC, LFE, BL, BR, BC, SL, SR, TFL, TFR, TBL, TBR, TML, TMR.

Remarks
This order is actually a superset of what is defined by SMPTE, but when filtered by actual masks like 5.1 or 7.1, it produces orderings equal to what is defined in the standard. When used with masks 2.x - 5.x (but not 6.x), it is also compatible with the channel order from AIFF-C, which is used by default in RTP/AVP, as defined in RFC 3551.
ChanOrder_Alsa 

ALSA channel order. Order: FL, FR, BL, BR, FC, LFE, SL, SR, BC.

Remarks
This order is used by ALSA hardware devices. ALSA supports only 9 channels.
ChanOrder_Max 

Maximum value of enum.

Definition at line 49 of file channel_defs.h.

◆ ChannelPosition

Surround channel position.

Remarks
Should be used with ChannelLayout_Surround. Defines meaning of channel indices for mono / stereo / surround sound.
Note
Despite mono, stereo, and 3.x technically are not surround layouts, in the code base they are considered a special case of surround.
Enumerator
ChanPos_FrontLeft 

Front left (FL).

ChanPos_FrontLeftOfCenter 

Front left of center (FLC).

ChanPos_FrontCenter 

Front center (FC).

ChanPos_FrontRightOfCenter 

Front right of center (FRC).

ChanPos_FrontRight 

Front right (FR).

ChanPos_SideLeft 

Side left (SL).

ChanPos_SideRight 

Side right (SR).

ChanPos_BackLeft 

Back left (BL).

ChanPos_BackCenter 

Back center (BC).

ChanPos_BackRight 

Back right (BR).

ChanPos_TopFrontLeft 

Top front left (TFL).

ChanPos_TopFrontRight 

Top front right (TFR).

ChanPos_TopMidLeft 

Top middle left (TML).

ChanPos_TopMidRight 

Top middle right (TMR).

ChanPos_TopBackLeft 

Top rear left (TBL).

ChanPos_TopBackRight 

Top rear right (TBR).

ChanPos_LowFrequency 

Low frequency speaker (LFE).

Remarks
Placed anywhere. Also known as "subwoofer" or "SW" speaker.
ChanPos_Max 

Maximum value of enum.

Definition at line 86 of file channel_defs.h.

◆ FreqEstimatorProfile

FreqEstimator paremeter preset.

Enumerator
FreqEstimatorProfile_Responsive 

Fast and responsive tuning. Good for lower network latency and jitter.

FreqEstimatorProfile_Gradual 

Slow and smooth tuning. Good for higher network latency and jitter.

Definition at line 24 of file freq_estimator.h.

◆ LatencyTunerBackend

Latency tuner backend. Defines which latency we monitor and tune to achieve target.

Enumerator
LatencyTunerBackend_Default 

Deduce best default for given settings.

LatencyTunerBackend_Niq 

Latency is Network Incoming Queue length. Calculated on receiver without use of any signaling protocol. Reported back to sender via RTCP XR.

LatencyTunerBackend_E2e 

Latency is End-to-end delay. Can on receiver if RTCP XR is supported by both sides. Reported back to sender via RTCP XR.

Definition at line 29 of file latency_tuner.h.

◆ LatencyTunerProfile

Latency tuner profile. Defines whether and how we tune latency on fly to compensate clock drift and jitter.

Enumerator
LatencyTunerProfile_Default 

Deduce best default for given settings.

LatencyTunerProfile_Intact 

Do not tune latency.

LatencyTunerProfile_Responsive 

Fast and responsive tuning. Good for lower network latency and jitter.

LatencyTunerProfile_Gradual 

Slow and smooth tuning. Good for higher network latency and jitter.

Definition at line 47 of file latency_tuner.h.

◆ PcmFormat

PCM format. Defines PCM sample coding and endian.

Enumerator
PcmFormat_Invalid 

Invalid format.

PcmFormat_SInt8 

8-bit signed integer, native endian.

PcmFormat_SInt8_Be 

8-bit signed integer, big endian.

PcmFormat_SInt8_Le 

8-bit signed integer, little endian.

PcmFormat_UInt8 

8-bit unsigned integer, native endian.

PcmFormat_UInt8_Be 

8-bit unsigned integer, big endian.

PcmFormat_UInt8_Le 

8-bit unsigned integer, little endian.

PcmFormat_SInt16 

16-bit signed integer, native endian.

PcmFormat_SInt16_Be 

16-bit signed integer, big endian.

PcmFormat_SInt16_Le 

16-bit signed integer, little endian.

PcmFormat_UInt16 

16-bit unsigned integer, native endian.

PcmFormat_UInt16_Be 

16-bit unsigned integer, big endian.

PcmFormat_UInt16_Le 

16-bit unsigned integer, little endian.

PcmFormat_SInt18 

18-bit signed integer (2.25 bytes), native endian.

PcmFormat_SInt18_Be 

18-bit signed integer (2.25 bytes), big endian.

PcmFormat_SInt18_Le 

18-bit signed integer (2.25 bytes), little endian.

PcmFormat_UInt18 

18-bit unsigned integer (2.25 bytes), native endian.

PcmFormat_UInt18_Be 

18-bit unsigned integer (2.25 bytes), big endian.

PcmFormat_UInt18_Le 

18-bit unsigned integer (2.25 bytes), little endian.

PcmFormat_SInt18_3 

18-bit signed integer, in low bits of 3-byte container, native endian.

PcmFormat_SInt18_3_Be 

18-bit signed integer, in low bits of 3-byte container, big endian.

PcmFormat_SInt18_3_Le 

18-bit signed integer, in low bits of 3-byte container, little endian.

PcmFormat_UInt18_3 

18-bit unsigned integer, in low bits of 3-byte container, native endian.

PcmFormat_UInt18_3_Be 

18-bit unsigned integer, in low bits of 3-byte container, big endian.

PcmFormat_UInt18_3_Le 

18-bit unsigned integer, in low bits of 3-byte container, little endian.

PcmFormat_SInt18_4 

18-bit signed integer, in low bits of 4-byte container, native endian.

PcmFormat_SInt18_4_Be 

18-bit signed integer, in low bits of 4-byte container, big endian.

PcmFormat_SInt18_4_Le 

18-bit signed integer, in low bits of 4-byte container, little endian.

PcmFormat_UInt18_4 

18-bit unsigned integer, in low bits of 4-byte container, native endian.

PcmFormat_UInt18_4_Be 

18-bit unsigned integer, in low bits of 4-byte container, big endian.

PcmFormat_UInt18_4_Le 

18-bit unsigned integer, in low bits of 4-byte container, little endian.

PcmFormat_SInt20 

20-bit signed integer (2.5 bytes), native endian.

PcmFormat_SInt20_Be 

20-bit signed integer (2.5 bytes), big endian.

PcmFormat_SInt20_Le 

20-bit signed integer (2.5 bytes), little endian.

PcmFormat_UInt20 

20-bit unsigned integer (2.5 bytes), native endian.

PcmFormat_UInt20_Be 

20-bit unsigned integer (2.5 bytes), big endian.

PcmFormat_UInt20_Le 

20-bit unsigned integer (2.5 bytes), little endian.

PcmFormat_SInt20_3 

20-bit signed integer, in low bits of 3-byte container, native endian.

PcmFormat_SInt20_3_Be 

20-bit signed integer, in low bits of 3-byte container, big endian.

PcmFormat_SInt20_3_Le 

20-bit signed integer, in low bits of 3-byte container, little endian.

PcmFormat_UInt20_3 

20-bit unsigned integer, in low bits of 3-byte container, native endian.

PcmFormat_UInt20_3_Be 

20-bit unsigned integer, in low bits of 3-byte container, big endian.

PcmFormat_UInt20_3_Le 

20-bit unsigned integer, in low bits of 3-byte container, little endian.

PcmFormat_SInt20_4 

20-bit signed integer, in low bits of 4-byte container, native endian.

PcmFormat_SInt20_4_Be 

20-bit signed integer, in low bits of 4-byte container, big endian.

PcmFormat_SInt20_4_Le 

20-bit signed integer, in low bits of 4-byte container, little endian.

PcmFormat_UInt20_4 

20-bit unsigned integer, in low bits of 4-byte container, native endian.

PcmFormat_UInt20_4_Be 

20-bit unsigned integer, in low bits of 4-byte container, big endian.

PcmFormat_UInt20_4_Le 

20-bit unsigned integer, in low bits of 4-byte container, little endian.

PcmFormat_SInt24 

24-bit signed integer (3 bytes), native endian.

PcmFormat_SInt24_Be 

24-bit signed integer (3 bytes), big endian.

PcmFormat_SInt24_Le 

24-bit signed integer (3 bytes), little endian.

PcmFormat_UInt24 

24-bit unsigned integer (3 bytes), native endian.

PcmFormat_UInt24_Be 

24-bit unsigned integer (3 bytes), big endian.

PcmFormat_UInt24_Le 

24-bit unsigned integer (3 bytes), little endian.

PcmFormat_SInt24_4 

24-bit signed integer, in low bits of 4-byte container, native endian.

PcmFormat_SInt24_4_Be 

24-bit signed integer, in low bits of 4-byte container, big endian.

PcmFormat_SInt24_4_Le 

24-bit signed integer, in low bits of 4-byte container, little endian.

PcmFormat_UInt24_4 

24-bit unsigned integer, in low bits of 4-byte container, native endian.

PcmFormat_UInt24_4_Be 

24-bit unsigned integer, in low bits of 4-byte container, big endian.

PcmFormat_UInt24_4_Le 

24-bit unsigned integer, in low bits of 4-byte container, little endian.

PcmFormat_SInt32 

32-bit signed integer, native endian.

PcmFormat_SInt32_Be 

32-bit signed integer, big endian.

PcmFormat_SInt32_Le 

32-bit signed integer, little endian.

PcmFormat_UInt32 

32-bit unsigned integer, native endian.

PcmFormat_UInt32_Be 

32-bit unsigned integer, big endian.

PcmFormat_UInt32_Le 

32-bit unsigned integer, little endian.

PcmFormat_SInt64 

64-bit signed integer, native endian.

PcmFormat_SInt64_Be 

64-bit signed integer, big endian.

PcmFormat_SInt64_Le 

64-bit signed integer, little endian.

PcmFormat_UInt64 

64-bit unsigned integer, native endian.

PcmFormat_UInt64_Be 

64-bit unsigned integer, big endian.

PcmFormat_UInt64_Le 

64-bit unsigned integer, little endian.

PcmFormat_Float32 

32-bit IEEE-754 float in range [-1.0; +1.0], native endian.

PcmFormat_Float32_Be 

32-bit IEEE-754 float in range [-1.0; +1.0], big endian.

PcmFormat_Float32_Le 

32-bit IEEE-754 float in range [-1.0; +1.0], little endian.

PcmFormat_Float64 

64-bit IEEE-754 float in range [-1.0; +1.0], native endian.

PcmFormat_Float64_Be 

64-bit IEEE-754 float in range [-1.0; +1.0], big endian.

PcmFormat_Float64_Le 

64-bit IEEE-754 float in range [-1.0; +1.0], little endian.

PcmFormat_Max 

Maximum enum value.

Definition at line 22 of file pcm_format.h.

◆ ResamplerBackend

Resampler backends.

Enumerator
ResamplerBackend_Default 

Default backend. Resolved to one of other backends, depending on what is enabled at build time.

ResamplerBackend_Builtin 

Built-in resampler. High precision, high quality, slow.

ResamplerBackend_Speex 

SpeexDSP resampler. Low precision, high quality, fast. May be disabled at build time.

ResamplerBackend_SpeexDec 

Combined SpeexDSP + decimating resampler. Tolerable precision, tolerable quality, fast. May be disabled at build time.

Definition at line 21 of file resampler_config.h.

◆ ResamplerProfile

Resampler parameters presets.

Enumerator
ResamplerProfile_Low 

Low quality, fast speed.

ResamplerProfile_Medium 

Medium quality, medium speed.

ResamplerProfile_High 

High quality, low speed.

Definition at line 43 of file resampler_config.h.

◆ SampleFormat

Sample format. Defines representation of samples in memory. Does not define sample rate and channel set.

Enumerator
SampleFormat_Invalid 

Invalid format.

SampleFormat_Pcm 

Interleaved PCM format. What specific PCM coding and endian is used is defined by PcmFormat enum.

Definition at line 23 of file sample_format.h.

Function Documentation

◆ channel_layout_to_str()

const char* roc::audio::channel_layout_to_str ( ChannelLayout  )

Get string name of channel layout.

◆ channel_mask_to_str()

const char* roc::audio::channel_mask_to_str ( ChannelMask  )

Get string name from channel mask.

◆ channel_order_to_str()

const char* roc::audio::channel_order_to_str ( ChannelOrder  )

Get string name of channel order.

◆ channel_pos_to_str()

const char* roc::audio::channel_pos_to_str ( ChannelPosition  )

Get string name from channel position.

◆ format_channel_set()

void roc::audio::format_channel_set ( const ChannelSet ch_set,
core::StringBuilder bld 
)

Format ChannelSet to string.

◆ format_sample_spec()

void roc::audio::format_sample_spec ( const SampleSpec sample_spec,
core::StringBuilder bld 
)

Format sample spec to string.

◆ latency_tuner_backend_to_str()

const char* roc::audio::latency_tuner_backend_to_str ( LatencyTunerBackend  backend)

Get string name of latency backend.

◆ latency_tuner_profile_to_str()

const char* roc::audio::latency_tuner_profile_to_str ( LatencyTunerProfile  tuner)

Get string name of latency tuner.

◆ parse_sample_spec()

ROC_ATTR_NODISCARD bool roc::audio::parse_sample_spec ( const char *  str,
SampleSpec result 
)

Parse sample spec from string.

Remarks
The input string should have the form:
  • "<format>/<rate>/<channels>"

Where:

  • "<format>" is string name of sample format (e.g. "s16")
  • "<rate>" is a positive integer
  • "<channels>" can be: "<surround preset>", "<surround channel list>", "<multitrack mask>", "<multitrack channel list>"
  • "<surround preset>" is a string name of predefined surround channel mask, e.g. "stereo", "surround4.1", etc.
  • "<surround channel list>" is comma-separated list of surround channel names, e.g. "FL,FC,FR"
  • "<multitrack mask>" is a 1024-bit hex mask defining which tracks are enabled, e.g. "0xAA00BB00"
  • "<multitrack channel list>" is a comma-separated list of track numbers or ranges, e.g. "1,2,5-8"

Each of the three components ("<format>", "<rate>", "<channels>") may be set to "-", which means "keep unset".

All four forms of "<channels>" component are alternative ways to represent a bitmask of enabled channels or tracks. The order of channels does no matter.

Examples:

  • "s16/44100/stereo"
  • "s18_4le/48000/FL,FC,FR"
  • "f32/96000/1,2,10-20,31"
  • "f32/96000/0xA0000000FFFF0000000C"
  • "-/44100/-"
  • "-/-/-"
Returns
false if string can't be parsed.

◆ pcm_format_from_str()

PcmFormat roc::audio::pcm_format_from_str ( const char *  str)

Get PCM format from string name.

◆ pcm_format_mapfn()

PcmMapFn roc::audio::pcm_format_mapfn ( PcmFormat  in_format,
PcmFormat  out_format 
)

Get mapping function for given PCM format pair.

◆ pcm_format_to_str()

const char* roc::audio::pcm_format_to_str ( PcmFormat  format)

Get string name of PCM format.

◆ pcm_format_traits()

PcmTraits roc::audio::pcm_format_traits ( PcmFormat  format)

Get format traits for given PCM format.

◆ print_supported()

ROC_ATTR_NODISCARD bool roc::audio::print_supported ( )

Print supported encodings.

◆ resampler_backend_to_str()

const char* roc::audio::resampler_backend_to_str ( ResamplerBackend  backend)

Get string name of resampler backend.

◆ resampler_profile_to_str()

const char* roc::audio::resampler_profile_to_str ( ResamplerProfile  profile)

Get string name of resampler profile.

◆ sample_format_to_str()

const char* roc::audio::sample_format_to_str ( SampleFormat  format)

Get string name of sample format.

Variable Documentation

◆ ChanMapTables

const ChannelMapTable roc::audio::ChanMapTables[71]
extern

Defines list of mappings between all supported surround channel mask pairs.

Channel mapper will search for appropriate mapping in this list, based on input and output channel masks.

These tables define downmixing coefficients for mapping between different surround channel sets. They are used for both downmixing and upmixing.

Mappings should be ordered from smaller to larger masks, because channel mapper will use the very first pair that covers both output and input masks.

Only downmixing mappings are defined. Upmixing mappings are derived automatically from them.

Technically, some of the mappings are actually partially downmixing, and partially upmixing, for example mapping from 6.x to 5.1.x downmixes some channels and upmixes others. However, for convenience, we still call it "downmixing" because we consider 6.x to be a "larger" channel set than 5.x.

For groups of similar layouts, when possible, mappings are defined only for the most complete layout, and are automatically reused for the rest. For example, mappings for 5.1.2 may be automatically used for 5.1 and 5.0.

These tables were originally based on the following documents (and then extended to cover more combinations):

  • ITU-R BS.775-1, ANNEX 4
  • A/52, Digital Audio Compression (AC-3) (E-AC-3) Standard, sections 6.1.12 and 7.8

Useful links: https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.775-1-199407-S!!PDF-E.pdf https://prdatsc.wpenginepowered.com/wp-content/uploads/2021/04/A52-2018.pdf https://www.audiokinetic.com/en/library/edge/?source=Help&id=downmix_tables https://trac.ffmpeg.org/wiki/AudioChannelManipulation https://superuser.com/questions/852400

◆ ChanMaskNames

const ChannelMaskName roc::audio::ChanMaskNames[17]
extern

Defines mapping between channel mask and its name.

◆ ChanOrderTables

const ChannelOrderTable roc::audio::ChanOrderTables[ChanOrder_Max]
extern

Defines mapping of channel order identifier to list of channel positions in corresponding order.

When channel order is applied, the list of channels is filtered, and only channels present in channel mask are kept. The resulting filtered list defines how channels are placed in memory.

This allows us to define single list that for multiple channel masks. For example, ITU/SMPTE defines order for each channel mask (5.x, 7.x), but we define only one list ChanOrder_Smpte, and after filtering it becomes suitable for each of the masks.

The opposite is also true: if some channel is missing from the order's list, it is considered unsupported by the order and is zeroized.

Links: https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2102-0-201701-I!!PDF-E.pdf

◆ ChanPositionNames

const ChannelPositionName roc::audio::ChanPositionNames[ChanPos_Max]
extern

Defines mapping between channel position and its name.

◆ fe_decim_h

const double roc::audio::fe_decim_h[fe_decim_len]
extern

Impulse response of decimation filter with factor of 10.

◆ fe_decim_h_gain

const double roc::audio::fe_decim_h_gain
extern

Filters gain, sum(fe_decim_h).

◆ Sample_Max

const sample_t roc::audio::Sample_Max
extern

Maximum possible value of a raw sample.

◆ Sample_Min

const sample_t roc::audio::Sample_Min
extern

Minimum possible value of a raw sample.

◆ Sample_RawFormat

const PcmFormat roc::audio::Sample_RawFormat
extern

Format description for raw audio samples.