class RemiAudio::DSP::BiQuadFilter

Overview

Implements a digital biquad filter.

Defined in:

remiaudio/dsp/biquadfilter.cr

Constant Summary

RESONANCE_MAX = 1.0

The maximum resonance value.

RESONANCE_MIN = Float64::MIN_POSITIVE

The minimum resonance value.

Constructors

Instance Method Summary

Constructor Detail

def self.new(newSampleRate) #

Creates a new BiQuadFilter.


[View source]

Instance Method Detail

def a1 : Float64 #

[View source]
def a2 : Float64 #

[View source]
def activate : Nil #

[View source]
def active=(active : Bool) #

Whether or not the filter is currently active.


[View source]
def active? : Bool #

Whether or not the filter is currently active.


[View source]
def b0 : Float64 #

[View source]
def b1 : Float64 #

[View source]
def b2 : Float64 #

[View source]
def clearBuffer : Nil #

Clears the internal buffer


[View source]
def deactivate : Nil #

[View source]
def freq : Float64 #

The current frequency of the filter.


[View source]
def gain : Float64 #

The current gain of the filter.

Setting the filter to be a lowpass, highpass, bandpass, notch, or allpass filter will cause this to always return 1.0. Otherwise this returns the actual gain.


[View source]
def mode : FilterMode #

The current mode of the filter.


[View source]
def plot(pt : PlotType, *, coeffsOnly : Bool = false) : String #

Generates a string that can be passed to a program to plot this filter on a graph. The PlotType dictates what kind of script is generated.


[View source]
def postGain : Float64 #

The amount of gain to apply after the EQ, in decibels.


[View source]
def postGain=(value : Float64) : Nil #

The amount of gain to apply after the EQ, in decibels.


[View source]
def process(sample : Float64) : Float64 #

Processes a single sample with the filter, returning a new sample.


[View source]
def process(sample : Float32) : Float32 #

Processes a single sample with the filter, returning a new sample.


[View source]
def process(block : Array(Float64) | Slice(Float64)) : BiQuadFilter #

"Runs" the filter over block.


[View source]
def process(block : Array(Float32) | Slice(Float32)) : BiQuadFilter #

"Runs" the filter over block.


[View source]
def reset #

Clears the internal buffer. This does not change the settings of the EQ.


[View source]
def sampleRate=(val : Int | Float) : Nil #

[View source]
def setAllPass(centerFreq : Float64, bandwidth : Float64) : Nil #

Puts the filter into allpass mode, setting the center frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit, or bandwidth is <= 0.


[View source]
def setBandPass(centerFreq : Float64, bandwidth : Float64) : Nil #

Puts the filter into bandpass mode, setting the center frequency and the width of the filter in octaves.

This deactivates the filter if cutoff is greater than the NyQuist limit, or bandwidth is <= 0.


[View source]
def setHighPass(cutoff : Float64, resonance : Float64) : Nil #

Puts the filter into highpass mode, setting the cutoff frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit. If resonance is less than or equal to 0, then resonance is set to RESONANCE_MIN.


[View source]
def setHighShelf(cutoff : Float64, gain : Float64, bandwidth : Float64) : Nil #

Puts the filter into low shelf mode, setting the cutoff frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit, if gain is 0, or if bandwidth is <= 0.


[View source]
def setLowPass(cutoff : Float64, resonance : Float64) : Nil #

Puts the filter into lowpass mode, setting the cutoff frequency and the resonance ("Q" value). The resonance will be clamped to RESONANCE_MIN..RESONANCE_MAX.

This deactivates the filter if cutoff is greater than the NyQuist limit. If resonance is less than or equal to 0, then resonance is set to RESONANCE_MIN.


[View source]
def setLowShelf(cutoff : Float64, gain : Float64, bandwidth : Float64) : Nil #

Puts the filter into low shelf mode, setting the cutoff frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit, if gain is 0, or if bandwidth is <= 0.


[View source]
def setNotch(centerFreq : Float64, bandwidth : Float64) : Nil #

Puts the filter into notch (bandstop) mode, setting the center frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit, or bandwidth is <= 0.


[View source]
def setPeakingEQ(centerFreq : Float64, gain : Float64, bandwidth : Float64) : Nil #

Puts the filter into peaking EQ mode, setting the center frequency and the resonance ("Q" value).

This deactivates the filter if cutoff is greater than the NyQuist limit, if gain is 0, or if bandwidth is <= 0.


[View source]
def width : Float64 #

The current width of the filter. This may be the bandwidth, or the Q value, depending on the mode the filter is set to.


[View source]