TracktionEngine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
tracktion::engine::ChannelMap Struct Reference

Represents a mapping from source channels to destination channels. More...

#include <tracktion_ChannelMap.h>

Classes

struct  Entry
 

Public Member Functions

 ChannelMap ()=default
 Creates an empty channel map.
 
 ChannelMap (std::vector< std::pair< int, int > > mappings)
 Creates a channel map from a vector of source->dest pairs (gain defaults to 1.0).
 
bool isEmpty () const noexcept
 Returns true if the map is empty.
 
size_t size () const noexcept
 Returns the number of mappings.
 
bool isIdentity () const noexcept
 Returns true if this is an identity mapping (each channel maps to itself at unity gain).
 
int getRequiredOutputChannels () const noexcept
 Returns the maximum destination channel index + 1 (i.e., the required output channel count).
 

Static Public Member Functions

static ChannelMap identity (int numChannels)
 Creates an identity mapping for the given number of channels.
 
static ChannelMap monoToStereo ()
 Creates a mapping that duplicates a mono source to stereo.
 
static ChannelMap stereoToMono ()
 Creates a mapping that averages stereo to mono (each channel at 0.5 gain).
 
static ChannelMap conversion (int fromChannels, int toChannels)
 Creates an appropriate conversion mapping between channel counts.
 
static ChannelMap duplicateToChannels (int sourceChannel, int numDestChannels)
 Creates a mapping that duplicates a source to all destination channels.
 

Public Attributes

std::vector< Entryentries
 The source -> destination mappings.
 

Detailed Description

Represents a mapping from source channels to destination channels.

Each entry maps a source channel index to a destination channel index with an optional gain factor (default 1.0). Multiple sources can map to the same destination (they will be summed). A single source can map to multiple destinations (it will be duplicated).

Constructor & Destructor Documentation

◆ ChannelMap() [1/2]

tracktion::engine::ChannelMap::ChannelMap ( )
default

Creates an empty channel map.

◆ ChannelMap() [2/2]

tracktion::engine::ChannelMap::ChannelMap ( std::vector< std::pair< int, int > >  mappings)
explicit

Creates a channel map from a vector of source->dest pairs (gain defaults to 1.0).

References entries.

Member Function Documentation

◆ identity()

static ChannelMap tracktion::engine::ChannelMap::identity ( int  numChannels)
static

Creates an identity mapping for the given number of channels.

References entries.

◆ monoToStereo()

static ChannelMap tracktion::engine::ChannelMap::monoToStereo ( )
static

Creates a mapping that duplicates a mono source to stereo.

◆ stereoToMono()

static ChannelMap tracktion::engine::ChannelMap::stereoToMono ( )
static

Creates a mapping that averages stereo to mono (each channel at 0.5 gain).

References entries.

◆ conversion()

static ChannelMap tracktion::engine::ChannelMap::conversion ( int  fromChannels,
int  toChannels 
)
static

Creates an appropriate conversion mapping between channel counts.

Rules:

  • Same count: identity mapping
  • Mono to stereo: duplicate channel 0 to both outputs
  • Stereo to mono: sum both channels to output 0
  • General upmix: identity for existing channels, duplicate last to fill remaining
  • General downmix: identity for channels that fit, sum remaining into last dest channel

References entries.

◆ duplicateToChannels()

static ChannelMap tracktion::engine::ChannelMap::duplicateToChannels ( int  sourceChannel,
int  numDestChannels 
)
static

Creates a mapping that duplicates a source to all destination channels.

References entries.

◆ isEmpty()

bool tracktion::engine::ChannelMap::isEmpty ( ) const
noexcept

Returns true if the map is empty.

◆ size()

size_t tracktion::engine::ChannelMap::size ( ) const
noexcept

Returns the number of mappings.

◆ isIdentity()

bool tracktion::engine::ChannelMap::isIdentity ( ) const
noexcept

Returns true if this is an identity mapping (each channel maps to itself at unity gain).

◆ getRequiredOutputChannels()

int tracktion::engine::ChannelMap::getRequiredOutputChannels ( ) const
noexcept

Returns the maximum destination channel index + 1 (i.e., the required output channel count).

Member Data Documentation

◆ entries

std::vector<Entry> tracktion::engine::ChannelMap::entries

The source -> destination mappings.

Referenced by ChannelMap(), conversion(), duplicateToChannels(), identity(), and stereoToMono().


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