Mozzi  version v2.0
sound synthesis library for Arduino
MultiResonantFilter< su > Class Template Reference

A generic filter for audio signals that can produce lowpass, highpass, bandpass and notch outputs at runtime. More...

#include <ResonantFilter.h>

+ Inheritance diagram for MultiResonantFilter< su >:

Detailed Description

template<typename su = uint8_t>
class MultiResonantFilter< su >

A generic filter for audio signals that can produce lowpass, highpass, bandpass and notch outputs at runtime.

Behaves like ResonantFilter for setting the resonance and cutoff frequency. Like ResonantFilter, it can be used on different sample sizes: MultiResonantFilter<uint8_t> and MultiResonantFilter<uint16_t> have been tested. For the former, both cutoff and resonance are uint8_t, hence between 0-255. For the later, both cutoff and resonance are uint16_t, hence between 0-65535.

Definition at line 184 of file ResonantFilter.h.

Public Member Functions

void next (AudioOutputStorage_t in)
 Compute the filters, given an input signal. More...
 
AudioOutputStorage_t low ()
 Return the input filtered with a lowpass filter. More...
 
AudioOutputStorage_t high ()
 Return the input filtered with a highpass filter. More...
 
AudioOutputStorage_t band ()
 Return the input filtered with a bandpass filter. More...
 
AudioOutputStorage_t notch ()
 Return the input filtered with a notch filter. More...
 
void setCutoffFreq (uint8_t cutoff)
 deprecated. More...
 
void setResonance (uint8_t resonance)
 deprecated. More...
 
void setCutoffFreqAndResonance (uint8_t cutoff, uint8_t resonance)
 Set the cut off frequency and resonance. More...
 

Protected Member Functions

void advanceBuffers (AudioOutputStorage_t in)
 
AudioOutputStorage_t current (AudioOutputStorage_t in, Int2Type< LOWPASS >)
 
AudioOutputStorage_t current (AudioOutputStorage_t in, Int2Type< HIGHPASS >)
 
AudioOutputStorage_t current (AudioOutputStorage_t in, Int2Type< BANDPASS >)
 
AudioOutputStorage_t current (AudioOutputStorage_t in, Int2Type< NOTCH >)
 
IntegerType< sizeof(uint8_t)+sizeof(uint8_t)>::unsigned_type ucfxmul (uint8_t a, typename IntegerType< sizeof(uint8_t)+sizeof(uint8_t)>::unsigned_type b)
 
IntegerType< sizeof(AudioOutputStorage_t)+sizeof(uint8_t) -1 >::signed_type ifxmul (typename IntegerType< sizeof(AudioOutputStorage_t)+sizeof(uint8_t) -1 >::signed_type a, uint8_t b)
 
IntegerType< sizeof(AudioOutputStorage_t)+sizeof(AudioOutputStorage_t)>::signed_type fxmul (typename IntegerType< sizeof(AudioOutputStorage_t)+sizeof(AudioOutputStorage_t)>::signed_type a, typename IntegerType< sizeof(AudioOutputStorage_t)+sizeof(uint8_t) -1 >::signed_type b)
 

Protected Attributes

uint8_t q
 
uint8_t f
 
IntegerType< sizeof(uint8_t)+sizeof(uint8_t)>::unsigned_type fb
 
AudioOutputStorage_t buf0
 
AudioOutputStorage_t buf1
 
const uint8_t FX_SHIFT
 
const uint8_t FX_SHIFT_M_1
 
const uint8_t SHIFTED_1
 

Member Function Documentation

◆ band()

template<typename su = uint8_t>
AudioOutputStorage_t MultiResonantFilter< su >::band ( )
inline

Return the input filtered with a bandpass filter.

Returns
the filtered signal output.

Definition at line 206 of file ResonantFilter.h.

◆ high()

template<typename su = uint8_t>
AudioOutputStorage_t MultiResonantFilter< su >::high ( )
inline

Return the input filtered with a highpass filter.

Returns
the filtered signal output.

Definition at line 202 of file ResonantFilter.h.

◆ low()

template<typename su = uint8_t>
AudioOutputStorage_t MultiResonantFilter< su >::low ( )
inline

Return the input filtered with a lowpass filter.

Returns
the filtered signal output.

Definition at line 198 of file ResonantFilter.h.

◆ next()

template<typename su = uint8_t>
void MultiResonantFilter< su >::next ( AudioOutputStorage_t  in)
inline

Compute the filters, given an input signal.

Parameters
inthe signal input. Should not be more than 8bits on 8bits platforms (Arduino) if using the 8bits version and not 16bits version.

Definition at line 190 of file ResonantFilter.h.

◆ notch()

template<typename su = uint8_t>
AudioOutputStorage_t MultiResonantFilter< su >::notch ( )
inline

Return the input filtered with a notch filter.

Returns
the filtered signal output.

Definition at line 210 of file ResonantFilter.h.

◆ setCutoffFreq()

void ResonantFilter< FILTER_TYPE, uint8_t >::setCutoffFreq ( uint8_t  cutoff)
inlineinherited

deprecated.

Use setCutoffFreqAndResonance(su cutoff, su resonance).

Set the cut off frequency,

Parameters
cutoffuse the range 0-255 to represent 0-8191 Hz (MOZZI_AUDIO_RATE/2) for ResonantFilter, cutoff use the range 0-65535 to represent 0-MOZZI_AUDIO_RATE/2. Be careful of distortion at the lower end, especially with high resonance.

Definition at line 91 of file ResonantFilter.h.

◆ setCutoffFreqAndResonance()

void ResonantFilter< FILTER_TYPE, uint8_t >::setCutoffFreqAndResonance ( uint8_t  cutoff,
uint8_t  resonance 
)
inlineinherited

Set the cut off frequency and resonance.

Replaces setCutoffFreq() and setResonance(). (Because the internal calculations need to be done whenever either parameter changes.)

Parameters
cutoffrange 0-255 represents 0-8191 Hz (MOZZI_AUDIO_RATE/2) for ResonantFilter, range 0-65535 for ResonantFilter16 Be careful of distortion at the lower end, especially with high resonance.
resonancerange 0-255 for ResonantFilter, 0-65535 for ResonantFilter<FILTER_TYPE, uint16_t>, 255/65535 is most resonant.

Definition at line 114 of file ResonantFilter.h.

◆ setResonance()

void ResonantFilter< FILTER_TYPE, uint8_t >::setResonance ( uint8_t  resonance)
inlineinherited

deprecated.

Use setCutoffFreqAndResonance(su cutoff, su resonance).

Set the resonance. If you hear unwanted distortion, back off the resonance. After setting resonance, you need to call setCuttoffFreq() to hear the change!

Parameters
resonancein the range 0-255 for ResonantFilter, 0-65535 for ResonantFilter<FILTER_TYPE, uint16_t>, with 255/65535 being most resonant
Note
Remember to call setCuttoffFreq() after resonance is changed!

Definition at line 105 of file ResonantFilter.h.