Nsound  0.9.4
Public Member Functions | Protected Attributes | List of all members
Nsound::FilterFlanger Class Reference

A class for filtering audio in the frequecy domain. More...

#include <Nsound/FilterFlanger.h>

Inheritance diagram for Nsound::FilterFlanger:
Inheritance graph
[legend]

Public Member Functions

 FilterFlanger (const float64 &sample_rate, const float64 &frequency, const float64 &max_delay_time_seconds)
 
 FilterFlanger (const FilterFlanger &copy)
 
 ~FilterFlanger ()
 
AudioStream filter (const AudioStream &x)
 
AudioStream filter (const AudioStream &x, const float64 &frequency)
 
AudioStream filter (const AudioStream &x, const float64 &frequency, const float64 &delay)
 
AudioStream filter (const AudioStream &x, const Buffer &frequency, const Buffer &delay)
 
Buffer filter (const Buffer &x)
 
Buffer filter (const Buffer &x, const float64 &frequency)
 
Buffer filter (const Buffer &x, const float64 &frequency, const float64 &delay)
 
Buffer filter (const Buffer &x, const Buffer &frequency, const Buffer &delay)
 
float64 filter (const float64 &x)
 
float64 filter (const float64 &x, const float64 &frequency)
 
float64 filter (const float64 &x, const float64 &frequency, const float64 &delay)
 
FilterFlangeroperator= (const FilterFlanger &rhs)
 
void plot (boolean show_fc=false, boolean show_phase=false)
 
void reset ()
 
void setRealtime (bool flag)
 
AudioStream filter (const AudioStream &x, const Buffer &frequencies)
 
Buffer filter (const Buffer &x, const Buffer &frequencies)
 
Buffer getFrequencyAxis (const uint32 n_fft=8192)
 
Buffer getFrequencyResponse (const uint32 n_fft=8192)
 
Buffer getImpulseResponse (const uint32 n_samples=8192)
 
virtual uint32 getKernelSize () const
 
Buffer getPhaseResponse ()
 
float64 getSampleRate () const
 
void plot (boolean show_phase=false)
 

Protected Attributes

float64 frequency_
 
float64 max_delay_
 
FilterDelaydelay_
 
Generatorgen_
 
float64 sample_rate_
 
float64 two_pi_over_sample_rate_
 
float64 sample_time_
 
uint32 kernel_size_
 
bool is_realtime_
 

Detailed Description

A class for filtering audio in the frequecy domain.

Definition at line 49 of file FilterFlanger.h.

Constructor & Destructor Documentation

FilterFlanger::FilterFlanger ( const float64 sample_rate,
const float64 frequency,
const float64 max_delay_time_seconds 
)

Definition at line 51 of file FilterFlanger.cc.

References delay_, frequency_, gen_, Nsound::Generator::generate(), M_ASSERT_VALUE, max_delay_, and Nsound::Filter::sample_rate_.

55  :
56  Filter(sample_rate),
57  frequency_(frequency),
58  max_delay_(max_delay_time_seconds),
59  delay_(NULL),
60  gen_(NULL)
61 {
62  M_ASSERT_VALUE(frequency_, >, 0.0);
63  M_ASSERT_VALUE(max_delay_, >, 0.0);
64 
66 
67  Sine sin(sample_rate_);
68 
69  Buffer waveform = (1.0 + sin.generate(1.0, 1.0)) / 2.0;
70 
71  gen_ = new Generator(sample_rate_, waveform);
72 }
#define M_ASSERT_VALUE(a, op, value)
Definition: Macros.h:76
FilterDelay * delay_
Filter(const float64 &sample_rate)
Definition: Filter.cc:41
A Buffer for storing audio samples.
Definition: Buffer.h:60
A class for filtering audio in the frequecy domain.
Definition: FilterDelay.h:47
DOXME.
Definition: Sine.h:43
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50
float64 sample_rate_
Definition: Filter.h:113
FilterFlanger::FilterFlanger ( const FilterFlanger copy)

