writeEventClips: Create Wav Clips of Data

View source: R/writeEventClips.R

writeEventClipsR Documentation

Create Wav Clips of Data

Description

Creates audio clips containing sounds from events or detections

Usage

writeEventClips(
  x,
  buffer = c(0, 0.1),
  outDir = ".",
  mode = c("event", "detection"),
  channel = 1,
  filter = 0,
  useSample = FALSE,
  progress = TRUE,
  verbose = TRUE,
  fixLength = FALSE
)

parseEventClipName(file, part = c("event", "time"))

Arguments

x

AcousticStudy object containing data to make wav clips for

buffer

amount before and after each event to also include in the clip, in seconds. Can either be a vector of length two specifying how much to buffer before and after (first number should be negative), or a single value if the buffer amount should be identical.

outDir

directory to write clips to, defaults to current directory

mode

either 'event' or 'detection' specifying whether to create wav clips of entire events or individual detections

channel

channel(s) of clips to write

filter

filter to apply to wav clips before writing, values in kHz. A value of 0 applies no filter. A single value applies a highpass filter at that value. A vector of two values applies a lowpass filter if the first number is 0, or a bandpass filter if both are non-zero.

useSample

logical flag to use startSample information in binaries instead of UTC time for start of detections. This can be slightly more accurate (~1ms) but will take longer

progress

logical flag to show progress bar

verbose

logical flag to show summary messages

fixLength

logical flag to fix the output clip length to a constant value. If TRUE, then output clip length is entirely determined by the buffer value, as if the detection or event had zero length. E.g. buffer=c(-2,1) will produce clips 3 seconds long, starting 2 seconds before the detection/event start time.

file

file name to parse

part

part of file name to return

Details

parseEventClipName parses the file names created to pull out event names or file start times

Value

A vector of file names for the wav clips that were successfully created, any that were not able to be written will be NA. Note that currently this can only write clips with up to 2 channels. File names will be formatted as [Event or Detection]_[Id]CH[ChannelNumber(s)]_[YYYYMMDD]_[HHMMSS]_[mmm].wav The last numbers are the start time of the file in UTC, accurate to milliseconds. The Id is either the event ID or the detection UID.

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples


data(exStudy)
recs <- system.file('extdata', 'Recordings', package='PAMpal')
exStudy <- addRecordings(exStudy, folder=recs, log=FALSE, progress=FALSE)
## Not run: 
# not running so that no wav clips are written to disk
wavs <- writeEventClips(exStudy, outDir='WavFolder', mode='event')

## End(Not run)


PAMpal documentation built on Aug. 12, 2023, 1:06 a.m.