Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
BaseIIRFilterReader.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright 2009-2016 Jörg Müller
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16
17#pragma once
18
25#include "fx/EffectReader.h"
26
28
33{
34private:
38 Specs m_specs;
39
43 int m_xlen;
44
48 int m_ylen;
49
53 sample_t* m_x;
54
58 sample_t* m_y;
59
63 int m_xpos;
64
68 int m_ypos;
69
73 int m_channel;
74
75 // delete copy constructor and operator=
77 BaseIIRFilterReader& operator=(const BaseIIRFilterReader&) = delete;
78
79protected:
86 BaseIIRFilterReader(std::shared_ptr<IReader> reader, int in, int out);
87
93 void setLengths(int in, int out);
94
95public:
101 inline sample_t x(int pos)
102 {
103 return m_x[(m_xpos + pos + m_xlen) % m_xlen * m_specs.channels + m_channel];
104 }
105
111 inline sample_t y(int pos)
112 {
113 return m_y[(m_ypos + pos + m_ylen) % m_ylen * m_specs.channels + m_channel];
114 }
115
116 virtual ~BaseIIRFilterReader();
117
118 virtual void read(int& length, bool& eos, sample_t* buffer);
119
124 virtual sample_t filter()=0;
125
130 virtual void sampleRateChanged(SampleRate rate);
131};
132
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
float sample_t
Sample type.(float samples)
Definition Audaspace.h:126
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:93
The EffectReader class.
double SampleRate
Sample rate type.
Definition Specification.h:115
This class is a base class for infinite impulse response filters.
Definition BaseIIRFilterReader.h:33
void setLengths(int in, int out)
Sets the length for the required input and output samples of the IIR filter.
virtual void read(int &length, bool &eos, sample_t *buffer)
Request to read the next length samples out of the source.
sample_t x(int pos)
Retrieves the last input samples.
Definition BaseIIRFilterReader.h:101
virtual sample_t filter()=0
Runs the filtering function.
sample_t y(int pos)
Retrieves the last output samples.
Definition BaseIIRFilterReader.h:111
virtual void sampleRateChanged(SampleRate rate)
Notifies the filter about a sample rate change.
BaseIIRFilterReader(std::shared_ptr< IReader > reader, int in, int out)
Creates a new base IIR filter reader.
This reader is a base class for all effect readers that take one other reader as input.
Definition EffectReader.h:36
Specification of a sound source.
Definition Specification.h:119
Channels channels
Channel count.
Definition Specification.h:124