Definition at line 76 of file FilterFlanger.cc.

References delay_, gen_, Nsound::Generator::generate(), max_delay_, and Nsound::Filter::sample_rate_.

77  :
78  Filter(copy.sample_rate_),
79  frequency_(copy.frequency_),
80  max_delay_(copy.max_delay_),
81  delay_(NULL),
82  gen_(NULL)
83 {
85 
86  Sine sin(sample_rate_);
87 
88  Buffer waveform = (1.0 + sin.generate(1.0, 1.0)) / 2.0;
89 
90  gen_ = new Generator(sample_rate_, waveform);
91 
92  *this = copy;
93 }
FilterDelay * delay_
Filter(const float64 &sample_rate)
Definition: Filter.cc:41
A Buffer for storing audio samples.
Definition: Buffer.h:60
A class for filtering audio in the frequecy domain.
Definition: FilterDelay.h:47
DOXME.
Definition: Sine.h:43
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50
float64 sample_rate_
Definition: Filter.h:113
FilterFlanger::~FilterFlanger ( )

Definition at line 97 of file FilterFlanger.cc.

References delay_, and gen_.

98 {
99  delete delay_;
100  delete gen_;
101 }
FilterDelay * delay_

Member Function Documentation

AudioStream FilterFlanger::filter ( const AudioStream x)

Definition at line 105 of file FilterFlanger.cc.

References Nsound::Filter::filter().

Referenced by filter().

106 {
107  return Filter::filter(x);
108 }
AudioStream filter(const AudioStream &x)
Definition: Filter.cc:53
AudioStream FilterFlanger::filter ( const AudioStream x,
const float64 frequency 
)

Definition at line 112 of file FilterFlanger.cc.

References Nsound::Filter::filter().

113 {
114  return Filter::filter(x, frequency);
115 }
AudioStream filter(const AudioStream &x)
Definition: Filter.cc:53
AudioStream FilterFlanger::filter ( const AudioStream x,
const float64 frequency,
const float64 delay 
)

Definition at line 119 of file FilterFlanger.cc.

References filter(), Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().

