bioacoustica.tools.window: Windowing function for waveforms

Description Usage Arguments Examples

View source: R/bioacoustica.tools.window.R

Description

Function that breaks a waveform into sections (windows). Windows may overlap, be consecutive, or be sparsely arranged. The gap between the start of windows is given by the increment, and the length of a window is given by the interval.

Usage

1
bioacoustica.tools.window(wave, interval, increment, windowFunction)

Arguments

wave
interval
increment
windowFunction

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (wave, interval, increment, windowFunction) 
{
    window_start <- 0
    window_number <- 1
    hit_end <- FALSE
    f <- wave@samp.rate
    results <- data.frame()
    while (!isTRUE(hit_end)) {
        if (window_start + increment > duration(wave, f = f)) {
            interval <- duration(wave, f = f) - window_start
            hit_end <- TRUE
        }
        window <- cutw(wave, f = f, from = window_start, to = window_start + 
            interval, output = "Wave")
        results <- rbind(results, window_function(window_number, 
            window_start, window_start + interval, window, f))
        window_start <- window_start + increment
        window_number <- window_number + 1
    }
    names(results) <- functions(NULL, NULL, NULL, NULL, NULL, 
        headers = TRUE)
    return(results)
  }

BioAcoustica/BioAcousticaR-tools documentation built on May 5, 2019, 3:46 p.m.