TracktionEngine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
tracktion::engine::ChannelConfiguration Class Reference

Represents a configuration of audio channels. More...

#include <tracktion_ChannelConfiguration.h>

Public Member Functions

 ChannelConfiguration ()=default
 Creates an empty channel configuration.
 
 ChannelConfiguration (std::vector< ChannelIndex > channels)
 Creates a channel configuration from a list of channel indices.
 
 ChannelConfiguration (const ChannelIndex *channels, size_t numChannels)
 Creates a channel configuration from a span of channel indices.
 
bool isEmpty () const noexcept
 Returns true if this configuration has no channels.
 
size_t size () const noexcept
 Returns the number of channels in this configuration.
 
int getNumChannels () const noexcept
 Returns the number of channels in this configuration.
 
const ChannelIndexdata () const noexcept
 Returns a pointer to the channel data.
 
const ChannelIndexoperator[] (size_t index) const
 Returns the channel at the given index.
 
auto begin () noexcept
 Returns an iterator to the beginning.
 
auto begin () const noexcept
 
auto end () noexcept
 Returns an iterator to the end.
 
auto end () const noexcept
 
bool isMono () const noexcept
 Returns true if this is a mono configuration (single channel).
 
bool isStereo () const noexcept
 Returns true if this is a stereo configuration (exactly 2 channels, L+R).
 
bool isMonoOrStereo () const noexcept
 Returns true if this configuration has 1 or 2 channels.
 
bool isMultichannel () const noexcept
 Returns true if this configuration has more than 2 channels.
 
bool contains (const ChannelIndex &) const noexcept
 Returns true if this configuration contains the given channel (exact match).
 
bool containsDeviceChannel (int deviceChannelIndex) const noexcept
 Returns true if this configuration contains a channel with the given device index.
 
std::pair< int, int > getChannelRange () const
 Returns the range of device channel indices [first, one-past-last) used by this configuration.
 
ChannelConfiguration intersection (const ChannelConfiguration &other) const
 Returns a new configuration containing only channels whose device indices also appear in the other configuration.
 
juce::AudioChannelSet toChannelSet () const
 Creates a JUCE AudioChannelSet from this configuration.
 
void clear () noexcept
 Clears all channels from this configuration.
 
void addChannel (ChannelIndex channel)
 Adds a channel to this configuration.
 
void setNumChannels (int numChannels, int firstDeviceChannelIndex=0)
 Sets the number of channels, creating discrete channels starting from a given index.
 
bool operator== (const ChannelConfiguration &other) const
 
bool operator!= (const ChannelConfiguration &other) const
 
choc::value::Value toJSON () const
 Serializes this configuration to JSON.
 
std::string toString () const
 Serializes this configuration to a string.
 
ChannelConfiguration reversed () const
 Returns a new configuration with the device index mapping reversed.
 
juce::String getDescription () const
 Creates a human-readable description of the channels.
 
juce::String getMatchingPresetName () const
 Returns the preset name that matches this configuration, or "From Edit" if no match.
 

Static Public Member Functions

static ChannelConfiguration none ()
 Creates an empty configuration — a bus that imposes no channel-count requirement.
 
static ChannelConfiguration mono (int deviceChannelIndex=0)
 Creates a mono configuration with a single channel.
 
static ChannelConfiguration left (int deviceChannelIndex=0)
 Creates a left-only configuration (single left channel).
 
static ChannelConfiguration right (int deviceChannelIndex=1)
 Creates a right-only configuration (single right channel).
 
static ChannelConfiguration stereo (int firstDeviceChannelIndex=0)
 Creates a stereo configuration with left and right channels.
 
static ChannelConfiguration surround5_1 (int firstDeviceChannelIndex=0)
 Creates a 5.1 surround configuration (L, R, C, LFE, Ls, Rs).
 
static ChannelConfiguration surround7_1 (int firstDeviceChannelIndex=0)
 Creates a 7.1 surround configuration (L, R, C, LFE, Ls, Rs, Lrs, Rrs).
 
static ChannelConfiguration discreteChannels (int numChannels, int firstDeviceChannelIndex=0)
 Creates a configuration with discrete (unnamed) channels.
 
static ChannelConfiguration canonical (int numChannels, int firstDeviceChannelIndex=0)
 Creates a canonical configuration for a given number of channels.
 
