Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
channel_mapper_matrix.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_matrix.h
10//! @brief Surround to surround conversation coefficients.
11
12#ifndef ROC_AUDIO_CHANNEL_MAPPER_MATRIX_H_
13#define ROC_AUDIO_CHANNEL_MAPPER_MATRIX_H_
14
18
19namespace roc {
20namespace audio {
21
22//! Contain conversation coefficients while mapping surround to surround.
24public:
25 //! Initialize.
26 //!
27 //! @remarks
28 //! Should be used only when mapping surround to surround.
29 ChannelMapperMatrix(const ChannelSet& in_chans, const ChannelSet& out_chans);
30
31 //! Return a conversation coefficient for input and output channels.
32 sample_t coeff(size_t out_ch, size_t in_ch) const;
33
34private:
35 //! Contain mapping of a channel to its position in matrix.
36 struct Mapping : public core::NonCopyable<> {
37 //! Map channels from @p chs to its position in matrix, taking into account
38 //! the channel order. @see ChannelOrder.
39 explicit Mapping(const ChannelSet& chs);
40
41 ChannelSet index_set;
42 size_t index_map[ChanPos_Max];
43 };
44
45 static const ChannelMap* find_channel_map_(const Mapping& out_mapping,
46 const Mapping& in_mapping,
47 bool& is_reverse);
48
49 //! Each channel is mapped only to itself.
50 void set_fallback_(const Mapping& out_mapping, const Mapping& in_mapping);
51
52 //! Fill mapping matrix based on rules from @p map.
53 void set_map_(const ChannelMap& map,
54 bool is_reverse,
55 const Mapping& out_mapping,
56 const Mapping& in_mapping);
57
58 //! Normalize mapping matrix.
59 void normalize_();
60
61 void set_(size_t out_ch,
62 size_t in_ch,
63 sample_t value,
64 const Mapping& out_mapping,
65 const Mapping& in_mapping);
66
68};
69
70} // namespace audio
71} // namespace roc
72
73#endif // ROC_AUDIO_CHANNEL_MAPPER_MATRIX_H_
Channel mapping tables.
Channel set.
Contain conversation coefficients while mapping surround to surround.
sample_t coeff(size_t out_ch, size_t in_ch) const
Return a conversation coefficient for input and output channels.
ChannelMapperMatrix(const ChannelSet &in_chans, const ChannelSet &out_chans)
Initialize.
Channel set. Multi-word bitmask with bits corresponding to enabled channels. Meaning of each channel ...
Definition channel_set.h:26
Base class for non-copyable objects.
Definition noncopyable.h:23
@ ChanPos_Max
Maximum value of enum.
float sample_t
Audio sample.
Definition sample.h:22
Root namespace.
Non-copyable object.
Defines multiplication matrix for two channel masks. Instead of defining the whole matrix,...