Learn R Programming

warbleR (version 1.1.8)

ffts: Extract the fundamental frequency values as a time series

Description

ffts extracts the fundamental frequency values as a time series of signals selected by manualoc or autodetec.

Usage

ffts(X, wl = 512, length.out = 20, wn = "hanning", ovlp = 70, bp = c(0, 22),
  threshold = 15, img = TRUE, parallel = 1, path = NULL, img.suffix = "ffts", pb = TRUE, 
  clip.edges = FALSE, leglab = "ffts", ff.method = "seewave", ...)

Arguments

X

Data frame with results containing columns for sound file name (sound.files), selection number (selec), and start and end time of signal (start and end). The ouptut of manualoc or autodetec can be used as the input data frame.

wl

A numeric vector of length 1 specifying the window length of the spectrogram, default is 512.

length.out

A character vector of length 1 giving the number of measurements of fundamental frequency desired (the length of the time series).

wn

Character vector of length 1 specifying window name. Default is "hanning". See function ftwindow for more options.

ovlp

Numeric vector of length 1 specifying % of overlap between two consecutive windows, as in spectro. Default is 70.

bp

A numeric vector of length 2 for the lower and upper limits of a frequency bandpass filter (in kHz). Default is c(0, 22).

threshold

amplitude threshold (%) for fundamental frequency detection. Default is 15.

img

Logical argument. If FALSE, image files are not produced. Default is TRUE.

parallel

Numeric. Controls whether parallel computing is applied. It specifies the number of cores to be used. Default is 1 (i.e. no parallel computing). Not available in Windows OS.

path

Character string containing the directory path where the sound files are located. If NULL (default) then the current working directory is used.

img.suffix

A character vector of length 1 with a suffix (label) to add at the end of the names of image files.

pb

Logical argument to control progress bar. Default is TRUE. Note that progress bar is only used when parallel = 1.

clip.edges

Logical argument to control whether edges (start or end of signal) in which amplitude values above the threshold were not detected will be removed. If TRUE this edges will be excluded and signal contour will be calculated on the remainging values. Default is FALSE. #' @param leglab A character vector of length 1 or 2 containing the label(s) of the frequency contour legend in the output image.

leglab

A character vector of length 1 or 2 containing the label(s) of the frequency contour legend in the output image.

ff.method

Character. Selects the method used to calculate the fundamental frequency. Either 'tuneR' (using FF) or 'seewave' (using fund). Default is 'seewave'. 'tuneR' performs faster (and seems to be more accurate) than 'seewave'.

...

Additional arguments to be passed to trackfreqs. for customizing graphical output.

Value

A data frame with the fundamental frequency values measured across the signals. If img is TRUE it also produces image files with the spectrograms of the signals listed in the input data frame showing the location of the fundamental frequencies (see trackfreqs description for more details).

Details

This function extracts the fundamental frequency values as a time series. The function uses the approx function to interpolate values between fundamental frequency #' measures. If there are no frequencies above the amplitude theshold at the begining or end of the signals then NAs will be generated. On the other hand, if there are no frequencies above the amplitude theshold in between signal segments in which amplitude was detected then the values of this adjacent segments will be interpolated to fill out the missing values (e.g. no NAs in between detected amplitude segments).

See Also

sig2noise, trackfreqs, dfts, ffDTW, dfDTW

Other spectrogram.creators: dfDTW, dfts, ffDTW, snrspecs, sp.en.ts, specreator, trackfreqs

Examples

Run this code
# NOT RUN {
# set the temp directory
setwd(tempdir())

#load data
data(list = c("Phae.long1", "Phae.long2","selec.table"))
writeWave(Phae.long1, "Phae.long1.wav") #save sound files 
writeWave(Phae.long2, "Phae.long2.wav") #save sound files 

# run function 
ffts(selec.table, length.out = 50, flim = c(1, 12), bp = c(2, 9), wl = 300)

Note that fundamental frequency is not accurate for noisy signals, works better with pure tones

# }

Run the code above in your browser using DataLab