123 {
124  uint32 n_channels = x.getNChannels();
125 
126  AudioStream y(x.getSampleRate(), n_channels);
127 
128  for(uint32 channel = 0; channel < n_channels; ++channel)
129  {
130  y[channel] = filter(x[channel], frequency, delay);
131  }
132 
133  return y;
134 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
float64 getSampleRate() const
Returns the sample rate of the stream.
Definition: AudioStream.h:217
uint32 getNChannels(void) const
Returns the number of audio channels in the stream.
Definition: AudioStream.h:212
AudioStream FilterFlanger::filter ( const AudioStream x,
const Buffer frequency,
const Buffer delay 
)

Definition at line 138 of file FilterFlanger.cc.

References filter(), Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().

142 {
143  uint32 n_channels = x.getNChannels();
144 
145  AudioStream y(x.getSampleRate(), n_channels);
146 
147  for(uint32 channel = 0; channel < n_channels; ++channel)
148  {
149  y[channel] = filter(x[channel], frequency, delay);
150  }
151 
152  return y;
153 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
float64 getSampleRate() const
Returns the sample rate of the stream.
Definition: AudioStream.h:217
uint32 getNChannels(void) const
Returns the number of audio channels in the stream.
Definition: AudioStream.h:212
Buffer FilterFlanger::filter ( const Buffer x)

Definition at line 157 of file FilterFlanger.cc.

References filter(), frequency_, Nsound::Buffer::getLength(), max_delay_, and reset().

158 {
159  reset();
160 
161  Buffer y(x.getLength());
162 
163  uint32 x_samples = x.getLength();
164 
165  for(uint32 i = 0; i < x_samples; ++i)
166  {
167  y << filter(x[i], frequency_, max_delay_);
168  }
169 
170  return y;
171 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer FilterFlanger::filter ( const Buffer x,
const float64 frequency 
)

Definition at line 175 of file FilterFlanger.cc.

References filter(), Nsound::Buffer::getLength(), max_delay_, and reset().

176 {
177  reset();
178 
179  Buffer y(x.getLength());
180 
181  uint32 x_samples = x.getLength();
182 
183  for(uint32 i = 0; i < x_samples; ++i)
184  {
185  y << filter(x[i], frequency, max_delay_);
186  }
187 
188  return y;
189 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer FilterFlanger::filter ( const Buffer x,
const float64 frequency,
const float64 delay 
)

Definition at line 193 of file FilterFlanger.cc.

References filter(), Nsound::Buffer::getLength(), and reset().

194 {
195  reset();
196 
197  Buffer y(x.getLength());
198 
199  uint32 x_samples = x.getLength();
200 
201  for(uint32 i = 0; i < x_samples; ++i)
202  {
203  y << filter(x[i], frequency, delay);
204  }
205 
206  return y;
207 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer FilterFlanger::filter ( const Buffer x,
const Buffer frequency,
const Buffer delay 
)

Definition at line 211 of file FilterFlanger.cc.

References Nsound::Buffer::cbegin(), filter(), Nsound::Buffer::getLength(), and reset().

212 {
213  reset();
214 
215  Buffer y(x.getLength());
216 
217  uint32 x_samples = x.getLength();
218 
219  Buffer::const_circular_iterator f = frequency.cbegin();
221 
222  for(uint32 i = 0; i < x_samples; ++i)
223  {
224  y << filter(x[i], *f, *d);
225  }
226 
227  return y;
228 }
unsigned int uint32
Definition: Nsound.h:153
AudioStream filter(const AudioStream &x)
circular_iterator cbegin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:318
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
A Buffer for storing audio samples.
Definition: Buffer.h:60
float64 FilterFlanger::filter ( const float64 x)
virtual

Implements Nsound::Filter.

Definition at line 232 of file FilterFlanger.cc.

References filter(), frequency_, and max_delay_.

233 {
234  return filter(x, frequency_, max_delay_);
235 
236 }
AudioStream filter(const AudioStream &x)
float64 FilterFlanger::filter ( const float64 x,
const float64 frequency 
)
virtual

Implements Nsound::Filter.

Definition at line 240 of file FilterFlanger.cc.

References filter(), and max_delay_.

241 {
242  return filter(x, frequency, max_delay_);
243 
244 }
AudioStream filter(const AudioStream &x)
float64 FilterFlanger::filter ( const float64 x,
const float64 frequency,
const float64 delay 
)

Definition at line 248 of file FilterFlanger.cc.

References delay_, Nsound::FilterDelay::filter(), gen_, and Nsound::Generator::generate().

249 {
250  float64 f = gen_->generate(frequency);
251 
252  float64 y = delay_->filter(x, f*delay);
253 
254  return (y+x) / 2.0;
255 }
FilterDelay * delay_
double float64
Definition: Nsound.h:146
AudioStream filter(const AudioStream &x)
Definition: FilterDelay.cc:98
virtual float64 generate(const float64 &frequency)
This is a real-time method for the wavetable oscillator.
Definition: Generator.cc:972
FilterFlanger & FilterFlanger::operator= ( const FilterFlanger rhs)

Definition at line 260 of file FilterFlanger.cc.

References delay_, frequency_, gen_, max_delay_, reset(), and Nsound::Filter::sample_rate_.

261 {
262  if(this == &rhs)
263  {
264  return *this;
265  }
266 
268  frequency_ = rhs.frequency_;
269  max_delay_ = rhs.max_delay_;
270  *delay_ = *rhs.delay_;
271  *gen_ = *rhs.gen_;
272 
273  reset();
274 
275  return *this;
276 }
FilterDelay * delay_
float64 sample_rate_
Definition: Filter.h:113
void FilterFlanger::plot ( boolean  show_fc = false,
boolean  show_phase = false 
)

Definition at line 280 of file FilterFlanger.cc.

References frequency_, max_delay_, Nsound::Filter::plot(), Nsound::Filter::sample_rate_, Nsound::Plotter::subplot(), and Nsound::Plotter::title().

281 {
282  char title[128];
283  sprintf(title,
284  "Flanger Frequency Response\n"
285  "sr = %0.1f Hz, f = %0.1f Hz, delay = %0.3f ms",
286  sample_rate_,
287  frequency_,
288  max_delay_ * 1000.0);
289 
290  Filter::plot(show_phase);
291 
292  Plotter pylab;
293 
294  uint32 n_rows = 1;
295 
296  if(show_phase)
297  {
298  n_rows = 2;
299  }
300 
301  if(show_fc)
302  {
303  pylab.subplot(n_rows, 1, 1);
304  }
305 
306  pylab.title(title);
307 }
unsigned int uint32
Definition: Nsound.h:153
void title(const std::string &title, const std::string &kwargs="")
Add a title to the plot at the top and centered.
Definition: Plotter.cc:1127
Axes subplot(const uint32 n_rows, const uint32 n_cols, const uint32 n, const std::string &kwargs="", Axes *sharex=NULL, Axes *sharey=NULL)
Creates a figure in a subplot, subplot(A, B, C, **kwargs)
Definition: Plotter.cc:1031
void plot(boolean show_phase=false)
Definition: Filter.cc:262
float64 sample_rate_
Definition: Filter.h:113
void FilterFlanger::reset ( )
virtual

Implements Nsound::Filter.

Definition at line 311 of file FilterFlanger.cc.

References delay_, gen_, Nsound::FilterDelay::reset(), and Nsound::Generator::reset().

Referenced by filter(), and operator=().

312 {
313  delay_->reset();
314  gen_->reset();
315 }
FilterDelay * delay_
virtual void reset()
Resets the position pointer back to the begging of the waveform.
Definition: Generator.cc:1272
void Nsound::Filter::setRealtime ( bool  flag)
inlineinherited

Definition at line 57 of file Filter.h.

References Nsound::Filter::is_realtime_.

57 {is_realtime_ = flag;}
bool is_realtime_
Definition: Filter.h:118
AudioStream Filter::filter ( const AudioStream x,
const Buffer frequencies 
)
inherited

Definition at line 99 of file Filter.cc.

References Nsound::Filter::filter(), Nsound::AudioStream::getNChannels(), Nsound::AudioStream::getSampleRate(), Nsound::Filter::is_realtime_, M_THROW, and Nsound::Filter::reset().

100 {
101  if(!is_realtime_) reset();
102 
103  uint32 n_channels = x.getNChannels();
104 
105  if(is_realtime_ && n_channels > 1)
106  {
107  M_THROW("In real-time mode, a filter per audio channel must be used!");
108  }
109 
110  AudioStream y(x.getSampleRate(), n_channels);
111 
112  for(uint32 channel = 0; channel < n_channels; ++channel)
113  {
114  y[channel] = filter(x[channel], frequency);
115  }
116 
117  return y;
118 }
unsigned int uint32
Definition: Nsound.h:153
float64 getSampleRate() const
Returns the sample rate of the stream.
Definition: AudioStream.h:217
virtual void reset()=0
uint32 getNChannels(void) const
Returns the number of audio channels in the stream.
Definition: AudioStream.h:212
AudioStream filter(const AudioStream &x)
Definition: Filter.cc:53
#define M_THROW(message)
Definition: Macros.h:108
bool is_realtime_
Definition: Filter.h:118
Buffer Filter::filter ( const Buffer x,
const Buffer frequencies 
)
inherited

Definition at line 161 of file Filter.cc.

References Nsound::Buffer::begin(), Nsound::Buffer::cbegin(), Nsound::Buffer::end(), Nsound::Filter::filter(), Nsound::Buffer::getLength(), Nsound::Filter::is_realtime_, and Nsound::Filter::reset().

162 {
163  if(!is_realtime_) reset();
164 
165  Buffer::const_circular_iterator freq = frequencies.cbegin();
166 
167  Buffer::const_iterator itor = x.begin();
168  Buffer::const_iterator end = x.end();
169 
170  Buffer y(x.getLength());
171 
172  while(itor != end)
173  {
174  y << filter(*itor, *freq);
175 
176  ++itor;
177  ++freq;
178  }
179 
180  return y;
181 }
circular_iterator cbegin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:318
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
virtual void reset()=0
iterator end()
Retruns the itreator at the end of the Buffer.
Definition: Buffer.h:348
FloatVector::const_iterator const_iterator
Definition: Buffer.h:70
iterator begin()
Retruns the itreator at the start of the Buffer.
Definition: Buffer.h:285
AudioStream filter(const AudioStream &x)
Definition: Filter.cc:53
bool is_realtime_
Definition: Filter.h:118
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer Filter::getFrequencyAxis ( const uint32  n_fft = 8192)
inherited

Definition at line 185 of file Filter.cc.

References Nsound::FFTransform::roundUp2(), and Nsound::Filter::sample_rate_.

Referenced by main(), Nsound::Filter::plot(), and Nsound::FilterIIR::savePlot().

186 {
187  uint32 fft_chunk_size = FFTransform::roundUp2(
188  static_cast<int32>(n_fft));
189 
190  uint32 n_samples = fft_chunk_size / 2 + 1;
191 
192  float64 f_step = (1.0 / (static_cast<float64>(fft_chunk_size) / 2.0))
193  * (sample_rate_ / 2.0);
194 
195  Buffer f_axis;
196 
197  float64 f = 0.0;
198 
199  for(uint32 i = 0; i < n_samples; ++i)
200  {
201  f_axis << f;
202  f += f_step;
203  }
204 
205  return f_axis;
206 };
unsigned int uint32
Definition: Nsound.h:153
double float64
Definition: Nsound.h:146
static int32 roundUp2(int32 raw)
Returns nearest power of 2 >= raw.
Definition: FFTransform.cc:274
A Buffer for storing audio samples.
Definition: Buffer.h:60
float64 sample_rate_
Definition: Filter.h:113
Buffer Filter::getFrequencyResponse ( const uint32  n_fft = 8192)
inherited

Definition at line 210 of file Filter.cc.

References Nsound::FFTransform::fft(), Nsound::Filter::getImpulseResponse(), and Nsound::Filter::sample_rate_.

Referenced by Nsound::FilterBandPassIIR::FilterBandPassIIR(), FilterLeastSquaresFIR_UnitTest(), Nsound::FilterIIR::getRMS(), main(), Nsound::Filter::plot(), and Nsound::FilterIIR::savePlot().

211 {
213 
214 //~ fft.setWindow(HANNING);
215 
216  FFTChunkVector vec;
217 
218  vec = fft.fft(getImpulseResponse(), n_fft);
219 
220  return vec[0].getMagnitude();
221 }
Buffer getImpulseResponse(const uint32 n_samples=8192)
Definition: Filter.cc:225
A Class that performes the Fast Fouier Transfrom on a Buffer.
Definition: FFTransform.h:57
std::vector< FFTChunk > FFTChunkVector
Definition: FFTChunk.h:119
float64 sample_rate_
Definition: Filter.h:113
Buffer Filter::getImpulseResponse ( const uint32  n_samples = 8192)
inherited

Definition at line 225 of file Filter.cc.

References Nsound::Filter::filter(), Nsound::Filter::is_realtime_, and Nsound::Filter::reset().

Referenced by Nsound::Filter::getFrequencyResponse(), Nsound::FilterHighPassFIR::getImpulseResponse(), Nsound::FilterLowPassFIR::getImpulseResponse(), Nsound::FilterLeastSquaresFIR::getImpulseResponse(), Nsound::FilterIIR::getImpulseResponse(), and Nsound::Filter::getPhaseResponse().

226 {
227  if(!is_realtime_) reset();
228 
229  Buffer response(n_samples);
230 
231  response << filter(1.0);
232 
233  for(uint32 i = 1; i < n_samples; ++i)
234  {
235  response << filter(0.0);
236  }
237 
238  if(!is_realtime_) reset();
239 
240  return response;
241 }
unsigned int uint32
Definition: Nsound.h:153
virtual void reset()=0
AudioStream filter(const AudioStream &x)
Definition: Filter.cc:53
bool is_realtime_
Definition: Filter.h:118
A Buffer for storing audio samples.
Definition: Buffer.h:60
virtual uint32 Nsound::Filter::getKernelSize ( ) const
inlinevirtualinherited
Buffer Filter::getPhaseResponse ( )
inherited

Definition at line 245 of file Filter.cc.

References Nsound::FFTransform::fft(), Nsound::Filter::getImpulseResponse(), Nsound::Buffer::getLength(), Nsound::Filter::sample_rate_, and Nsound::Buffer::subbuffer().

Referenced by Nsound::Filter::plot().

246 {
247  uint32 n_samples = static_cast<uint32>(sample_rate_ * 2);
248 
249  FFTransform fft(n_samples);
250 
251  FFTChunkVector vec;
252 
253  vec = fft.fft(getImpulseResponse(), n_samples);
254 
255  Buffer phase = vec[0].getPhase();
256 
257  return phase.subbuffer(0, phase.getLength() / 2 + 1);
258 }
Buffer subbuffer(uint32 start_index, uint32 n_samples=0) const
Slice the Buffer.
Definition: Buffer.cc:2073
unsigned int uint32
Definition: Nsound.h:153
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
Buffer getImpulseResponse(const uint32 n_samples=8192)
Definition: Filter.cc:225
A Class that performes the Fast Fouier Transfrom on a Buffer.
Definition: FFTransform.h:57
A Buffer for storing audio samples.
Definition: Buffer.h:60
std::vector< FFTChunk > FFTChunkVector
Definition: FFTChunk.h:119
float64 sample_rate_
Definition: Filter.h:113
float64 Nsound::Filter::getSampleRate ( ) const
inlineinherited

Definition at line 102 of file Filter.h.

References Nsound::Filter::sample_rate_.

102 { return sample_rate_; };
float64 sample_rate_
Definition: Filter.h:113
void Filter::plot ( boolean  show_phase = false)
inherited

Definition at line 262 of file Filter.cc.

References Nsound::Plotter::figure(), Nsound::Buffer::getdB(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Buffer::getMax(), Nsound::Filter::getPhaseResponse(), Nsound::Plotter::plot(), Nsound::Plotter::subplot(), Nsound::Plotter::xlabel(), Nsound::Plotter::ylabel(), and Nsound::Plotter::ylim().

Referenced by main(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterBandPassVocoder::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterBandPassIIR::plot(), and Nsound::FilterParametricEqualizer::plot().

263 {
264  Buffer x = getFrequencyAxis();
266 
267  Plotter pylab;
268 
269  pylab.figure();
270 
271  uint32 n_rows = 1;
272  uint32 n_cols = 1;
273 
274  if(show_phase)
275  {
276  n_rows = 2;
277  }
278 
279  pylab.subplot(n_rows, n_cols, 1);
280 
281  // Frequency response
282  pylab.plot(x,fr, "blue");
283 
284  pylab.xlabel("Frequency (Hz)");
285  pylab.ylabel("Frequency Response (dB)");
286 
287  // Phase response
288  if(show_phase)
289  {
290  pylab.subplot(n_rows, n_cols, 2);
291 
292  Buffer pr = getPhaseResponse().getdB();
293 
294  pylab.plot(x,pr);
295 
296  pylab.xlabel("Frequency (Hz)");
297  pylab.ylabel("Phase Response (dB)");
298  }
299 
300  float64 ymax = fr.getMax();
301  float64 height = ymax - -60.0;
302 
303  pylab.ylim(-60.0, ymax + 0.05 * height);
304 }
unsigned int uint32
Definition: Nsound.h:153
void xlabel(const std::string &label, const std::string &kwargs="")
Add a label x axis.
Definition: Plotter.cc:1154
void plot(const Buffer &y, const std::string &fmt="", const std::string &kwargs="")
Plots the Buffer on the current figure.
Definition: Plotter.cc:765
void figure(const std::string &kwargs="") const
Creates a new figure window to plot in.
Definition: Plotter.cc:455
Buffer getPhaseResponse()
Definition: Filter.cc:245
double float64
Definition: Nsound.h:146
Axes subplot(const uint32 n_rows, const uint32 n_cols, const uint32 n, const std::string &kwargs="", Axes *sharex=NULL, Axes *sharey=NULL)
Creates a figure in a subplot, subplot(A, B, C, **kwargs)
Definition: Plotter.cc:1031
void ylim(const float64 &ymin, const float64 &ymax)
Definition: Plotter.cc:422
Buffer getFrequencyAxis(const uint32 n_fft=8192)
Definition: Filter.cc:185
void ylabel(const std::string &label, const std::string &kwargs="")
Add a label y axis.
Definition: Plotter.cc:1180
A Buffer for storing audio samples.
Definition: Buffer.h:60
Buffer getFrequencyResponse(const uint32 n_fft=8192)
Definition: Filter.cc:210
float64 getMax() const
Returns the maximum sample value in the Buffer.
Definition: Buffer.cc:951
Buffer getdB() const
Returns the Buffer in dB.
Definition: Buffer.h:487

Member Data Documentation

float64 Nsound::FilterFlanger::frequency_
protected

Definition at line 127 of file FilterFlanger.h.

Referenced by filter(), FilterFlanger(), operator=(), and plot().

float64 Nsound::FilterFlanger::max_delay_
protected

Definition at line 128 of file FilterFlanger.h.

Referenced by filter(), FilterFlanger(), operator=(), and plot().

FilterDelay* Nsound::FilterFlanger::delay_
protected

Definition at line 129 of file FilterFlanger.h.

Referenced by filter(), FilterFlanger(), operator=(), reset(), and ~FilterFlanger().

Generator* Nsound::FilterFlanger::gen_
protected

Definition at line 130 of file FilterFlanger.h.

Referenced by filter(), FilterFlanger(), operator=(), reset(), and ~FilterFlanger().

float64 Nsound::Filter::sample_rate_
protectedinherited

Definition at line 113 of file Filter.h.

Referenced by Nsound::FilterPhaser::filter(), Nsound::FilterCombLowPassFeedback::filter(), Nsound::FilterDelay::filter(), Nsound::FilterAllPass::FilterAllPass(), Nsound::FilterCombLowPassFeedback::FilterCombLowPassFeedback(), Nsound::FilterDelay::FilterDelay(), FilterFlanger(), Nsound::FilterPhaser::FilterPhaser(), Nsound::FilterSlinky::FilterSlinky(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Filter::getPhaseResponse(), Nsound::Filter::getSampleRate(), Nsound::FilterStageIIR::makeIIRKernelHelper(), Nsound::FilterHighPassFIR::makeKernel(), Nsound::FilterStageIIR::makeKernel(), Nsound::FilterBandPassVocoder::makeKernel(), Nsound::FilterLeastSquaresFIR::makeKernel(), Nsound::FilterParametricEqualizer::makeKernel(), Nsound::FilterPhaser::operator=(), Nsound::FilterLeastSquaresFIR::operator=(), operator=(), Nsound::FilterIIR::operator=(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandPassIIR::plot(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterParametricEqualizer::plot(), Nsound::FilterLowPassIIR::setCutoff(), and Nsound::FilterLeastSquaresFIR::setWindow().

float64 Nsound::Filter::two_pi_over_sample_rate_
protectedinherited
float64 Nsound::Filter::sample_time_
protectedinherited

Definition at line 115 of file Filter.h.

Referenced by Nsound::FilterLowPassMoogVcf::_make_filter().

uint32 Nsound::Filter::kernel_size_
protectedinherited
bool Nsound::Filter::is_realtime_
protectedinherited

The documentation for this class was generated from the following files: