Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
resampler_speex.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/target_speexdsp/roc_audio/resampler_speex.h
10//! @brief Resampler Speex.
11
12#ifndef ROC_AUDIO_RESAMPLER_SPEEX_H_
13#define ROC_AUDIO_RESAMPLER_SPEEX_H_
14
15#include "roc_audio/frame.h"
19#include "roc_audio/sample.h"
21#include "roc_core/array.h"
25#include "roc_core/slice.h"
26#include "roc_core/stddefs.h"
27#include "roc_packet/units.h"
28
29#include <speex/speex_resampler.h>
30
31namespace roc {
32namespace audio {
33
34//! Resamples audio stream using speex resampler.
36public:
37 //! Initialize.
39 core::BufferFactory<sample_t>& buffer_factory,
40 ResamplerProfile profile,
41 core::nanoseconds_t frame_length,
42 const audio::SampleSpec& sample_spec);
43
45
46 //! Check if object is successfully constructed.
47 virtual bool valid() const;
48
49 //! Set new resample factor.
50 virtual bool set_scaling(size_t input_rate, size_t output_rate, float multiplier);
51
52 //! Get buffer to be filled with input data.
54
55 //! Commit buffer with input data.
56 virtual void end_push_input();
57
58 //! Read samples from input frame and fill output frame.
59 virtual size_t pop_output(Frame& out);
60
61private:
62 void report_stats_();
63
64 SpeexResamplerState* speex_state_;
65
66 core::Slice<sample_t> in_frame_;
67 const spx_uint32_t in_frame_size_;
68 spx_uint32_t in_frame_pos_;
69
70 const spx_uint32_t num_ch_;
71
72 core::RateLimiter rate_limiter_;
73
74 bool valid_;
75};
76
77} // namespace audio
78} // namespace roc
79
80#endif // ROC_AUDIO_RESAMPLER_SPEEX_H_
Dynamic array.
Buffer factory.
Audio frame.
Definition: frame.h:22
Audio writer interface.
Definition: iresampler.h:23
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
Resamples audio stream using speex resampler.
virtual void end_push_input()
Commit buffer with input data.
virtual bool set_scaling(size_t input_rate, size_t output_rate, float multiplier)
Set new resample factor.
virtual const core::Slice< sample_t > & begin_push_input()
Get buffer to be filled with input data.
SpeexResampler(core::IAllocator &allocator, core::BufferFactory< sample_t > &buffer_factory, ResamplerProfile profile, core::nanoseconds_t frame_length, const audio::SampleSpec &sample_spec)
Initialize.
virtual size_t pop_output(Frame &out)
Read samples from input frame and fill output frame.
virtual bool valid() const
Check if object is successfully constructed.
Memory allocator interface.
Definition: iallocator.h:23
Base class for non-copyable objects.
Definition: noncopyable.h:23
Slice.
Definition: slice.h:54
Audio frame.
Frame reader interface.
Audio resampler interface.
ResamplerProfile
Resampler parameters presets.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Rate limiter.
Resampler profile.
Audio sample.
Sample specifications.
Slice.
Commonly used types and functions.
Various units used in packets.