Learn R Programming

warbleR (version 1.1.8)

lspec: Create long spectrograms of whole sound files

Description

lspec produces image files with spectrograms of whole sound files split into multiple rows.

Usage

lspec(X = NULL, flim = c(0,22), sxrow = 5, rows = 10, collev = seq(-40, 0, 1), 
ovlp = 50, parallel = 1, wl = 512, gr = FALSE, pal = reverse.gray.colors.2, 
cex = 1, it = "jpeg", flist = NULL, redo = TRUE, path = NULL, pb = TRUE, 
fast.spec = FALSE)

Arguments

X

Data frame with results from manualoc or any data frame with columns for sound file name (sound.files), selection number (selec), and start and end time of signal (start and end). If given, two red dotted lines are plotted at the start and end of a selection and the selections are labeled with the selection number (and selection comment, if available). Default is NULL.

flim

A numeric vector of length 2 indicating the highest and lowest frequency limits (kHz) of the spectrogram, as in spectro. Default is c(0,22).

sxrow

A numeric vector of length 1. Specifies seconds of spectrogram per row. Default is 5.

rows

A numeric vector of length 1. Specifies number of rows per image file. Default is 10.

collev

A numeric vector of length 3. Specifies levels to partition the amplitude range of the spectrogram (in dB). The more levels the higher the resolution of the spectrogram. Default is seq(-40, 0, 1).

ovlp

Numeric vector of length 1 specifying % of overlap between two consecutive windows, as in spectro. Default is 50. High values of ovlp slow down the function but produce more accurate selection limits (when X is provided).

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

wl

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

gr

Logical argument to add grid to spectrogram. Default is FALSE.

pal

Color palette function for spectrogram. Default is reverse.gray.colors.2. See spectro for more palettes.

cex

A numeric vector of length 1 giving the amount by which text (including sound file and page number) should be magnified. Default is 1.

it

A character vector of length 1 giving the image type to be used. Currently only "tiff" and "jpeg" are admitted. Default is "jpeg".

flist

character vector or factor indicating the subset of files that will be analyzed. Ignored if X is provided.

redo

Logical argument. If TRUE all selections will be analyzed again when code is rerun. If FALSE only the selections that do not have a image file in the working directory will be analyzed. Default is FALSE.

path

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

pb

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

fast.spec

Logical. If TRUE then image function is used internally to create spectrograms, which substantially increases performance (much faster), although some options become unavailable, as collevels, and sc (amplitude scale). This option is indicated for signals with high background noise levels. Palette colors gray.1, gray.2, gray.3, topo.1 and rainbow.1 (which should be imported from the package monitoR) seem to work better with 'fast' spectograms. Palette colors gray.1, gray.2, gray.3 offer decreasing darkness levels. THIS IS STILL BEING TESTED.

Value

image files with spectrograms of whole sound files in the working directory. Multiple pages can be returned, depending on the length of each sound file.

Details

The function creates spectrograms for complete sound files, printing the name of the sound files and the "page" number (p1-p2...) at the upper right corner of the image files. If results from manualoc are supplied (or an equivalent data frame), the function delimits and labels the selections. This function aims to facilitate visual inspection of multiple files as well as visual classification of vocalization units and the analysis of animal vocal sequences.

Examples

Run this code
# NOT RUN {
# Set temporary working directory
setwd(tempdir())
# save sound file examples
data(list = c("Phae.long1", "Phae.long2","selec.table"))
writeWave(Phae.long1,"Phae.long1.wav") 
writeWave(Phae.long2,"Phae.long2.wav")

lspec(sxrow = 2, rows = 8, pal = reverse.heat.colors, wl = 300)

# including selections
lspec(sxrow = 2, rows = 8, X = selec.table, pal = reverse.heat.colors, redo = TRUE, wl = 300)

check this floder
getwd()
# }

Run the code above in your browser using DataLab