Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
channel_mapper_table.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_audio/channel_mapper_table.h
10 //! @brief Channel mapping tables.
11 
12 #ifndef ROC_AUDIO_CHANNEL_MAPPER_TABLE_H_
13 #define ROC_AUDIO_CHANNEL_MAPPER_TABLE_H_
14 
15 #include "roc_audio/channel_defs.h"
16 #include "roc_audio/sample.h"
17 
18 namespace roc {
19 namespace audio {
20 
21 //! Defines multiplication coefficient for a pair of channels.
23  ChannelPosition out_ch; //!< Index of output channel.
24  ChannelPosition in_ch; //!< Index of input channel.
25  sample_t coeff; //!< Multiplication coefficient.
26 };
27 
28 //! Defines multiplication matrix for two channel masks.
29 //! Instead of defining the whole matrix, it defines a list of pairs of
30 //! output and input channel numbers and corresponding coefficients.
31 //! Such representation allows more compact definition in the source
32 //! code. The actual matrix is built by channel mapper at runtime.
33 struct ChannelMap {
34  const char* name; //!< Mapping name.
35 
36  ChannelMask in_mask; //!< Channel mask of input stream.
37  ChannelMask out_mask; //!< Channel mask of output stream.
38 
39  //! Transformation rules.
40  //! Rules are used to fill channel mapping matrix.
42 };
43 
44 //! Defines ordered list of channels.
45 struct ChannelList {
46  ChannelPosition chans[ChanPos_Max + 1]; //!< Channels.
47 };
48 
49 //! Number of defined channel mappings.
50 const size_t chan_map_count = 40;
51 
52 //! Defines list of mappings between all supported surround channel mask pairs.
53 //! Channel mapper will search for appropriate mapping in this list,
54 //! based on input and output channel masks.
55 extern const ChannelMap chan_maps[chan_map_count];
56 
57 //! Defines mapping of channel order identifier to list of channel positions
58 //! in corresponding order.
60 
61 } // namespace audio
62 } // namespace roc
63 
64 #endif // ROC_AUDIO_CHANNEL_MAPPER_TABLE_H_
Channel layout, order, and positions.
const size_t chan_map_count
Number of defined channel mappings.
ChannelPosition
Surround channel position.
Definition: channel_defs.h:86
@ ChanPos_Max
Maximum value of enum.
Definition: channel_defs.h:137
float sample_t
Audio sample.
Definition: sample.h:22
uint32_t ChannelMask
Channel mask.
Definition: channel_defs.h:144
const ChannelMap chan_maps[chan_map_count]
Defines list of mappings between all supported surround channel mask pairs. Channel mapper will searc...
const ChannelList chan_orders[ChanOrder_Max]
Defines mapping of channel order identifier to list of channel positions in corresponding order.
@ ChanOrder_Max
Maximum value of enum.
Definition: channel_defs.h:76
Root namespace.
Audio sample.
Defines ordered list of channels.
ChannelPosition chans[ChanPos_Max+1]
Channels.
Defines multiplication coefficient for a pair of channels.
ChannelPosition in_ch
Index of input channel.
sample_t coeff
Multiplication coefficient.
ChannelPosition out_ch
Index of output channel.
Defines multiplication matrix for two channel masks. Instead of defining the whole matrix,...
ChannelMask out_mask
Channel mask of output stream.
const char * name
Mapping name.
ChannelMask in_mask
Channel mask of input stream.
ChannelMapRule rules[24]
Transformation rules. Rules are used to fill channel mapping matrix.