Nsound  0.9.4
FilterStageIIR.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: FilterStageIIR.h 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2007 Nick Hilton
11 //
12 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 //-----------------------------------------------------------------------------
15 
16 //-----------------------------------------------------------------------------
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 //-----------------------------------------------------------------------------
33 #ifndef _NSOUND_FILTER_STAGE_IIR_H_
34 #define _NSOUND_FILTER_STAGE_IIR_H_
35 
36 #include <Nsound/Filter.h>
37 
38 #include <set>
39 
40 namespace Nsound
41 {
42 
43 // Forward class declarations
44 class AudioStream;
45 class Buffer;
46 
47 //-----------------------------------------------------------------------------
49 class FilterStageIIR : public Filter
50 {
51  public:
52 
53  enum Type
54  {
57  };
58 
60  Type type,
61  const float64 & sample_rate,
62  uint32 n_poles,
63  const float64 & frequency,
64  const float64 & percent_ripple);
65 
66  FilterStageIIR(const FilterStageIIR & copy);
67 
68  virtual ~FilterStageIIR();
69 
71  filter(const AudioStream & x);
72 
74  filter(const AudioStream & x, const float64 & f);
75 
77  filter(const AudioStream & x, const Buffer & frequencies);
78 
79  Buffer
80  filter(const Buffer & x);
81 
82  Buffer
83  filter(const Buffer & x, const float64 & f);
84 
85  Buffer
86  filter(const Buffer & x, const Buffer & frequencies);
87 
88  float64
89  filter(const float64 & x);
90 
91  float64
92  filter(const float64 & x, const float64 & frequency);
93 
94  void
95  makeKernel(const float64 & frequency);
96 
98  operator=(const FilterStageIIR & rhs);
99 
100  void
101  reset();
102 
103  protected:
104 
105  void
107  const float64 & frequency,
108  float64 * a,
109  float64 * b,
110  uint32 p);
111 
116 
119 
123 
127 
129  struct Kernel
130  {
131  Kernel(const uint32 & frequency);
132 
133  bool operator<(const Kernel & rhs) const;
134 
137 
139  };
140 
141  typedef std::set<Kernel> KernelCache;
142 
144 
145 };
146 
147 };
148 
149 // :mode=c++: jEdit modeline
150 
151 #endif
unsigned int uint32
Definition: Nsound.h:153
std::set< Kernel > KernelCache
AudioStream filter(const AudioStream &x)
Kernel(const uint32 &frequency)
A class for filtering audio in the frequecy domain.
bool operator<(const Kernel &rhs) const
A class to store calculated kernels.
double float64
Definition: Nsound.h:146
FilterStageIIR & operator=(const FilterStageIIR &rhs)
Base class for IIR Filters, defines the interface.
Definition: Filter.h:49
FilterStageIIR(Type type, const float64 &sample_rate, uint32 n_poles, const float64 &frequency, const float64 &percent_ripple)
A Buffer for storing audio samples.
Definition: Buffer.h:60
void makeIIRKernelHelper(const float64 &frequency, float64 *a, float64 *b, uint32 p)
void makeKernel(const float64 &frequency)