FilterGen  1.0.0
A library to design digital filters in embedded systems.
dh::filter Class Reference

This class holds the C++ bindings to the filter library. More...

#include <dh/cpp/filter.hpp>

Classes

class  error
 
struct  graph_point
 
class  span
 

Public Types

using parameters_t = dh_filter_parameters
 

Public Member Functions

 filter (parameters_t options)
 Constructs a filter with the given options. More...
 
 filter (const filter &)
 Deep copy.
 
filteroperator= (const filter &)
 Deep copy.
 
 filter (filter &&)
 Move constructor. More...
 
filteroperator= (filter &&)
 Move assignment. More...
 
double update (double in)
 Updates the internal state of the filter with a new input value and returns the updated filtered value. More...
 
double current_value () const noexcept
 Returns the filtered value without changing the state of the filter. More...
 
const parameters_toptions () const
 
void set_gain (double gain)
 
double gain () const
 
std::vector< dh_frequency_response_tcompute_frequency_response (size_t count) const
 Computes the frequency response of the filter and returns a vector with count entries. More...
 
std::vector< graph_pointcompute_step_response () const
 Computes the step response of the filter. More...
 
std::vector< graph_pointcompute_impulse_response () const
 Computes the impulse response of the filter. More...
 
bool good () const noexcept
 
span feedforward_coefficients () const noexcept
 
span feedback_coefficients () const noexcept
 

Detailed Description

This class holds the C++ bindings to the filter library.

Simply construct it with given options and you are ready to use your filter. If an error occurs, an exception will be thrown. This should either happen if the given parameters are invalid, you are out of memory or if the filter structure was moved from.

Exceptions
dh::filter::errorin case something goes wrong.

Member Typedef Documentation

◆ parameters_t

Typedef to the parameter structure

Constructor & Destructor Documentation

◆ filter() [1/2]

dh::filter::filter ( parameters_t  options)

Constructs a filter with the given options.

Exceptions
dh::filter::errorin case something goes wrong.
See also
dh_filter_parameters

◆ filter() [2/2]

dh::filter::filter ( filter &&  )

Move constructor.

Warning
The other filter object becomes invalid and can no longer be used.

Member Function Documentation

◆ compute_frequency_response()

std::vector<dh_frequency_response_t> dh::filter::compute_frequency_response ( size_t  count) const

Computes the frequency response of the filter and returns a vector with count entries.

The response is computed in the range of [0,sampling_frequency/2]. The distance between the entries will be half of sampling_frequency/count.

Parameters
[in]countNumber values to compute
Returns
Frequency response curve.

◆ compute_impulse_response()

std::vector<graph_point> dh::filter::compute_impulse_response ( ) const

Computes the impulse response of the filter.

The response is computed in the range of [-10,2*number of feedforward coefficients].

◆ compute_step_response()

std::vector<graph_point> dh::filter::compute_step_response ( ) const

Computes the step response of the filter.

The response is computed in the range of [-10,2*number of feedforward coefficients].

◆ current_value()

double dh::filter::current_value ( ) const
inlinenoexcept

Returns the filtered value without changing the state of the filter.

Returns
The last output of update().

◆ feedback_coefficients()

span dh::filter::feedback_coefficients ( ) const
noexcept

Returns a range of the output coefficients.

Note
May return an empty range!

◆ feedforward_coefficients()

span dh::filter::feedforward_coefficients ( ) const
noexcept

Returns a range of the input coefficients of the filter.

Note
May return an empty range!

◆ gain()

double dh::filter::gain ( ) const

Gets the current gain of the filter.

◆ good()

bool dh::filter::good ( ) const
noexcept

checks if the filter is usable. (False if object was moved from)

◆ operator=()

filter& dh::filter::operator= ( filter &&  )

Move assignment.

Warning
The other filter object becomes invalid and can no longer be used.

◆ options()

const parameters_t& dh::filter::options ( ) const
inline

Returns the configuration of the filter.

◆ set_gain()

void dh::filter::set_gain ( double  gain)

Sets the current gain of the filter.

Parameters
[in]gainThe desired gain.

◆ update()

double dh::filter::update ( double  in)

Updates the internal state of the filter with a new input value and returns the updated filtered value.

Parameters
[in]inThe next input value.
Returns
The current output value of the filter.

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