~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * Copyright 2009-2011 Jörg Hermann Müller
 
5
 *
 
6
 * This file is part of AudaSpace.
 
7
 *
 
8
 * Audaspace is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * AudaSpace is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with Audaspace; if not, write to the Free Software Foundation,
 
20
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
21
 *
 
22
 * ***** END GPL LICENSE BLOCK *****
 
23
 */
 
24
 
 
25
/** \file audaspace/FX/AUD_IIRFilterReader.cpp
 
26
 *  \ingroup audfx
 
27
 */
 
28
 
 
29
 
 
30
#include "AUD_IIRFilterReader.h"
 
31
 
 
32
AUD_IIRFilterReader::AUD_IIRFilterReader(AUD_Reference<AUD_IReader> reader,
 
33
                                                                                 const std::vector<float>& b,
 
34
                                                                                 const std::vector<float>& a) :
 
35
        AUD_BaseIIRFilterReader(reader, b.size(), a.size()), m_a(a), m_b(b)
 
36
{
 
37
        if(m_a.size())
 
38
        {
 
39
                for(int i = 1; i < m_a.size(); i++)
 
40
                        m_a[i] /= m_a[0];
 
41
                for(int i = 0; i < m_b.size(); i++)
 
42
                        m_b[i] /= m_a[0];
 
43
                m_a[0] = 1;
 
44
        }
 
45
}
 
46
 
 
47
sample_t AUD_IIRFilterReader::filter()
 
48
{
 
49
        sample_t out = 0;
 
50
 
 
51
        for(int i = 1; i < m_a.size(); i++)
 
52
                out -= y(-i) * m_a[i];
 
53
        for(int i = 0; i < m_b.size(); i++)
 
54
                out += x(-i) * m_b[i];
 
55
 
 
56
        return out;
 
57
}
 
58
 
 
59
void AUD_IIRFilterReader::setCoefficients(const std::vector<float>& b,
 
60
                                                                                  const std::vector<float>& a)
 
61
{
 
62
        setLengths(b.size(), a.size());
 
63
        m_a = a;
 
64
        m_b = b;
 
65
}