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

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...

#include <channel_set.h>

Public Member Functions

 ChannelSet ()
 Construct empty channel set. More...
 
 ChannelSet (ChannelLayout layout, ChannelOrder order, ChannelMask mask)
 Construct with given layout and 32-bit channel mask. More...
 
bool operator== (const ChannelSet &other) const
 Check two channel sets for equality. More...
 
bool operator!= (const ChannelSet &other) const
 Check two channel sets for equality. More...
 
bool is_valid () const
 Check if channel set has valid layout and order, and non-zero channels. More...
 
void clear ()
 Unset all fields. More...
 
ChannelLayout layout () const
 Get channel layout. More...
 
void set_layout (ChannelLayout layout)
 Set layout of the channel set. More...
 
ChannelOrder order () const
 Get channel order. More...
 
void set_order (ChannelOrder order)
 Set order of the channel set. More...
 
size_t num_channels () const
 Get number of enabled channels. More...
 
bool has_channel (size_t n) const
 Check if specific channel is enabled. More...
 
size_t first_channel () const
 Get index of first enabled channel. More...
 
size_t last_channel () const
 Get index of last enabled channel. More...
 
bool is_equal (ChannelMask mask) const
 Check if channel set is equal to given mask. More...
 
bool is_subset (ChannelMask mask) const
 Check if channel set is sub-set of given mask, or equal to it. More...
 
bool is_superset (ChannelMask mask) const
 Check if channel set is super-set of given mask, or equal to it. More...
 
void set_mask (ChannelMask mask)
 Set channel mask to given bitmask. More...
 
void set_range (size_t from, size_t to)
 Set channel mask to all channels from inclusive range. More...
 
void set_count (size_t count)
 Set channel mask based on channel count. More...
 
void toggle_channel (size_t n, bool enabled)
 Enable/disable given channel. More...
 
void toggle_channel_range (size_t from, size_t to, bool enabled)
 Enable/disable all channels in inclusive range. More...
 
void bitwise_and (const ChannelSet &other)
 Set channel set to result of bitwise AND operation with another set. More...
 
void bitwise_or (const ChannelSet &other)
 Set channel set to result of bitwise OR operation with another set. More...
 
void bitwise_xor (const ChannelSet &other)
 Set channel set to result of bitwise XOR operation with another set. More...
 
size_t num_bytes () const
 Get number of bytes in bit mask. More...
 
uint8_t byte_at (size_t n) const
 Get byte by index from bit mask. More...
 

Static Public Member Functions

static size_t max_channels ()
 Get maximum possible number of channels. More...
 

Detailed Description

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.

Definition at line 26 of file channel_set.h.

Constructor & Destructor Documentation

◆ ChannelSet() [1/2]

roc::audio::ChannelSet::ChannelSet ( )

Construct empty channel set.

◆ ChannelSet() [2/2]

roc::audio::ChannelSet::ChannelSet ( ChannelLayout  layout,
ChannelOrder  order,
ChannelMask  mask 
)

Construct with given layout and 32-bit channel mask.

Remarks
The mask defines only first 32 channels. All channels outside of 0-31 range will be disabled. If you need more channels, construct empty channel set and enable channels or channel ranges using setters.

Member Function Documentation

◆ bitwise_and()

void roc::audio::ChannelSet::bitwise_and ( const ChannelSet other)

Set channel set to result of bitwise AND operation with another set.

Remarks
Similar to "&=".

◆ bitwise_or()

void roc::audio::ChannelSet::bitwise_or ( const ChannelSet other)

Set channel set to result of bitwise OR operation with another set.

Remarks
Similar to "|=".

◆ bitwise_xor()

void roc::audio::ChannelSet::bitwise_xor ( const ChannelSet other)

Set channel set to result of bitwise XOR operation with another set.

Remarks
Similar to "^=".

◆ byte_at()

uint8_t roc::audio::ChannelSet::byte_at ( size_t  n) const

