Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
resampler_reader.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_reader.h
10
//! @brief Resampler.
11
12
#ifndef ROC_AUDIO_RESAMPLER_READER_H_
13
#define ROC_AUDIO_RESAMPLER_READER_H_
14
15
#include "
roc_audio/frame.h
"
16
#include "
roc_audio/iframe_reader.h
"
17
#include "
roc_audio/iresampler.h
"
18
#include "
roc_audio/sample.h
"
19
#include "
roc_audio/sample_spec.h
"
20
#include "
roc_core/array.h
"
21
#include "
roc_core/noncopyable.h
"
22
#include "
roc_core/slice.h
"
23
#include "
roc_core/stddefs.h
"
24
#include "
roc_packet/units.h
"
25
26
namespace
roc
{
27
namespace
audio
{
28
29
//! Resampler element for reading pipeline.
30
class
ResamplerReader
:
public
IFrameReader
,
public
core::NonCopyable
<> {
31
public
:
32
//! Initialize.
33
ResamplerReader
(
IFrameReader
& reader,
34
IResampler
& resampler,
35
const
SampleSpec
& in_sample_spec,
36
const
SampleSpec
& out_sample_spec);
37
38
//! Check if object is successfully constructed.
39
bool
is_valid
()
const
;
40
41
//! Set new resample factor.
42
bool
set_scaling
(
float
multiplier);
43
44
//! Read audio frame.
45
virtual
bool
read
(
Frame
&);
46
47
private
:
48
bool
push_input_();
49
core::nanoseconds_t
capture_ts_(
Frame
& out_frame);
50
51
IResampler
& resampler_;
52
IFrameReader
& reader_;
53
54
const
SampleSpec
in_sample_spec_;
55
const
SampleSpec
out_sample_spec_;
56
57
// timestamp of the last sample +1 of the last frame pushed into resampler
58
core::nanoseconds_t
last_in_cts_;
59
60
float
scaling_;
61
bool
valid_;
62
};
63
64
}
// namespace audio
65
}
// namespace roc
66
67
#endif
// ROC_AUDIO_RESAMPLER_READER_H_
array.h
Dynamic array.
roc::audio::Frame
Audio frame.
Definition
frame.h:25
roc::audio::IFrameReader
Frame reader interface.
Definition
iframe_reader.h:22
roc::audio::IResampler
Audio writer interface.
Definition
iresampler.h:24
roc::audio::ResamplerReader::ResamplerReader
ResamplerReader(IFrameReader &reader, IResampler &resampler, const SampleSpec &in_sample_spec, const SampleSpec &out_sample_spec)
Initialize.
roc::audio::ResamplerReader::set_scaling
bool set_scaling(float multiplier)
Set new resample factor.
roc::audio::ResamplerReader::read
virtual bool read(Frame &)
Read audio frame.
roc::audio::ResamplerReader::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
frame.h
Audio frame.
iframe_reader.h
Frame reader 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_reader.h
Generated by
1.17.0