1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2009-2011 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* Audaspace is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* AudaSpace is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Audaspace; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file audaspace/FX/AUD_BaseIIRFilterReader.cpp
* \ingroup audfx
*/
#include "AUD_BaseIIRFilterReader.h"
#include <cstring>
#define CC m_channels + m_channel
AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in,
int out) :
AUD_EffectReader(reader),
m_channels(reader->getSpecs().channels),
m_xlen(in), m_ylen(out),
m_xpos(0), m_ypos(0), m_channel(0)
{
m_x = new sample_t[in * m_channels];
m_y = new sample_t[out * m_channels];
memset(m_x, 0, sizeof(sample_t) * in * m_channels);
memset(m_y, 0, sizeof(sample_t) * out * m_channels);
}
AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
{
delete[] m_x;
delete[] m_y;
}
void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
m_reader->read(length, buf);
if(m_buffer.getSize() < length * samplesize)
m_buffer.resize(length * samplesize);
buffer = m_buffer.getBuffer();
for(m_channel = 0; m_channel < m_channels; m_channel++)
{
for(int i = 0; i < length; i++)
{
m_x[m_xpos * CC] = buf[i * CC];
m_y[m_ypos * CC] = buffer[i * CC] = filter();
m_xpos = (m_xpos + 1) % m_xlen;
m_ypos = (m_ypos + 1) % m_ylen;
}
}
}
|