View on GitHub Report a bug

monitoR

spectrogram cross-correlation, binary point matching, and manual annotation in R

Making Binary Point Templates

These examples explore the function arguments. You can also read the article.

Get clip, write to file

data(btnw)
tuneR::writeWave(btnw, 'btnw.wav')

Change amp.cutoff

template <- makeBinTemplate('btnw.wav', amp.cutoff = -45)
plot(template)

plot of chunk example1plot of chunk example1

template <- makeBinTemplate('btnw.wav', amp.cutoff = -25)
plot(template)

plot of chunk example1_1plot of chunk example1_1

Automatic point selection

Automatic is the default because it does not require interactivity and allows the package vignette and examples to build. In general use it is unlikely that users will build the most effective templates with the “auto” option.

template <- makeBinTemplate('btnw.wav', amp.cutoff=-35)
plot(template)

plot of chunk example1_2plot of chunk example1_2

Change select to ‘rectangle’

template <- makeBinTemplate('btnw.wav', select='rectangle', amp.cutoff=-35)

Change select to ‘cell’

template <- makeBinTemplate('btnw.wav', select='cell', amp.cutoff=-35)

Change time limits

template <- makeBinTemplate('btnw.wav', t.lim = c(0.75, 2.25), amp.cutoff = -35)
plot(template)

plot of chunk example2plot of chunk example2

Change frequency limits

template <- makeBinTemplate('btnw.wav', frq.lim = c(3, 7), amp.cutoff = -35)
plot(template)

plot of chunk example3plot of chunk example3

Change buffer

template <- makeBinTemplate('btnw.wav', buffer = 4, amp.cutoff = -35)
plot(template)

plot of chunk example4plot of chunk example4

Change selection density

template <- makeBinTemplate('btnw.wav', dens = 0.4, amp.cutoff = -35)
plot(template)

plot of chunk example5plot of chunk example5

Change FFT parameters

template <- makeBinTemplate('btnw.wav', wl = 1024, ovlp = 75, amp.cutoff = -35)
plot(template)

plot of chunk example6plot of chunk example6

Change template name

template <- makeBinTemplate('btnw.wav', name='btnw_typeB_5kHz', amp.cutoff = -35)
plot(template)

plot of chunk example6_1plot of chunk example6_1

Intersection of two clips

(download the second clip)

btnw_2 <- c('btnw.wav', 'btnw2.wav')
viewSpec(btnw_2[1]) # The clip that comes with the package
viewSpec(btnw_2[2]) # Another song, ~800Hz higher frequency

plot of chunk example7plot of chunk example7

template <- makeBinTemplate(btnw_2, t.lim = list(c(0.75, 2.25),c(1.5, 3.5)), frq.lim = c(3, 8), amp.cutoff = -35)

## Interactive clip alignment.
## Enter l, ll, ll, etc. for left shift, 
## r, rr, rrr, etc. for right shift, 
## or Enter to continue.

ll
lll
l

plot(template)

plot of chunk example8

Combine templates

template1 <- makeBinTemplate('btnw.wav', name='btnw_typeB_5kHz', amp.cutoff = -35)
template2 <- makeBinTemplate('btnw2.wav', name='btnw_typeB_5.8kHz', amp.cutoff = -35)
templates <- combineBinTemplates(template1, template2)
plot(templates, ask=FALSE)

plot of chunk example9_1plot of chunk example9_1