Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
channel_mapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 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.h
10 //! @brief Mixer.
11 
12 #ifndef ROC_AUDIO_CHANNEL_MAPPER_H_
13 #define ROC_AUDIO_CHANNEL_MAPPER_H_
14 
16 #include "roc_audio/channel_set.h"
17 #include "roc_audio/frame.h"
19 #include "roc_core/noncopyable.h"
20 
21 namespace roc {
22 namespace audio {
23 
24 //! Channel mapper.
25 //! Converts between frames with specified channel masks.
26 class ChannelMapper : public core::NonCopyable<> {
27 public:
28  //! Initialize.
29  ChannelMapper(const ChannelSet& in_chans, const ChannelSet& out_chans);
30 
31  //! Map samples.
32  void map(const sample_t* in_samples,
33  size_t n_in_samples,
34  sample_t* out_samples,
35  size_t n_out_samples);
36 
37 private:
38  typedef void (ChannelMapper::*map_func_t)(const sample_t* in_samples,
39  sample_t* out_samples,
40  size_t n_samples);
41 
42  void map_surround_surround_(const sample_t* in_samples,
43  sample_t* out_samples,
44  size_t n_samples);
45  void map_multitrack_surround_(const sample_t* in_samples,
46  sample_t* out_samples,
47  size_t n_samples);
48  void map_multitrack_multitrack_(const sample_t* in_samples,
49  sample_t* out_samples,
50  size_t n_samples);
51 
52  void setup_map_func_();
53 
54  const ChannelSet in_chans_;
55  const ChannelSet out_chans_;
56  ChannelSet inout_chans_;
57 
58  ChannelMapperMatrix matrix_;
59  map_func_t map_func_;
60 };
61 
62 } // namespace audio
63 } // namespace roc
64 
65 #endif // ROC_AUDIO_CHANNEL_MAPPER_H_
Buffer factory.
Surround to surround conversation coefficients.
Channel set.
Contain conversation coefficients while mapping surround to surround.
Channel mapper. Converts between frames with specified channel masks.
void map(const sample_t *in_samples, size_t n_in_samples, sample_t *out_samples, size_t n_out_samples)
Map samples.
ChannelMapper(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
Audio frame.
float sample_t
Audio sample.
Definition: sample.h:22
Root namespace.
Non-copyable object.