#include <Nsound/FilterHighPassFIR.h>

Definition at line 42 of file FilterHighPassFIR.h.
typedef std::set<Kernel> Nsound::FilterLowPassFIR::KernelCache [protected, inherited] |
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 143 of file FilterLowPassFIR.h.
| FilterHighPassFIR::FilterHighPassFIR | ( | const float64 & | sample_rate, | |
| uint32 | kernel_size, | |||
| const float64 & | cutoff_frequency_Hz | |||
| ) |
Definition at line 46 of file FilterHighPassFIR.cc.
References Nsound::FilterLowPassFIR::frequency_1_Hz_, and reset().
00051 : 00052 FilterLowPassFIR(sample_rate, kernel_size, cutoff_frequency_Hz), 00053 hp_cache_() 00054 { 00055 frequency_1_Hz_ = cutoff_frequency_Hz; 00056 FilterHighPassFIR::reset(); }
| FilterHighPassFIR::~FilterHighPassFIR | ( | ) | [virtual] |
Definition at line 60 of file FilterHighPassFIR.cc.
References hp_cache_.
| AudioStream FilterHighPassFIR::filter | ( | const AudioStream & | x | ) |
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 75 of file FilterHighPassFIR.cc.
Referenced by filter(), Nsound::FilterBandPassFIR::filter(), FilterHighPassFIR_UnitTest(), and main().
00076 { 00077 return Filter::filter(x); 00078 }
| AudioStream FilterHighPassFIR::filter | ( | const AudioStream & | x, | |
| const float64 & | frequency | |||
| ) |
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 83 of file FilterHighPassFIR.cc.
References filter().
00084 { 00085 return Filter::filter(x, f); 00086 }
| AudioStream FilterHighPassFIR::filter | ( | const AudioStream & | x, | |
| const Buffer & | frequencies | |||
| ) |
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 91 of file FilterHighPassFIR.cc.
References filter().
00092 { 00093 return Filter::filter(x, frequencies); 00094 }
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 99 of file FilterHighPassFIR.cc.
References filter().
00100 { 00101 return Filter::filter(x); 00102 }
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 107 of file FilterHighPassFIR.cc.
References Nsound::Buffer::begin(), Nsound::Buffer::end(), filter(), makeKernel(), and reset().
00108 { 00109 // Instead of calling Filter::filter(x,f), we implement this function here 00110 // to avoid calling makeKernel(f) for each sample. 00111 00112 FilterHighPassFIR::reset(); 00113 FilterHighPassFIR::makeKernel(f); 00114 00115 Buffer::const_iterator itor = x.begin(); 00116 Buffer::const_iterator end = x.end(); 00117 00118 Buffer y; 00119 while(itor != end) 00120 { 00121 y << FilterLowPassFIR::filter(*itor); 00122 ++itor; 00123 } 00124 00125 return y; 00126 }
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 131 of file FilterHighPassFIR.cc.
References filter().
00132 { 00133 return Filter::filter(x, frequencies); 00134 }
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 139 of file FilterHighPassFIR.cc.
References filter().
00140 { 00141 return FilterLowPassFIR::filter(x); 00142 }
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 147 of file FilterHighPassFIR.cc.
References filter(), and makeKernel().
00148 { 00149 FilterHighPassFIR::makeKernel(frequency_Hz); 00150 return FilterLowPassFIR::filter(x); 00151 }
| float64 Nsound::FilterHighPassFIR::getFrequency | ( | ) | const [inline] |
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 92 of file FilterHighPassFIR.h.
References Nsound::FilterLowPassFIR::frequency_1_Hz_.
Referenced by Nsound::FilterBandPassFIR::getFrequencyLow(), and Nsound::FilterBandPassFIR::plot().
00092 {return frequency_1_Hz_;};
| Buffer FilterHighPassFIR::getImpulseResponse | ( | ) |
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 156 of file FilterHighPassFIR.cc.
00157 { 00158 return Filter::getImpulseResponse(); 00159 }
| void FilterHighPassFIR::makeKernel | ( | const float64 & | frequency | ) |
Reimplemented from Nsound::FilterLowPassFIR.
Definition at line 164 of file FilterHighPassFIR.cc.
References Nsound::FilterLowPassFIR::Kernel::b_, Nsound::FilterLowPassFIR::b_, hp_cache_, Nsound::Filter::kernel_size_, Nsound::Filter::sample_rate_, and spectraReversal_().
Referenced by filter(), and reset().
00165 { 00166 // Here we create a key into the kernel cache. I'm only storing kernels 00167 // with freqs chopped off to the 10th Hz. So filtering with a kernel 00168 // designed at 440.1567 Hz will get stored as 440.1. Any other frequency 00169 // that starts at 440.1 will not get a kernel calculated and just use the 00170 // one in the cache. 00171 00172 FilterLowPassFIR::Kernel new_kernel( 00173 static_cast<uint32>(cutoff_frequency_Hz)); 00174 00175 // See if the kernel is in the cache. 00176 00177 FilterLowPassFIR:: 00178 KernelCache:: 00179 const_iterator itor = hp_cache_.find(new_kernel); 00180 00181 if(itor != hp_cache_.end()) 00182 { 00183 // The kernel was found in the cache. 00184 b_ = itor->b_; 00185 return; 00186 } 00187 00188 // The filter wasn't in the cache, need to make it. 00189 new_kernel.b_ = new float64[kernel_size_]; 00190 00191 if(cutoff_frequency_Hz < 0.10) 00192 { 00193 // Create All pass filter. 00194 new_kernel.b_[0] = 1.0; 00195 00196 b_ = new_kernel.b_; 00197 } 00198 else 00199 { 00200 float64 fc = sample_rate_ / 2.0 - cutoff_frequency_Hz; 00201 00202 FilterLowPassFIR::makeKernel(fc); 00203 00204 // Now b_ is pointing to a low pass kernel, copy it into new_kernel. 00205 memcpy(new_kernel.b_, b_, sizeof(float64) * kernel_size_); 00206 00207 // Point to new kernel. 00208 b_ = new_kernel.b_; 00209 00210 // Perform the spectra inversion on the kernel to turn it into a high 00211 // pass filter. 00212 spectraReversal_(); 00213 } 00214 00215 // Add the new kernel to the cache. 00216 hp_cache_.insert(new_kernel); 00217 }
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 222 of file FilterHighPassFIR.cc.
References Nsound::Plotter::axvline(), Nsound::FilterLowPassFIR::frequency_1_Hz_, Nsound::Filter::kernel_size_, Nsound::Filter::sample_rate_, Nsound::Plotter::subplot(), and Nsound::Plotter::title().
Referenced by main().
00225 { 00226 char title[128]; 00227 sprintf(title, 00228 "High Pass FIR Frequency Response\n" 00229 "order = %d, fc = %0.1f Hz, sr = %0.1f Hz", 00230 kernel_size_ - 1, frequency_1_Hz_, sample_rate_); 00231 00232 Filter::plot(show_phase); 00233 00234 Plotter pylab; 00235 00236 int32 topplot = 111; 00237 00238 if(show_phase) 00239 { 00240 topplot = 211; 00241 } 00242 00243 if(show_fc) 00244 { 00245 pylab.subplot(topplot); 00246 00247 pylab.axvline(frequency_1_Hz_,"color='red'"); 00248 00249 pylab.title(title); 00250 } 00251 00252 }
| void FilterHighPassFIR::reset | ( | ) | [virtual] |
Resets interal history buffer and sets the cut off frequency to the one used at declaration.
Reimplemented from Nsound::FilterLowPassFIR.
Reimplemented in Nsound::FilterBandRejectFIR.
Definition at line 257 of file FilterHighPassFIR.cc.
References Nsound::FilterLowPassFIR::frequency_1_Hz_, Nsound::Filter::kernel_size_, makeKernel(), Nsound::FilterLowPassFIR::x_history_, and Nsound::FilterLowPassFIR::x_ptr_.
Referenced by filter(), FilterHighPassFIR(), and Nsound::FilterBandPassFIR::reset().
00258 { 00259 // Don't call FilterLowPassFIR::reset(), if we did, we would be creating 00260 // a kernel twice. 00261 00262 memset(x_history_, 0, sizeof(float64) * (kernel_size_ + 1)); 00263 x_ptr_ = x_history_; 00264 00265 FilterHighPassFIR::makeKernel(frequency_1_Hz_); 00266 }
| void FilterHighPassFIR::spectraReversal_ | ( | ) | [protected] |
Definition at line 271 of file FilterHighPassFIR.cc.
References Nsound::FilterLowPassFIR::b_, and Nsound::Filter::kernel_size_.
Referenced by makeKernel().
00272 { 00273 for(uint32 i = 0; i < kernel_size_; ++i) 00274 { 00275 if(i % 2) 00276 { 00277 b_[i] *= -1.00; 00278 } 00279 } 00280 }
Reimplemented in Nsound::FilterIIR.
Definition at line 218 of file Filter.cc.
References Nsound::Filter::filter(), and Nsound::Filter::reset().
Referenced by Nsound::Filter::getFrequencyResponse(), and Nsound::Filter::getPhaseResponse().
| void Filter::plot | ( | boolean | show_phase = false |
) | [inherited] |
Definition at line 257 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().
00258 { 00259 Buffer x = getFrequencyAxis(); 00260 Buffer fr = getFrequencyResponse().getdB(); 00261 00262 Plotter pylab; 00263 00264 pylab.figure(); 00265 00266 int subplot_int = 111; 00267 00268 if(show_phase) 00269 { 00270 subplot_int = 211; 00271 } 00272 00273 pylab.subplot(subplot_int); 00274 00275 // Frequency response 00276 pylab.plot(x,fr, "blue"); 00277 00278 pylab.xlabel("Frequency (Hz)"); 00279 pylab.ylabel("Frequency Response (dB)"); 00280 00281 // Phase response 00282 if(show_phase) 00283 { 00284 pylab.subplot(subplot_int + 1); 00285 00286 Buffer pr = getPhaseResponse().getdB(); 00287 00288 pylab.plot(x,pr); 00289 00290 pylab.xlabel("Frequency (Hz)"); 00291 pylab.ylabel("Phase Response (dB)"); 00292 } 00293 00294 float64 ymax = fr.getMax(); 00295 float64 height = ymax - -60.0; 00296 00297 pylab.ylim(-60.0, ymax + 0.05 * height); 00298 00299 }
| void FilterLowPassFIR::setCutoff | ( | const float64 & | fc | ) | [inherited] |
Sets the cut off frequency (Hz).
Definition at line 379 of file FilterLowPassFIR.cc.
References Nsound::FilterLowPassFIR::frequency_1_Hz_, and Nsound::FilterLowPassFIR::reset().
00380 { 00381 frequency_1_Hz_ = fc; 00382 reset(); 00383 }
Definition at line 176 of file Filter.cc.
References Nsound::FFTransform::roundUp2(), and Nsound::Filter::sample_rate_.
Referenced by main(), Nsound::Filter::plot(), and Nsound::FilterIIR::savePlot().
00177 { 00178 uint32 fft_chunk_size = FFTransform::roundUp2( 00179 static_cast<int32>(n_fft)); 00180 00181 uint32 n_samples = fft_chunk_size / 2 + 1; 00182 00183 float64 f_step = (1.0 / (static_cast<float64>(fft_chunk_size) / 2.0)) 00184 * (sample_rate_ / 2.0); 00185 00186 Buffer f_axis; 00187 00188 float64 f = 0.0; 00189 00190 for(uint32 i = 0; i < n_samples; ++i) 00191 { 00192 f_axis << f; 00193 f += f_step; 00194 } 00195 00196 return f_axis; 00197 };
Definition at line 202 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().
00203 { 00204 FFTransform fft(sample_rate_); 00205 00206 //~ fft.setWindow(HANNING); 00207 00208 FFTChunkVector vec; 00209 00210 vec = fft.fft(getImpulseResponse(), n_fft); 00211 00212 return vec[0].getMagnitude(); 00213 }
| virtual uint32 Nsound::Filter::getKernelSize | ( | ) | const [inline, virtual, inherited] |
Reimplemented in Nsound::FilterIIR, and Nsound::FilterTone.
Definition at line 109 of file Filter.h.
References Nsound::Filter::kernel_size_.
Referenced by Nsound::FilterBandPassIIR::FilterBandPassIIR(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterBandPassIIR::plot(), and Nsound::FilterBandPassFIR::plot().
00109 {return kernel_size_;};
| Buffer Filter::getPhaseResponse | ( | ) | [inherited] |
Definition at line 239 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().
00240 { 00241 uint32 n_samples = static_cast<uint32>(sample_rate_ * 2); 00242 00243 FFTransform fft(n_samples); 00244 00245 FFTChunkVector vec; 00246 00247 vec = fft.fft(getImpulseResponse(), n_samples); 00248 00249 Buffer phase = vec[0].getPhase(); 00250 00251 return phase.subbuffer(0, phase.getLength() / 2 + 1); 00252 }
| float64 Nsound::Filter::getSampleRate | ( | ) | const [inline, inherited] |
Definition at line 117 of file Filter.h.
References Nsound::Filter::sample_rate_.
00117 { return sample_rate_; };
Definition at line 116 of file FilterHighPassFIR.h.
Referenced by makeKernel(), and ~FilterHighPassFIR().
float64* Nsound::FilterLowPassFIR::b_ [protected, inherited] |
Definition at line 121 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::filter(), Nsound::FilterLowPassFIR::makeKernel(), makeKernel(), Nsound::FilterBandRejectFIR::makeKernel(), and spectraReversal_().
float64* Nsound::FilterLowPassFIR::window_ [protected, inherited] |
Definition at line 122 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::FilterLowPassFIR(), Nsound::FilterLowPassFIR::makeKernel(), and Nsound::FilterLowPassFIR::~FilterLowPassFIR().
float64* Nsound::FilterLowPassFIR::x_history_ [protected, inherited] |
Definition at line 125 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::filter(), Nsound::FilterLowPassFIR::FilterLowPassFIR(), Nsound::FilterLowPassFIR::reset(), reset(), and Nsound::FilterLowPassFIR::~FilterLowPassFIR().
float64* Nsound::FilterLowPassFIR::x_ptr_ [protected, inherited] |
Definition at line 126 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::filter(), Nsound::FilterLowPassFIR::FilterLowPassFIR(), Nsound::FilterLowPassFIR::reset(), and reset().
float64* Nsound::FilterLowPassFIR::x_end_ptr_ [protected, inherited] |
Definition at line 127 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::filter(), and Nsound::FilterLowPassFIR::FilterLowPassFIR().
float64 Nsound::FilterLowPassFIR::frequency_1_Hz_ [protected, inherited] |
Definition at line 129 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterBandRejectFIR::FilterBandRejectFIR(), FilterHighPassFIR(), Nsound::FilterLowPassFIR::getFrequency(), getFrequency(), Nsound::FilterBandRejectFIR::getFrequencyLow(), Nsound::FilterLowPassFIR::plot(), plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterLowPassFIR::reset(), reset(), Nsound::FilterBandRejectFIR::reset(), and Nsound::FilterLowPassFIR::setCutoff().
KernelCache Nsound::FilterLowPassFIR::lp_cache_ [protected, inherited] |
Definition at line 145 of file FilterLowPassFIR.h.
Referenced by Nsound::FilterLowPassFIR::makeKernel(), and Nsound::FilterLowPassFIR::~FilterLowPassFIR().
float64 Nsound::Filter::sample_rate_ [protected, inherited] |
Definition at line 131 of file Filter.h.
Referenced by Nsound::FilterPhaser::filter(), Nsound::FilterDelay::filter(), Nsound::FilterCombLowPassFeedback::filter(), Nsound::FilterAllPass::FilterAllPass(), Nsound::FilterCombLowPassFeedback::FilterCombLowPassFeedback(), Nsound::FilterDelay::FilterDelay(), Nsound::FilterFlanger::FilterFlanger(), Nsound::FilterPhaser::FilterPhaser(), Nsound::FilterSlinky::FilterSlinky(), Nsound::Filter::getFrequencyAxis(), Nsound::Filter::getFrequencyResponse(), Nsound::Filter::getPhaseResponse(), Nsound::Filter::getSampleRate(), Nsound::FilterStageIIR::makeIIRKernelHelper(), Nsound::FilterStageIIR::makeKernel(), Nsound::FilterParametricEqualizer::makeKernel(), Nsound::FilterLeastSquaresFIR::makeKernel(), makeKernel(), Nsound::FilterBandPassVocoder::makeKernel(), Nsound::FilterPhaser::operator=(), Nsound::FilterLeastSquaresFIR::operator=(), Nsound::FilterIIR::operator=(), Nsound::FilterFlanger::operator=(), Nsound::FilterTone::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterParametricEqualizer::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterHighPassIIR::plot(), plot(), Nsound::FilterFlanger::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandPassIIR::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterLowPassIIR::setCutoff(), and Nsound::FilterLeastSquaresFIR::setWindow().
float64 Nsound::Filter::two_pi_over_sample_rate_ [protected, inherited] |
Definition at line 132 of file Filter.h.
Referenced by Nsound::FilterTone::makeKernel(), Nsound::FilterParametricEqualizer::makeKernel(), and Nsound::FilterLowPassFIR::makeKernel().
uint32 Nsound::Filter::kernel_size_ [protected, inherited] |
Definition at line 133 of file Filter.h.
Referenced by Nsound::FilterLowPassFIR::filter(), Nsound::FilterLeastSquaresFIR::filter(), Nsound::FilterBandPassFIR::FilterBandPassFIR(), Nsound::FilterBandPassIIR::FilterBandPassIIR(), Nsound::FilterBandRejectIIR::FilterBandRejectIIR(), Nsound::FilterHighPassIIR::FilterHighPassIIR(), Nsound::FilterLeastSquaresFIR::FilterLeastSquaresFIR(), Nsound::FilterLowPassFIR::FilterLowPassFIR(), Nsound::FilterLowPassIIR::FilterLowPassIIR(), Nsound::FilterLeastSquaresFIR::getKernel(), Nsound::Filter::getKernelSize(), Nsound::FilterLowPassFIR::makeKernel(), Nsound::FilterLeastSquaresFIR::makeKernel(), makeKernel(), Nsound::FilterBandRejectFIR::makeKernel(), Nsound::FilterLeastSquaresFIR::operator=(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterLowPassFIR::reset(), Nsound::FilterLeastSquaresFIR::reset(), reset(), Nsound::FilterLeastSquaresFIR::setKernel(), Nsound::FilterLeastSquaresFIR::setWindow(), and spectraReversal_().
1.6.3