bioacoustica.getAnnotationFile: Downloads an annotated section of a recording

Description Usage Arguments Value Author(s) Examples

Description

This fucntion wil download and trim a recording to match an annotated section of recording on BioAcoustica.

Usage

1

Arguments

annotation_id

The annotation ID of the annotation on BioAcoustica.

c

An authenticated CURL handle.

data

Annotation data. Previosuly downloaded annotation downloads can be passed to the function to prevent multiple calls to BioAcoustica which may cause access to be tmeporarily suspended. If not provided the annotation data will be downloaded from BioAcoustica.

Value

The filename to a downloaded sound recording.

Author(s)

Ed Baker

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
##---- 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(annotation_id, c) {
  a <- bioacoustica::bioacoustica.getAnnotations(c);
  file <- as.character(subset(a, 
                              a$id==annotation_id,
                              select="file")[1,1]);
  parts <- strsplit(file, "/");
  filename <- parts[[1]][7];
  #TODO: CHange to CURL
  download.file(file, destfile=filename);
  long <- tuneR::readWave(filename);
  f <- long@samp.rate;
  wave <- seewave::cutw(long, f=f, from=subset(a, id==annotation_id,
                          select="start")[1,1], 
                          to=subset(a, id==annotation_id,select="end")[1,1],
                          method="Wave");
  file.remove(filename);
  nf <- paste0(filename,".",annotation_id,".wav");
  seewave::savewav(wave, f=f, file=nf);
  return(nf)
}

BioAcoustica/bioacousticaR documentation built on May 5, 2019, 3:46 p.m.