Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
resampler_writer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 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/resampler_writer.h
10
//! @brief Resampler.
11
12
#ifndef ROC_AUDIO_RESAMPLER_WRITER_H_
13
#define ROC_AUDIO_RESAMPLER_WRITER_H_
14
15
#include "
roc_audio/frame.h
"
16
#include "
roc_audio/frame_factory.h
"
17
#include "
roc_audio/iframe_writer.h
"
18
#include "
roc_audio/iresampler.h
"
19
#include "
roc_audio/sample.h
"
20
#include "
roc_audio/sample_spec.h
"
21
#include "
roc_core/array.h
"
22
#include "
roc_core/noncopyable.h
"
23
#include "
roc_core/slice.h
"
24
#include "
roc_core/stddefs.h
"
25
#include "
roc_packet/units.h
"
26
27
namespace
roc
{
28
namespace
audio
{
29
30
//! Resampler element for writing pipeline.
31
class
ResamplerWriter
:
public
IFrameWriter
,
public
core::NonCopyable
<> {
32
public
:
33
//! Initialize.
34
ResamplerWriter
(
IFrameWriter
& writer,
35
IResampler
& resampler,
36
FrameFactory
& frame_factory,
37
const
SampleSpec
& in_sample_spec,
38
const
SampleSpec
& out_sample_spec);
39
40
//! Check if object is successfully constructed.
41
bool
is_valid
()
const
;
42
43
//! Set new resample factor.
44
bool
set_scaling
(
float
multiplier);
45
46
//! Read audio frame.
47
virtual
void
write
(
Frame
&);
48
49
private
:
50
size_t
push_input_(
Frame
& in_frame,
size_t
in_pos);
51
core::nanoseconds_t
capture_ts_(
Frame
& in_frame,
size_t
in_pos);
52
53
IResampler
& resampler_;
54
IFrameWriter
& writer_;
55
56
const
SampleSpec
in_sample_spec_;
57
const
SampleSpec
out_sample_spec_;
58
59
core::Slice<sample_t>
input_buf_;
60
core::Slice<sample_t>
output_buf_;
61
62
size_t
input_buf_pos_;
63
size_t
output_buf_pos_;
64
65
float
scaling_;
66
bool
valid_;
67
};
68
69
}
// namespace audio
70
}
// namespace roc
71
72
#endif
// ROC_AUDIO_RESAMPLER_WRITER_H_
array.h
Dynamic array.
roc::audio::FrameFactory
Frame factory.
Definition
frame_factory.h:38
roc::audio::Frame
Audio frame.
Definition
frame.h:25
roc::audio::IFrameWriter
Frame writer interface.
Definition
iframe_writer.h:22
roc::audio::IResampler
Audio writer interface.
Definition
iresampler.h:24
roc::audio::ResamplerWriter::write
virtual void write(Frame &)
Read audio frame.
roc::audio::ResamplerWriter::set_scaling
bool set_scaling(float multiplier)
Set new resample factor.
roc::audio::ResamplerWriter::ResamplerWriter
ResamplerWriter(IFrameWriter &writer, IResampler &resampler, FrameFactory &frame_factory, const SampleSpec &in_sample_spec, const SampleSpec &out_sample_spec)
Initialize.
roc::audio::ResamplerWriter::is_valid
bool is_valid() const
Check if object is successfully constructed.
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Slice
Slice.
Definition
slice.h:55
frame.h
Audio frame.
frame_factory.h
Frame factory.
iframe_writer.h
Frame writer interface.
iresampler.h
Audio resampler interface.
roc::audio
Audio frames and audio processing.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc
Root namespace.
noncopyable.h
Non-copyable object.
sample.h
Audio sample.
sample_spec.h
Sample specifications.
slice.h
Slice.
stddefs.h
Commonly used types and functions.
units.h
Various units used in packets.
roc_audio
resampler_writer.h
Generated by
1.17.0