2
* $Id: AUD_SquareFactory.cpp 25656 2010-01-01 18:45:21Z nexyon $
4
* ***** BEGIN LGPL LICENSE BLOCK *****
6
* Copyright 2009 Jörg Hermann Müller
2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* Copyright 2009-2011 Jörg Hermann Müller
8
6
* 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
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
13
11
* (at your option) any later version.
15
13
* AudaSpace is distributed in the hope that it will be useful,
16
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
15
* 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 *****
16
* GNU General Public License for more details.
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.
22
* ***** END GPL LICENSE BLOCK *****
25
/** \file audaspace/FX/AUD_SquareFactory.cpp
26
30
#include "AUD_SquareFactory.h"
27
#include "AUD_SquareReader.h"
29
AUD_SquareFactory::AUD_SquareFactory(AUD_IFactory* factory, float threshold) :
31
#include "AUD_CallbackIIRFilterReader.h"
33
sample_t AUD_SquareFactory::squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold)
35
float in = reader->x(0);
38
else if(in <= -*threshold)
44
void AUD_SquareFactory::endSquareFilter(float* threshold)
49
AUD_SquareFactory::AUD_SquareFactory(AUD_Reference<AUD_IFactory> factory, float threshold) :
30
50
AUD_EffectFactory(factory),
31
m_threshold(threshold) {}
33
AUD_SquareFactory::AUD_SquareFactory(float threshold) :
35
m_threshold(threshold) {}
37
float AUD_SquareFactory::getThreshold()
51
m_threshold(threshold)
55
float AUD_SquareFactory::getThreshold() const
39
57
return m_threshold;
42
void AUD_SquareFactory::setThreshold(float threshold)
44
m_threshold = threshold;
47
AUD_IReader* AUD_SquareFactory::createReader()
49
AUD_IReader* reader = getReader();
53
reader = new AUD_SquareReader(reader, m_threshold); AUD_NEW("reader")
60
AUD_Reference<AUD_IReader> AUD_SquareFactory::createReader()
62
return new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
63
(doFilterIIR) squareFilter,
64
(endFilterIIR) endSquareFilter,
65
new float(m_threshold));