30#ifndef APF_POINTER_POLICY_H
31#define APF_POINTER_POLICY_H
37#ifndef APF_MIMOPROCESSOR_SAMPLE_TYPE
38#define APF_MIMOPROCESSOR_SAMPLE_TYPE float
40#ifndef APF_MIMOPROCESSOR_INTERFACE_POLICY
41#define APF_MIMOPROCESSOR_INTERFACE_POLICY apf::pointer_policy<APF_MIMOPROCESSOR_SAMPLE_TYPE*>
47template<
typename T>
class pointer_policy;
53class pointer_policy<T*>
56 using sample_type = T;
61 void audio_callback(
size_t n, T*
const* in, T*
const* out);
64 bool activate()
const {
return true; }
65 bool deactivate()
const {
return true; }
67 size_t block_size()
const {
return _block_size; }
68 size_t sample_rate()
const {
return _sample_rate; }
70 int in_channels()
const {
return _next_input_id; }
71 int out_channels()
const {
return _next_output_id; }
75 : _sample_rate(params.get<
size_t>(
"sample_rate"))
76 , _block_size(params.get<
size_t>(
"block_size"))
83 virtual ~pointer_policy() =
default;
86 virtual void process() = 0;
90 int get_next_input_id() {
return _next_input_id++; }
93 int get_next_output_id() {
return _next_output_id++; }
95 const size_t _sample_rate;
96 const size_t _block_size;
119 assert(n == this->block_size());
128class pointer_policy<T*>::Input
131 using iterator = T
const*;
137 this->buffer._begin = _parent._in[_id];
138 this->buffer._end = this->buffer._begin + _parent.block_size();
144 Input(pointer_policy& parent,
const parameter_map&)
146 , _id(_parent.get_next_input_id())
152 Input(
const Input&); Input& operator=(
const Input&);
154 pointer_policy& _parent;
159class pointer_policy<T*>::Output
164 struct buffer_type : has_begin_and_end<iterator> {
friend class Output; };
168 this->buffer._begin = _parent._out[_id];
169 this->buffer._end = this->buffer._begin + _parent.block_size();
175 Output(pointer_policy& parent,
const parameter_map&)
177 , _id(_parent.get_next_output_id())
183 Output(
const Output&); Output& operator=(
const Output&);
185 pointer_policy& _parent;
Convenience class providing begin() and end().
void audio_callback(size_t n, T *const *in, T *const *out)
This has to be called for each audio block.
Several more or less useful iterators and some macros.
Audio Processing Framework.
A "dictionary" for parameters.
A "dictionary" for parameters.