Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
iresampler.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 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/iresampler.h
10
//! @brief Audio resampler interface.
11
12
#ifndef ROC_AUDIO_IRESAMPLER_H_
13
#define ROC_AUDIO_IRESAMPLER_H_
14
15
#include "
roc_audio/frame.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/ref_counted.h
"
18
#include "
roc_core/slice.h
"
19
20
namespace
roc
{
21
namespace
audio
{
22
23
//! Audio writer interface.
24
class
IResampler
:
public
core::RefCounted
<IResampler, core::ArenaAllocation> {
25
public
:
26
//! Initialization.
27
IResampler
(
core::IArena
&
arena
);
28
29
//! Deinitialization.
30
virtual
~IResampler
();
31
32
//! Check if object is successfully constructed.
33
virtual
bool
is_valid
()
const
= 0;
34
35
//! Set new resample factor.
36
//! @remarks
37
//! Returns false if the scaling is invalid or out of bounds.
38
virtual
bool
set_scaling
(
size_t
input_rate,
size_t
output_rate,
float
multiplier) = 0;
39
40
//! Get buffer to be filled with input data.
41
//! @remarks
42
//! After this call, the caller should fill returned buffer with input
43
//! data and invoke end_push_input().
44
virtual
const
core::Slice<sample_t>
&
begin_push_input
() = 0;
45
46
//! Commit buffer with input data.
47
//! @remarks
48
//! Should be called after begin_push_input() to commit the push operation.
49
virtual
void
end_push_input
() = 0;
50
51
//! Read samples from input buffer and fill output frame.
52
//! @remarks
53
//! May return lesser samples than requested if there are no more samples in
54
//! the input ring buffer. In this case the caller should provide resampler
55
//! with more input samples using begin_push_input() and end_push_input().
56
virtual
size_t
pop_output
(
sample_t
* out_data,
size_t
out_size) = 0;
57
58
//! How many samples were pushed but not processed yet.
59
//! @remarks
60
//! If last input sample pushed to resampler has number N, then last output sample
61
//! popped from resampler corresponds to input sample number N - n_left_to_process().
62
//! @note
63
//! It is float, as a resampler backend could possibly keep track of current
64
//! position from output stream perspective.
65
//! @returns
66
//! Number of samples multiplied by channel count.
67
virtual
float
n_left_to_process
()
const
= 0;
68
};
69
70
}
// namespace audio
71
}
// namespace roc
72
73
#endif
// ROC_AUDIO_IRESAMPLER_H_
roc::audio::IResampler::n_left_to_process
virtual float n_left_to_process() const =0
How many samples were pushed but not processed yet.
roc::audio::IResampler::is_valid
virtual bool is_valid() const =0
Check if object is successfully constructed.
roc::audio::IResampler::~IResampler
virtual ~IResampler()
Deinitialization.
roc::audio::IResampler::end_push_input
virtual void end_push_input()=0
Commit buffer with input data.
roc::audio::IResampler::IResampler
IResampler(core::IArena &arena)
Initialization.
roc::audio::IResampler::pop_output
virtual size_t pop_output(sample_t *out_data, size_t out_size)=0
Read samples from input buffer and fill output frame.
roc::audio::IResampler::begin_push_input
virtual const core::Slice< sample_t > & begin_push_input()=0
Get buffer to be filled with input data.
roc::audio::IResampler::set_scaling
virtual bool set_scaling(size_t input_rate, size_t output_rate, float multiplier)=0
Set new resample factor.
roc::core::ArenaAllocation::arena
IArena & arena() const
Get arena.
Definition
allocation_policy.h:37
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::RefCounted
Base class for object with reference counter.
Definition
ref_counted.h:40
roc::core::Slice
Slice.
Definition
slice.h:55
frame.h
Audio frame.
roc::audio
Audio frames and audio processing.
roc::audio::sample_t
float sample_t
Raw audio sample.
Definition
sample.h:22
roc
Root namespace.
noncopyable.h
Non-copyable object.
ref_counted.h
Base class for object with reference counter.
slice.h
Slice.
roc_audio
iresampler.h
Generated by
1.17.0