Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
channel_mapper_reader.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_reader.h
10//! @brief Channel mapper reader.
11
12#ifndef ROC_AUDIO_CHANNEL_MAPPER_READER_H_
13#define ROC_AUDIO_CHANNEL_MAPPER_READER_H_
14
20#include "roc_core/slice.h"
21#include "roc_core/stddefs.h"
22
23namespace roc {
24namespace audio {
25
26//! Channel mapper reader.
27//! Reads frames from nested reader and maps them to another channel mask.
29public:
30 //! Initialize.
32 core::BufferFactory<sample_t>& buffer_factory,
33 core::nanoseconds_t frame_length,
34 const SampleSpec& in_spec,
35 const SampleSpec& out_spec);
36
37 //! Check if the object was succefully constructed.
38 bool valid() const;
39
40 //! Read audio frame.
41 virtual bool read(Frame& frame);
42
43private:
44 bool read_(sample_t* out_samples, size_t n_samples, unsigned& flags);
45
46 IFrameReader& input_reader_;
47 core::Slice<sample_t> input_buf_;
48
49 ChannelMapper mapper_;
50 const bool mapper_enabled_;
51
52 const SampleSpec in_spec_;
53 const SampleSpec out_spec_;
54
55 bool valid_;
56};
57
58} // namespace audio
59} // namespace roc
60
61#endif // ROC_AUDIO_CHANNEL_MAPPER_READER_H_
Buffer factory.
Channel mapper reader. Reads frames from nested reader and maps them to another channel mask.
bool valid() const
Check if the object was succefully constructed.
ChannelMapperReader(IFrameReader &reader, core::BufferFactory< sample_t > &buffer_factory, core::nanoseconds_t frame_length, const SampleSpec &in_spec, const SampleSpec &out_spec)
Initialize.
virtual bool read(Frame &frame)
Read audio frame.
Channel mapper. Converts between frames with specified channel masks.
Audio frame.
Definition frame.h:22
Frame reader interface.
Sample stream specification. Defines sample rate and channel layout.
Definition sample_spec.h:24
Base class for non-copyable objects.
Definition noncopyable.h:23
Frame reader interface.
float sample_t
Audio sample.
Definition sample.h:22
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
Root namespace.
Non-copyable object.
Sample specifications.
Slice.
Commonly used types and functions.