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

A generic resonant filter for audio signals. More...

#include <ResonantFilter.h>

Detailed Description

template<int8_t FILTER_TYPE, typename su = uint8_t>
class ResonantFilter< FILTER_TYPE, su >

A generic resonant filter for audio signals.

Definition at line 75 of file ResonantFilter.h.

Public Member Functions

 ResonantFilter ()
 Constructor.
 
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...
 
AudioOutputStorage_t next (AudioOutputStorage_t in)
 Calculate the next sample, given an input signal. 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
 

Member Function Documentation

◆ next()

template<int8_t FILTER_TYPE, typename su = uint8_t>
AudioOutputStorage_t ResonantFilter< FILTER_TYPE, su >::next ( AudioOutputStorage_t  in)
inline

Calculate the next sample, 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.
Returns
the signal output.
Note
Timing: about 11us.

Definition at line 128 of file ResonantFilter.h.

◆ setCutoffFreq()

template<int8_t FILTER_TYPE, typename su = uint8_t>
void ResonantFilter< FILTER_TYPE, su >::setCutoffFreq ( su  cutoff)
inline

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()

template<int8_t FILTER_TYPE, typename su = uint8_t>
void ResonantFilter< FILTER_TYPE, su >::setCutoffFreqAndResonance ( su  cutoff,
su  resonance 
)
inline

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()

template<int8_t FILTER_TYPE, typename su = uint8_t>
void ResonantFilter< FILTER_TYPE, su >::setResonance ( su  resonance)
inline

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.