add_noise: Add synthetic noise

View source: R/add_noise.R

add_noiseR Documentation

Add synthetic noise

Description

add_noise adds synthetic noise to annotations in extended selection tables

Usage

add_noise(
  X,
  mar = NULL,
  target.snr = 2,
  precision = 0.1,
  cores = getOption("mc.cores", 1),
  pb = getOption("pb", TRUE),
  max.iterations = 1000,
  kind = c("pink", "white", "brown", "red", "power"),
  alpha = 1,
  ...
)

Arguments

X

Object of class 'extended_selection_table' (created by the function selection_table from the warbleR package), generated 'by element', with the reference to the test sounds (typically the output of align_test_files). Must contain the following columns: 1) "sound.files": name of the .wav files, 2) "selec": unique selection identifier (within a sound file), 3) "start": start time and 4) "end": end time of selections, 5) "bottom.freq": low frequency for bandpass, 6) "top.freq": high frequency for bandpass and 7) "sound.id": ID of sounds (needed to calculate signal to noise ratio internally using signal_to_noise_ratio).

mar

numeric vector of length 1. Specifies the margins adjacent to the start point of the annotation over which to measure ambient noise.

target.snr

numeric vector of length 1. Specifies the desired signal-to-noise ratio. Must be lower that the current signal-to-noise ratio. Annotations showing a signal-to-noise ratio higher than 'target.snr' will remain unchanged. Must be supplied.

precision

numeric vector of length 1. Specifies the precision of the adjusted signal-to-noise ratio (in dB).

cores

Numeric vector of length 1. Controls whether parallel computing is applied by specifying the number of cores to be used. Default is 1 (i.e. no parallel computing).

pb

Logical argument to control if progress bar is shown. Default is TRUE.

max.iterations

Numeric vector of length 1. Specifies the maximum number of iterations that the internal signal-to-noise adjusting routine will run before stopping. Note that in most cases the default maximum number of iterations (1000) is not reached.

kind

Character vector of length 1 indicating the kind of noise, “white”, “pink”, “power”, "brown", or “red”. Noise is synthesized with a modified version of the function noise. Default is "pink" which is similar to background noise in natural environments.

alpha

Numeric vector of length 1. The power for the power law noise (defaults are 1 for pink and 1.5 for red noise). Only used when kind = "power".

...

Additional arguments to be passed internally to signal_to_noise_ratio.

Details

The function adds synthetic noise to sounds referenced in an extended selection table (class created by the function selection_table from the warbleR package) to decrease the signal-to-noise ratio. This can be useful, for instance, for evaluating the effect of background noise on signal structure. Note that the implementation is slow.

Value

Object 'X' in which the wave objects have been modified to match the target signal-to-noise ratio. It also includes an additional column, 'adjusted.snr', with the new signal-to-noise ratio values.

Author(s)

Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)

References

Araya-Salas, M. (2020). baRulho: baRulho: quantifying degradation of (animal) acoustic signals in R. R package version 1.0.2 Timmer. J and M. König (1995): On generating power law noise. Astron. Astrophys. 300, 707-710.

See Also

signal_to_noise_ratio

Other miscellaneous: attenuation(), noise_profile()

Examples

## Not run: 
# load example data
data("test_sounds_est")

# make it a 'by element' extended selection table
X <- warbleR::by_element_est(X = test_sounds_est)

# add noise to the first five rows
X_noise <- add_noise(X = X[1:5, ], mar = 0.2, target.snr = 3)

## End(Not run)

maRce10/baRulho documentation built on March 30, 2024, 7:50 a.m.