Learn R Programming

phonTools (version 0.2-2.2)

Ffilter: Formant Filtering

Description

Perform cascade formant filtering of sounds.

Usage

Ffilter (sound, ffs, bwp = 0.06, minbw = 60, fs = 22050, verify = FALSE)

Value

A vector representing the filtered sound.

Arguments

sound

A numeric vector representing a waveform, or a 'sound' object created with the loadsound() or makesound() functions.

ffs

A list of vectors of initial and final center frequencies for each formant. Each vector should contain formant frequencies in order of lowest to highest frequency. If only a single vector is provided, formants will remain stable throughout.

bwp

A vector of formant bandwidths, one for each formant.

minbw

The minimum permissible formant bandwidth, in Hertz.

fs

The sampling frequency of the sound. If a 'sound' object is passed, this does not need to be specified.

verify

If TRUE, before and after spectra are plotted to allow the user to visually verify the process.

Author

Santiago Barreda <sbarreda@ucdavis.edu>

Details

This function allows the user to specify one or more formant filters and to pass a signal through said filters. This may be used to create synthetic speech sounds or to modify existing sounds as desired. The given signal is passed through the formant filters in reverse order. Filter bandwidths specify the distance between formant center frequencies and the point at which the output will be 3 dB below peak energy.

Filter bandwidths may be provided in Hz, or as a percentage of the formant frequencies. To set these as a percent of formant frequencies, all values must be less than 1. If these are not provided they are set to 6 percent of the formant center frequencies by default. If only one value is provided, this is assumed to be the desired value for all formants.

References

Klatt, D. H. (1980). Software for a cascade/parallel formant synthesizer. Journal of the Acoustical Society of America 67(3): 971-995.

http://www.fon.hum.uva.nl/praat/manual/Sound__Filter__one_formant____.html

Examples

Run this code

## uncomment and run
## Generate half a second of white noise
#sound = rnorm (11025, 0, 1)

## pass this through some formant filters
## two static formants
#filtered1 = Ffilter (sound, ffs = c(4000,7000), bw = 500)
## a single moving formant
#filtered2 = Ffilter (sound, ffs = list(3000,8000), bw = 500)
## two moving formants


## inspect the results
#par (mfrow = c(1,2), mar = c(4,4,1,1))
#spectrogram (filtered1, maxfreq = 11025)
#spectrogram (filtered2, maxfreq = 11025)

Run the code above in your browser using DataLab