static ChannelConfiguration fromChannelSet (const juce::AudioChannelSet &, int firstDeviceChannelIndex=0)
 Creates a configuration from an AudioChannelSet and starting device index.
 
static ChannelConfiguration fromJSON (const choc::value::ValueView &)
 Creates a configuration from JSON.
 
static ChannelConfiguration fromString (std::string_view)
 Creates a configuration from a string.
 

Detailed Description

Represents a configuration of audio channels.

This is a wrapper around a list of ChannelIndex objects, optimized to avoid heap allocations for typical channel counts (up to 8 channels).

Use the factory methods to create common configurations:

static ChannelConfiguration stereo(int firstDeviceChannelIndex=0)
Creates a stereo configuration with left and right channels.
static ChannelConfiguration mono(int deviceChannelIndex=0)
Creates a mono configuration with a single channel.
static ChannelConfiguration discreteChannels(int numChannels, int firstDeviceChannelIndex=0)
Creates a configuration with discrete (unnamed) channels.
static ChannelConfiguration surround5_1(int firstDeviceChannelIndex=0)
Creates a 5.1 surround configuration (L, R, C, LFE, Ls, Rs).

Constructor & Destructor Documentation

◆ ChannelConfiguration() [1/3]

tracktion::engine::ChannelConfiguration::ChannelConfiguration ( )
default

Creates an empty channel configuration.

◆ ChannelConfiguration() [2/3]

tracktion::engine::ChannelConfiguration::ChannelConfiguration ( std::vector< ChannelIndex channels)
explicit

Creates a channel configuration from a list of channel indices.

◆ ChannelConfiguration() [3/3]

tracktion::engine::ChannelConfiguration::ChannelConfiguration ( const ChannelIndex channels,
size_t  numChannels 
)

Creates a channel configuration from a span of channel indices.

Member Function Documentation

◆ none()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::none ( )
static

Creates an empty configuration — a bus that imposes no channel-count requirement.

