Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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"
17#include "roc_core/slice.h"
18
19namespace roc {
20namespace audio {
21
22//! Audio writer interface.
24public:
25 virtual ~IResampler();
26
27 //! Check if object is successfully constructed.
28 virtual bool valid() const = 0;
29
30 //! Set new resample factor.
31 //! @remarks
32 //! Returns false if the scaling is invalid or out of bounds.
33 virtual bool set_scaling(size_t input_rate, size_t output_rate, float multiplier) = 0;
34
35 //! Get buffer to be filled with input data.
36 //! @remarks
37 //! After this call, the caller should fill returned buffer with input
38 //! data and invoke end_push_input().
40
41 //! Commit buffer with input data.
42 //! @remarks
43 //! Should be called after begin_push_input() to commit the push operation.
44 virtual void end_push_input() = 0;
45
46 //! Read samples from input buffer and fill output frame.
47 //! @remarks
48 //! May return lesser samples than requested if there are no more samples in
49 //! the input ring buffer. In this case the caller should provide resampler
50 //! with more input samples using begin_push_input() and end_push_input().
51 virtual size_t pop_output(Frame& out) = 0;
52};
53
54} // namespace audio
55} // namespace roc
56
57#endif // ROC_AUDIO_IRESAMPLER_H_
Audio frame.
Definition: frame.h:22
Audio writer interface.
Definition: iresampler.h:23
virtual bool valid() const =0
Check if object is successfully constructed.
virtual size_t pop_output(Frame &out)=0
Read samples from input buffer and fill output frame.
virtual void end_push_input()=0
Commit buffer with input data.
virtual const core::Slice< sample_t > & begin_push_input()=0
Get buffer to be filled with input data.
virtual bool set_scaling(size_t input_rate, size_t output_rate, float multiplier)=0
Set new resample factor.
Slice.
Definition: slice.h:54
Audio frame.
Root namespace.
Non-copyable object.
Slice.