2
* $Id: AUD_BaseIIRFilterReader.cpp 31372 2010-08-16 11:41:07Z nexyon $
4
* ***** BEGIN LGPL LICENSE BLOCK *****
6
* Copyright 2009 Jörg Hermann Müller
8
* This file is part of AudaSpace.
10
* AudaSpace is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU Lesser General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
15
* AudaSpace is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
23
* ***** END LGPL LICENSE BLOCK *****
26
#include "AUD_BaseIIRFilterReader.h"
30
#define CC m_channels + m_channel
32
AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_IReader* reader, int in,
34
AUD_EffectReader(reader),
35
m_channels(reader->getSpecs().channels),
36
m_xlen(in), m_ylen(out),
37
m_xpos(0), m_ypos(0), m_channel(0)
39
m_x = new sample_t[in * m_channels];
40
m_y = new sample_t[out * m_channels];
42
memset(m_x, 0, sizeof(sample_t) * in * m_channels);
43
memset(m_y, 0, sizeof(sample_t) * out * m_channels);
46
AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
52
void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer)
56
int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
58
m_reader->read(length, buf);
60
if(m_buffer.getSize() < length * samplesize)
61
m_buffer.resize(length * samplesize);
63
buffer = m_buffer.getBuffer();
65
for(m_channel = 0; m_channel < m_channels; m_channel++)
67
for(int i = 0; i < length; i++)
69
m_x[m_xpos * CC] = buf[i * CC];
70
m_y[m_ypos * CC] = buffer[i * CC] = filter();
72
m_xpos = (m_xpos + 1) % m_xlen;
73
m_ypos = (m_ypos + 1) % m_ylen;