Nsound  0.9.4
FilterTone.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: FilterTone.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_TONE_H_
34 #define _NSOUND_FILTER_TONE_H_
35 
36 #include <Nsound/Filter.h>
37 
38 #include <set>
39 
40 namespace Nsound
41 {
42 
43 class AudioStream;
44 class Buffer;
45 
46 //-----------------------------------------------------------------------------
47 class FilterTone : public Filter
48 {
49  public:
50 
51  FilterTone(
52  const float64 & sample_rate,
53  const float64 & half_power_frequency);
54 
55  virtual ~FilterTone();
56 
58  filter(const AudioStream & x);
59 
61  filter(const AudioStream & x, const Buffer & hp_frequencies);
62 
63  Buffer
64  filter(const Buffer & x);
65 
66  Buffer
67  filter(const Buffer & x, const Buffer & hp_frequencies);
68 
69  float64
70  filter(const float64 & x);
71 
72  float64
73  filter(const float64 & x, const float64 & hp_frequency);
74 
75  float64
76  getFrequency() const {return hp_frequency_;};
77 
78  uint32
79  getKernelSize() const { return 2; };
80 
81  void
82  plot(boolean show_fc = true, boolean show_phase = false);
83 
86  void
87  reset();
88 
89  void
90  makeKernel(const float64 & half_power_frequency);
91 
92  protected:
93 
98 
100  struct Kernel
101  {
102  Kernel(const uint32 & frequency);
103 
104  bool operator<(const Kernel & rhs) const;
105 
108 
110  };
111 
112  typedef std::set<Kernel> KernelCache;
113 
115 };
116 
117 }; // Nsound
118 
119 // :mode=c++: jEdit modeline
120 
121 #endif
unsigned int uint32
Definition: Nsound.h:153
Kernel(const uint32 &frequency)
Definition: FilterTone.cc:183
void makeKernel(const float64 &half_power_frequency)
Definition: FilterTone.cc:111
FilterTone(const float64 &sample_rate, const float64 &half_power_frequency)
Definition: FilterTone.cc:42
double float64
Definition: Nsound.h:146
float64 getFrequency() const
Definition: FilterTone.h:76
bool operator<(const Kernel &rhs) const
Definition: FilterTone.cc:194
Base class for IIR Filters, defines the interface.
Definition: Filter.h:49
std::set< Kernel > KernelCache
Definition: FilterTone.h:112
KernelCache kernel_cache_
Definition: FilterTone.h:114
void plot(boolean show_fc=true, boolean show_phase=false)
Definition: FilterTone.cc:142
A Buffer for storing audio samples.
Definition: Buffer.h:60
AudioStream filter(const AudioStream &x)
Definition: FilterTone.cc:63
virtual ~FilterTone()
Definition: FilterTone.cc:56
A class to store calculated kernels.
Definition: FilterTone.h:100
uint32 getKernelSize() const
Definition: FilterTone.h:79
float64 last_output_
Definition: FilterTone.h:97
float64 hp_frequency_
Definition: FilterTone.h:94