Mozzi  version v1.1.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 >:

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 (su cutoff)
 deprecated. More...
 
void setResonance (su resonance)
 deprecated. More...
 
void setCutoffFreqAndResonance (su cutoff, su 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(su)+sizeof(su)>::unsigned_type ucfxmul (su a, typename IntegerType< sizeof(su)+sizeof(su)>::unsigned_type b)
 
IntegerType< sizeof(AudioOutputStorage_t)+sizeof(su) -1 >::signed_type ifxmul (typename IntegerType< sizeof(AudioOutputStorage_t)+sizeof(su) -1 >::signed_type a, su 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(su) -1 >::signed_type b)
 

Protected Attributes

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

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 185 of file ResonantFilter.h.

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 207 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 203 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 199 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 191 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 211 of file ResonantFilter.h.

◆ setCutoffFreq()

void ResonantFilter< FILTER_TYPE, su >::setCutoffFreq ( su  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 (AUDIO_RATE/2) for ResonantFilter, cutoff use the range 0-65535 to represent 0-AUDIO_RATE/2. Be careful of distortion at the lower end, especially with high resonance.

Definition at line 92 of file ResonantFilter.h.

◆ setCutoffFreqAndResonance()

void ResonantFilter< FILTER_TYPE, su >::setCutoffFreqAndResonance ( su  cutoff,
su  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 (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 115 of file ResonantFilter.h.

◆ setResonance()

void ResonantFilter< FILTER_TYPE, su >::setResonance ( su  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 106 of file ResonantFilter.h.