Nsound  0.9.4
FilterLowPassFIR.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: FilterLowPassFIR.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) 2006 - Present 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_LOW_PASS_FIR_H_
34 #define _NSOUND_FILTER_LOW_PASS_FIR_H_
35 
36 #include <Nsound/Filter.h>
37 
38 #include <set>
39 
40 namespace Nsound
41 {
42 
43 //-----------------------------------------------------------------------------
44 class FilterLowPassFIR : public Filter
45 {
46  public:
47 
49  const float64 & sample_rate,
50  uint32 kernel_size,
51  const float64 & cutoff_frequency_Hz);
52 
53  virtual ~FilterLowPassFIR();
54 
56  filter(const AudioStream & x);
57 
59  filter(const AudioStream & x, const float64 & frequency);
60 
62  filter(const AudioStream & x, const Buffer & frequencies);
63 
64  Buffer
65  filter(const Buffer & x);
66 
67  Buffer
68  filter(const Buffer & x, const float64 & frequency);
69 
70  Buffer
71  filter(const Buffer & x, const Buffer & frequencies);
72 
73  virtual
74  float64
75  filter(const float64 & x);
76 
77  float64
78  filter(const float64 & x, const float64 & frequency_Hz);
79 
80  float64
81  getFrequency() const {return frequency_1_Hz_;};
82 
84  Buffer
86 
87  void
88  plot(boolean show_fc = true, boolean show_phase = false);
89 
92  void
93  reset();
94 
96  void
97  setCutoff(const float64 & fc);
98 
99  protected:
100 
101  void
102  makeKernel(const float64 & frequency1);
103 
106 
107  // These are for point by point filtering. filter_(float64)
111 
113 
115  struct Kernel
116  {
117  Kernel(const uint32 & frequency);
118 
119  bool operator<(const Kernel & rhs) const;
120 
122 
124  };
125 
126  typedef std::set<Kernel> KernelCache;
127 
129 
130  private:
131 
132  FilterLowPassFIR(const FilterLowPassFIR & copy);
133 
135  operator=(const FilterLowPassFIR & rhs){return *this;};
136 ;
137 
138 }; // LowPassFilter
139 
140 }; // Nsound
141 
142 // :mode=c++: jEdit modeline
143 #endif
void plot(boolean show_fc=true, boolean show_phase=false)
FilterLowPassFIR(const float64 &sample_rate, uint32 kernel_size, const float64 &cutoff_frequency_Hz)
unsigned int uint32
Definition: Nsound.h:153
FilterLowPassFIR & operator=(const FilterLowPassFIR &rhs)
double float64
Definition: Nsound.h:146
bool operator<(const Kernel &rhs) const
void makeKernel(const float64 &frequency1)
Base class for IIR Filters, defines the interface.
Definition: Filter.h:49
float64 getFrequency() const
std::set< Kernel > KernelCache
A Buffer for storing audio samples.
Definition: Buffer.h:60
Kernel(const uint32 &frequency)
void setCutoff(const float64 &fc)
Sets the cut off frequency (Hz).
A class to store calculated kernels.
AudioStream filter(const AudioStream &x)