combfilter: Comb filter

View source: R/seewave.r

combfilterR Documentation

Comb filter

Description

This function processes a feedforward comb filter and plots a spectrogram of the filtered wave asso- ciated with the frequency response of the filter.

Usage

combfilter(wave, f, channel = 1, alpha, K, units = c("samples", "seconds"),
plot = FALSE, output = "matrix", ...)

Arguments

wave

an R object

f

sampling frequency (in Hz). Does not need to be specified if embedded in wave.

channel

channel of the R object, by default left channel (1).

alpha

a numeric vector of length 1 for the scaling factor. See Details.

K

a numeric vector of lenght 1 for the delay length, in units. See Details.

units

units in which K is given, the default is 'samples' but can be set to 'seconds'.

plot

a logical, if TRUE plots the spectrogram of the filtered wave and the frequency response of the comb filter.

output

character string, the class of the object to return, either 'matrix', 'Wave', 'Sample', 'audioSample' or 'ts'.

...

other arguments to be passed to spectro except scale and osc that are set by default to FALSE.

Details

A comb filter consists in adding a delayed version of a signal to itself resulting in constructive and destructive interference. The feedforward version of a comb filter can be written following:

y(n) = x(n) + \alpha \times x(n - K)

where alpha is the scaling factor and K the delay length. The frequency response of the filter is obtained with:

H(f) = \sqrt{(1+\alpha^2)+2 \times \cos(\omega K)}

The frequency response is periodic. The depth of the cycles is controlled with alpha and the number of cycles with K.

Value

A new wave is returned. The class of the returned object is set with the argument output.

Note

Setting K to high values may generate unwanted results.
The feedback form of the combfilter is not implemented yet.

Author(s)

Jerome Sueur

See Also

combfilter, fir, squarefilter, drawfilter, ffilter, bwfilter

Examples

## Not run: 
f <- 44100
## chirp
s1 <- synth(f=f, cf=1, d=2, fm=c(0,0,f/2,0,0), out="Wave")
combfilter(s1, alpha=1, K=50, plot=TRUE)
## harmonic sound
s2 <- synth(f=f, d=2, cf=600, harmonics=rep(1, 35), output="Wave")
combfilter(s2, alpha=1, K=10, plot=TRUE)
## noise, units in seconds
s3 <- noisew(d=2, f=44100, out="Wave")
combfilter(s3, alpha=0.5, K=1e-4, units="seconds", plot=TRUE)

## End(Not run)

seewave documentation built on Oct. 19, 2023, 5:07 p.m.

Related to combfilter in seewave...