Use this for buses that should pass audio through at whatever channel count the graph happens to be running at (e.g. VolumeAndPan's output, LevelMeter, VCA). Equivalent to a default-constructed instance, but more self-documenting at the call site.

◆ mono()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::mono ( int  deviceChannelIndex = 0)
static

Creates a mono configuration with a single channel.

◆ left()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::left ( int  deviceChannelIndex = 0)
static

Creates a left-only configuration (single left channel).

◆ right()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::right ( int  deviceChannelIndex = 1)
static

Creates a right-only configuration (single right channel).

◆ stereo()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::stereo ( int  firstDeviceChannelIndex = 0)
static

Creates a stereo configuration with left and right channels.

◆ surround5_1()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::surround5_1 ( int  firstDeviceChannelIndex = 0)
static

Creates a 5.1 surround configuration (L, R, C, LFE, Ls, Rs).

◆ surround7_1()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::surround7_1 ( int  firstDeviceChannelIndex = 0)
static

Creates a 7.1 surround configuration (L, R, C, LFE, Ls, Rs, Lrs, Rrs).

◆ discreteChannels()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::discreteChannels ( int  numChannels,
int  firstDeviceChannelIndex = 0 
)
static

Creates a configuration with discrete (unnamed) channels.

◆ canonical()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::canonical ( int  numChannels,
int  firstDeviceChannelIndex = 0 
)
static

Creates a canonical configuration for a given number of channels.

1=mono, 2=stereo, 6=5.1, 8=7.1, otherwise discrete.

◆ fromChannelSet()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::fromChannelSet ( const juce::AudioChannelSet &  ,
int  firstDeviceChannelIndex = 0 
)
static

Creates a configuration from an AudioChannelSet and starting device index.

◆ isEmpty()

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

Returns true if this configuration has no channels.

◆ size()

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

Returns the number of channels in this configuration.

◆ getNumChannels()

int tracktion::engine::ChannelConfiguration::getNumChannels ( ) const
noexcept

Returns the number of channels in this configuration.

◆ data()

const ChannelIndex * tracktion::engine::ChannelConfiguration::data ( ) const
noexcept

Returns a pointer to the channel data.

◆ operator[]()

const ChannelIndex & tracktion::engine::ChannelConfiguration::operator[] ( size_t  index) const

Returns the channel at the given index.

◆ begin() [1/2]

auto tracktion::engine::ChannelConfiguration::begin ( )
noexcept

Returns an iterator to the beginning.

◆ begin() [2/2]

auto tracktion::engine::ChannelConfiguration::begin ( ) const
noexcept

◆ end() [1/2]

auto tracktion::engine::ChannelConfiguration::end ( )
noexcept

Returns an iterator to the end.

◆ end() [2/2]

auto tracktion::engine::ChannelConfiguration::end ( ) const
noexcept

◆ isMono()

bool tracktion::engine::ChannelConfiguration::isMono ( ) const
noexcept

Returns true if this is a mono configuration (single channel).

◆ isStereo()

bool tracktion::engine::ChannelConfiguration::isStereo ( ) const
noexcept

Returns true if this is a stereo configuration (exactly 2 channels, L+R).

◆ isMonoOrStereo()

bool tracktion::engine::ChannelConfiguration::isMonoOrStereo ( ) const
noexcept

Returns true if this configuration has 1 or 2 channels.

◆ isMultichannel()

bool tracktion::engine::ChannelConfiguration::isMultichannel ( ) const
noexcept

Returns true if this configuration has more than 2 channels.

◆ contains()

bool tracktion::engine::ChannelConfiguration::contains ( const ChannelIndex ) const
noexcept

Returns true if this configuration contains the given channel (exact match).

◆ containsDeviceChannel()

bool tracktion::engine::ChannelConfiguration::containsDeviceChannel ( int  deviceChannelIndex) const
noexcept

Returns true if this configuration contains a channel with the given device index.

◆ getChannelRange()

std::pair< int, int > tracktion::engine::ChannelConfiguration::getChannelRange ( ) const

Returns the range of device channel indices [first, one-past-last) used by this configuration.

◆ intersection()

ChannelConfiguration tracktion::engine::ChannelConfiguration::intersection ( const ChannelConfiguration other) const

Returns a new configuration containing only channels whose device indices also appear in the other configuration.

◆ toChannelSet()

juce::AudioChannelSet tracktion::engine::ChannelConfiguration::toChannelSet ( ) const

Creates a JUCE AudioChannelSet from this configuration.

◆ clear()

void tracktion::engine::ChannelConfiguration::clear ( )
noexcept

Clears all channels from this configuration.

◆ addChannel()

void tracktion::engine::ChannelConfiguration::addChannel ( ChannelIndex  channel)

Adds a channel to this configuration.

◆ setNumChannels()

void tracktion::engine::ChannelConfiguration::setNumChannels ( int  numChannels,
int  firstDeviceChannelIndex = 0 
)

Sets the number of channels, creating discrete channels starting from a given index.

◆ operator==()

bool tracktion::engine::ChannelConfiguration::operator== ( const ChannelConfiguration other) const

Referenced by operator!=().

◆ operator!=()

bool tracktion::engine::ChannelConfiguration::operator!= ( const ChannelConfiguration other) const

References operator==().

◆ toJSON()

choc::value::Value tracktion::engine::ChannelConfiguration::toJSON ( ) const

Serializes this configuration to JSON.

◆ fromJSON()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::fromJSON ( const choc::value::ValueView &  )
static

Creates a configuration from JSON.

◆ toString()

std::string tracktion::engine::ChannelConfiguration::toString ( ) const

Serializes this configuration to a string.

◆ fromString()

static ChannelConfiguration tracktion::engine::ChannelConfiguration::fromString ( std::string_view  )
static

Creates a configuration from a string.

◆ reversed()

ChannelConfiguration tracktion::engine::ChannelConfiguration::reversed ( ) const

Returns a new configuration with the device index mapping reversed.

Channel types are preserved in their original positions, but the indexInDevice values are reversed. For example, stereo [{idx:0,L}, {idx:1,R}] becomes [{idx:1,L}, {idx:0,R}].

◆ getDescription()

juce::String tracktion::engine::ChannelConfiguration::getDescription ( ) const

Creates a human-readable description of the channels.

◆ getMatchingPresetName()

juce::String tracktion::engine::ChannelConfiguration::getMatchingPresetName ( ) const

Returns the preset name that matches this configuration, or "From Edit" if no match.


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