# \donttest{
# Save example files into temporary working directory
data("lbh1", "lbh2", "lbh_reference")
tuneR::writeWave(lbh1, file.path(tempdir(), "lbh1.wav"))
tuneR::writeWave(lbh2, file.path(tempdir(), "lbh2.wav"))
# using smoothing and minimum duration
detec <- energy_detector(files = c("lbh1.wav", "lbh2.wav"),
path = tempdir(), threshold = 6, smooth = 6.8,
bp = c(2, 9), hop.size = 3, min.duration = 0.05)
# diagnose detection
diagnose_detection(reference = lbh_reference,
detection = detec)
# without declaring 'files'
detec <- energy_detector(path = tempdir(), threshold = 60, smooth = 6.8,
bp = c(2, 9), hop.size = 6.8, min.duration = 90)
# diagnose detection
diagnose_detection(reference = lbh_reference,
detection = detec)
# using hold time
detec <- energy_detector(threshold = 10, hold.time = 150,
bp = c(2, 9), hop.size = 6.8, path = tempdir())
# diagnose detection
diagnose_detection(reference = lbh_reference, detection = detec)
# calculate envelopes first
envs <- get_envelopes(bp = c(2, 9), hop.size = 6.8, path = tempdir())
# then run detection providing 'envelopes' (but no 'files')
detec <- energy_detector(envelopes = envs, threshold = 10, hold.time = 150, min.duration = 50)
# diagnose detection
diagnose_detection(reference = lbh_reference, detection = detec, time.diagnostics = TRUE)
# \donttest{
# USING OTHER SOUND FILE FORMAT (flac program must be installed)
# fisrt convert files to flac
warbleR::wav_2_flac(path = tempdir())
# change sound file extension to flac
flac_reference <- lbh_reference
flac_reference$sound.files <- gsub(".wav", ".flac", flac_reference$sound.files)
# run detection
detec <- energy_detector(files = c("lbh1.flac", "lbh2.flac"), path = tempdir(), threshold = 60,
smooth = 6.8, bp = c(2, 9), hop.size = 6.8, min.duration = 90)
# diagnose detection
diagnose_detection(reference = flac_reference, detection = detec)
# }
# }
Run the code above in your browser using DataLab