Nsound  0.9.4
FilterBandRejectFIR.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: FilterBandRejectFIR.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_BAND_REJECT_FIR_H_
34 #define _NSOUND_FILTER_BAND_REJECT_FIR_H_
35 
37 
38 #include <set>
39 
40 namespace Nsound
41 {
42 
43 class AudioStream;
44 class Buffer;
45 
46 //-----------------------------------------------------------------------------
48 {
49  public:
50 
52  const float64 & sample_rate,
53  uint32 kernel_size,
54  const float64 & frequency_Hz_low,
55  const float64 & frequency_Hz_high);
56 
57  virtual ~FilterBandRejectFIR();
58 
59  float64
60  getFrequencyLow() const;
61 
62  float64
63  getFrequencyHigh() const;
64 
66  filter(const AudioStream & x);
67 
68 //~//~ AudioStream
69 //~ filter(const AudioStream & x, const Buffer & frequencies);
70 
72  filter(
73  const AudioStream & x,
74  const float64 & f_low,
75  const float64 & f_high);
76 
78  filter(
79  const AudioStream & x,
80  const Buffer & low_frequencies,
81  const Buffer & high_frequencies);
82 
83  Buffer
84  filter(const Buffer & x);
85 
86 //~//~ Buffer
87 //~ filter(const Buffer & x, const Buffer & frequencies);
88 
89  Buffer
90  filter(
91  const Buffer & x,
92  const float64 & f_low,
93  const float64 & f_high);
94 
95  Buffer
96  filter(
97  const Buffer & x,
98  const Buffer & frequencies_Hz_low,
99  const Buffer & frequencies_Hz_high);
100 
101  virtual
102  float64
103  filter(const float64 & x);
104 
105  virtual
106  float64
107  filter(const float64 & x, const float64 & frequency_Hz);
108 
109  virtual
110  float64
111  filter(
112  const float64 & x,
113  const float64 & frequency_Hz_low,
114  const float64 & frequency_Hz_high);
115 
116  void
117  makeKernel(
118  const float64 & frequency_Hz_low,
119  const float64 & frequency_Hz_high);
120 
121  void
122  plot(boolean show_fc = true, boolean show_phase = false);
123 
126  void
127  reset();
128 
129  protected:
130 
132 
134  struct Kernel
135  {
136  Kernel(const uint32 & f1, const uint32 & f2);
137 
138  bool operator<(const Kernel & rhs) const;
139 
141 
144  };
145 
146  typedef std::set<Kernel> KernelCache;
147 
149 
150  private:
151 
153  :
155  frequency_2_Hz_(0.0),
156  kernel_cache_(){};
157 
159  operator=(const FilterBandRejectFIR & rhs){return *this;};
160 
161 }; // class FilterBandRejectFIR
162 
163 } // namespace Nsound
164 
165 // :mode=c++: jEdit modeline
166 #endif
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
FilterBandRejectFIR(const FilterBandRejectFIR &copy)
A class to store calculated kernels.
FilterBandRejectFIR & operator=(const FilterBandRejectFIR &rhs)
Kernel(const uint32 &f1, const uint32 &f2)
double float64
Definition: Nsound.h:146
void makeKernel(const float64 &frequency_Hz_low, const float64 &frequency_Hz_high)
void plot(boolean show_fc=true, boolean show_phase=false)
A Buffer for storing audio samples.
Definition: Buffer.h:60
bool operator<(const Kernel &rhs) const
FilterBandRejectFIR(const float64 &sample_rate, uint32 kernel_size, const float64 &frequency_Hz_low, const float64 &frequency_Hz_high)
float64 sample_rate_
Definition: Filter.h:113