Get byte by index from bit mask.

◆ clear()

void roc::audio::ChannelSet::clear ( )

Unset all fields.

◆ first_channel()

size_t roc::audio::ChannelSet::first_channel ( ) const

Get index of first enabled channel.

Remarks
Panics if there are no enabled channels.

◆ has_channel()

bool roc::audio::ChannelSet::has_channel ( size_t  n) const

Check if specific channel is enabled.

◆ is_equal()

bool roc::audio::ChannelSet::is_equal ( ChannelMask  mask) const

Check if channel set is equal to given mask.

Remarks
The mask defines only first 32 channels. If any channels outside of 0-31 range are enabled in channel set, the method will fail.

◆ is_subset()

bool roc::audio::ChannelSet::is_subset ( ChannelMask  mask) const

Check if channel set is sub-set of given mask, or equal to it.

Remarks
The mask defines only first 32 channels. If any channels outside of 0-31 range are enabled in channel set, the method will fail.

◆ is_superset()

bool roc::audio::ChannelSet::is_superset ( ChannelMask  mask) const

Check if channel set is super-set of given mask, or equal to it.

Remarks
The mask defines only first 32 channels. If any channels outside of 0-31 range are enabled in channel set, the method will succeed.

◆ is_valid()

bool roc::audio::ChannelSet::is_valid ( ) const

Check if channel set has valid layout and order, and non-zero channels.

◆ last_channel()

size_t roc::audio::ChannelSet::last_channel ( ) const

Get index of last enabled channel.

Remarks
Panics if there are no enabled channels.

◆ layout()

ChannelLayout roc::audio::ChannelSet::layout ( ) const

Get channel layout.

Remarks
Defines meaning of channel numbers (e.g. that channel 0 is front-left).

◆ max_channels()

static size_t roc::audio::ChannelSet::max_channels ( )
static

Get maximum possible number of channels.

◆ num_bytes()

size_t roc::audio::ChannelSet::num_bytes ( ) const

Get number of bytes in bit mask.

◆ num_channels()

size_t roc::audio::ChannelSet::num_channels ( ) const

Get number of enabled channels.

◆ operator!=()

bool roc::audio::ChannelSet::operator!= ( const ChannelSet other) const

Check two channel sets for equality.

◆ operator==()

bool roc::audio::ChannelSet::operator== ( const ChannelSet other) const

Check two channel sets for equality.

◆ order()

ChannelOrder roc::audio::ChannelSet::order ( ) const

Get channel order.

Remarks
Defines order of serialized channels (e.g. that front-left goes before front-right).

◆ set_count()

void roc::audio::ChannelSet::set_count ( size_t  count)

Set channel mask based on channel count.

Remarks
Tries to find a mask that looks most appropriate for given channel count. Falls back to just enabling first N channels and disabling others.

◆ set_layout()

void roc::audio::ChannelSet::set_layout ( ChannelLayout  layout)

Set layout of the channel set.

◆ set_mask()

void roc::audio::ChannelSet::set_mask ( ChannelMask  mask)

Set channel mask to given bitmask.

Remarks
The mask defines only first 32 channels. All channels outside of the 0-31 range are disabled.

◆ set_order()

void roc::audio::ChannelSet::set_order ( ChannelOrder  order)

Set order of the channel set.

◆ set_range()

void roc::audio::ChannelSet::set_range ( size_t  from,
size_t  to 
)

Set channel mask to all channels from inclusive range.

Remarks
All channels within range and enabled. All other channels are disabled.

◆ toggle_channel()

void roc::audio::ChannelSet::toggle_channel ( size_t  n,
bool  enabled 
)

Enable/disable given channel.

◆ toggle_channel_range()

void roc::audio::ChannelSet::toggle_channel_range ( size_t  from,
size_t  to,
bool  enabled 
)

Enable/disable all channels in inclusive range.


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