~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kevin Roy
  • Date: 2011-02-08 22:20:54 UTC
  • mfrom: (1.4.2 upstream)
  • mto: (14.2.6 sid) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110208222054-kk0gwa4bu8h5lyq4
Tags: upstream-2.56.1-beta-svn34076
Import upstream version 2.56.1-beta-svn34076

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: AUD_BaseIIRFilterReader.cpp 31372 2010-08-16 11:41:07Z nexyon $
 
3
 *
 
4
 * ***** BEGIN LGPL LICENSE BLOCK *****
 
5
 *
 
6
 * Copyright 2009 Jörg Hermann Müller
 
7
 *
 
8
 * This file is part of AudaSpace.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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/>.
 
22
 *
 
23
 * ***** END LGPL LICENSE BLOCK *****
 
24
 */
 
25
 
 
26
#include "AUD_BaseIIRFilterReader.h"
 
27
 
 
28
#include <cstring>
 
29
 
 
30
#define CC m_channels + m_channel
 
31
 
 
32
AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_IReader* reader, int in,
 
33
                                                                                                 int out) :
 
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)
 
38
{
 
39
        m_x = new sample_t[in * m_channels];
 
40
        m_y = new sample_t[out * m_channels];
 
41
 
 
42
        memset(m_x, 0, sizeof(sample_t) * in * m_channels);
 
43
        memset(m_y, 0, sizeof(sample_t) * out * m_channels);
 
44
}
 
45
 
 
46
AUD_BaseIIRFilterReader::~AUD_BaseIIRFilterReader()
 
47
{
 
48
        delete[] m_x;
 
49
        delete[] m_y;
 
50
}
 
51
 
 
52
void AUD_BaseIIRFilterReader::read(int & length, sample_t* & buffer)
 
53
{
 
54
        sample_t* buf;
 
55
 
 
56
        int samplesize = AUD_SAMPLE_SIZE(m_reader->getSpecs());
 
57
 
 
58
        m_reader->read(length, buf);
 
59
 
 
60
        if(m_buffer.getSize() < length * samplesize)
 
61
                m_buffer.resize(length * samplesize);
 
62
 
 
63
        buffer = m_buffer.getBuffer();
 
64
 
 
65
        for(m_channel = 0; m_channel < m_channels; m_channel++)
 
66
        {
 
67
                for(int i = 0; i < length; i++)
 
68
                {
 
69
                        m_x[m_xpos * CC] = buf[i * CC];
 
70
                        m_y[m_ypos * CC] = buffer[i * CC] = filter();
 
71
 
 
72
                        m_xpos = (m_xpos + 1) % m_xlen;
 
73
                        m_ypos = (m_ypos + 1) % m_ylen;
 
74
                }
 
75
        }
 
76
}