| Title: | Bioacoustic Analysis and Publication Tools |
|---|---|
| Description: | Provides tools for manipulating sound files for bioacoustic analysis, and preparing analyses these for publication. The package validates that values are physically possible wherever feasible. |
| Authors: | Ed Baker [aut, cre] (ORCID: <https://orcid.org/0000-0002-5887-9543>), Quentin Geissman [ctb] |
| Maintainer: | Ed Baker <[email protected]> |
| License: | GPL-3 |
| Version: | 0.0.8.9000 |
| Built: | 2026-10-23 19:10:26 UTC |
| Source: | https://github.com/edwbaker/sonicscrewdriver |
PseudoWave scalar subtraction
## S4 method for signature 'PseudoWave,numeric' e1 - e2## S4 method for signature 'PseudoWave,numeric' e1 - e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with e2 subtracted from its offset.
Check if two annotations overlap or are continuous
.annotation_check_overlap(annotation1, annotation2, domain = "time").annotation_check_overlap(annotation1, annotation2, domain = "time")
annotation1 |
An Annotation object. |
annotation2 |
An Annotation object. |
domain |
Domain of the annotations, either "time", "frequency", or "both". |
TRUE if the annotations overlap, FALSE otherwise.
Checks a list of annotations for those that are overlapping in the time or frequency domain, and returns a list where overlapping annotations are merged.
.merge_annotations(annotations, domain = "time").merge_annotations(annotations, domain = "time")
annotations |
A list of Annotation objects. |
domain |
Domain of the annotations, either "time" or "frequency". |
The exported function merge_annotations() handles sanity checks and calls this function.
A list of Annotation objects.
Helper function to convert a Wave-like object to scikit-maad spectrogram
.spectrogram_maad_power(object).spectrogram_maad_power(object)
object |
A Wave or WaveMC object (or Tagged equivalent), or a spectrogram_maad object |
A spectrogram_maad object
Helper function to convert a Wave-like object to scikit-maad spectrum
.spectrum_maad(object).spectrum_maad(object)
object |
A Wave or WaveMC object (or Tagged equivalent), or a spectrum |
A spectrum list
Allow subsetting a Wave object with a TimeRegion
## S4 method for signature 'Wave,TimeRegion' x[i]## S4 method for signature 'Wave,TimeRegion' x[i]
x |
Wave Object |
i |
TimeRegion object |
A Wave object containing only the samples within the time region.
Numeric multiplication by PseudoWave
## S4 method for signature 'numeric,PseudoWave' e1 * e2## S4 method for signature 'numeric,PseudoWave' e1 * e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with its scale multiplied by e1.
PseudoWave scalar manipulation
## S4 method for signature 'PseudoWave,numeric' e1 * e2## S4 method for signature 'PseudoWave,numeric' e1 * e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with its scale multiplied by e2.
PseudoWave scalar division
## S4 method for signature 'PseudoWave,numeric' e1 / e2## S4 method for signature 'PseudoWave,numeric' e1 / e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with its scale divided by e2.
Numeric addition by PseudoWave
## S4 method for signature 'numeric,PseudoWave' e1 + e2## S4 method for signature 'numeric,PseudoWave' e1 + e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with e1 added to its offset.
PseudoWave scalar addition
## S4 method for signature 'PseudoWave,numeric' e1 + e2## S4 method for signature 'PseudoWave,numeric' e1 + e2
e1 |
Input 1 |
e2 |
Input 2 |
A PseudoWave object with e2 added to its offset.
This function takes a traits dataset retrieved from audioblast and converts values such as "day" into a numeric time of day based on the date and location.
ab_diel_traits(traits, date, lat, lon, overwrite = FALSE)ab_diel_traits(traits, date, lat, lon, overwrite = FALSE)
traits |
Traits dataset retrieved using audioblast(). |
date |
The date used for conversion for time. |
lat |
Latitude of location. |
lon |
Longitude of location. |
overwrite |
If TRUE then the function will overwrite any existing min/max. |
The traits data frame, with value_min and value_max converted to numeric times of day.
This function takes a TaggedWave or TaggedWaveMC object and adds a process
to the processing slot. This is used to keep a record of the processes that
have been applied to the object.
addProcess(object, process, output = NULL, duration = NULL) ## S4 method for signature 'TaggedWave' addProcess(object, process, output = NULL, duration = NULL) ## S4 method for signature 'TaggedWaveMC' addProcess(object, process, output = NULL, duration = NULL)addProcess(object, process, output = NULL, duration = NULL) ## S4 method for signature 'TaggedWave' addProcess(object, process, output = NULL, duration = NULL) ## S4 method for signature 'TaggedWaveMC' addProcess(object, process, output = NULL, duration = NULL)
object |
An object. |
process |
A description of the process. |
output |
The output of the process. |
duration |
The duration of the process in seconds. |
The object with the process added.
This function takes two spectra from seewave (or equivalent) and adds their values. The spectra must have the same bins.
addSpectra(s1, s2, coerceNegative = TRUE)addSpectra(s1, s2, coerceNegative = TRUE)
s1 |
First spectrum |
s2 |
Second spectrum |
coerceNegative |
Sets any values below zero to zero in output. |
A spectrum of s1+s2
## Not run: addSpectra(spec1, spec2) addSpectra(spec1, spec2, coerceNegative=TRUE) ## End(Not run)## Not run: addSpectra(spec1, spec2) addSpectra(spec1, spec2, coerceNegative=TRUE) ## End(Not run)
Some functions (e.g. ffilter from seewave) only operate on a single channel at a time. This function applies the function to each channel and returns a list of analyses.
allChannels( w, FUN, cl = NULL, channel.param = "channel", output.FUN = NULL, ... )allChannels( w, FUN, cl = NULL, channel.param = "channel", output.FUN = NULL, ... )
w |
A Wave or WaveMC object |
FUN |
Function to apply to the wave. |
cl |
Optionally a cluster for parallel calculation. |
channel.param |
Name of the channel parameter to FUN. Can be NULL. |
output.FUN |
Optional. Function that processes the output of FUN. The "channels_se" function provides standard functionality for the soundecology package. |
... |
Optional. Additional parameters to pass to FUN. |
A list with one entry per channel, whatever the class and channel count of the input. Each entry is itself a list.
Create a new Annotation object
annotation( file = "", metadata = list(), start = 0, end = Inf, low = 0, high = Inf, source = "", type = "", value = "" )annotation( file = "", metadata = list(), start = 0, end = Inf, low = 0, high = Inf, source = "", type = "", value = "" )
file |
File being annotated. |
metadata |
A list of metadata. |
start |
Start time of annotation (seconds). |
end |
End time of annotation (seconds). |
low |
Low frequency of annotation (Hz). |
high |
High frequency of annotation (Hz). |
source |
Source of annotation. |
type |
Type of annotation. |
value |
Value of annotation. |
An Annotation object.
The Annotation class is used to store annotations on Wave-like objects.
fileFile being annotated.
metadataA list for storing metadata.
startStart time of annotation.
endEnd time of annotation.
lowLow frequency of annotation.
highHigh frequency of annotation.
sourceSource of annotation.
typeType of annotation.
valueValue of annotation.
Converts a list of Annotation objects to a data.frame, with one column for each metadata name in the list.
AnnotationList2DataFrame(x)AnnotationList2DataFrame(x)
x |
A list of Annotation objects. |
A data.frame.
Calculates the raw size of audio date at set sample rate, bit depth and duration.
audio_filesize( samp.rate = 44100, bit.depth = 16, channels = 1, duration = 1, duration.unit = "seconds", output.unit = "bits", units = "decimal" )audio_filesize( samp.rate = 44100, bit.depth = 16, channels = 1, duration = 1, duration.unit = "seconds", output.unit = "bits", units = "decimal" )
samp.rate |
Sample rate |
bit.depth |
Bit depth |
channels |
The number of audio channels |
duration |
Duration of recording |
duration.unit |
Any unit accepted by |
output.unit |
"human", "bits" or "bytes" |
units |
Units used when output.unit is "human", either "decimal" or "binary". See humanBytes(). |
The size is given in bits by default. Setting output.unit to "bytes" gives
bytes, and to "human" passes the result through humanBytes(), whose choice of
decimal or binary units is taken from units.
The size of the audio file in the specified unit
# One minute of mono 16-bit audio sampled at 44.1kHz audio_filesize(samp.rate=44100, bit.depth=16, channels=1, duration=1, duration.unit="minutes") # One year of stereo 24-bit audio sampled at 96kHz audio_filesize(samp.rate=96000, bit.depth=24, channels=2, duration=1, duration.unit="years")# One minute of mono 16-bit audio sampled at 44.1kHz audio_filesize(samp.rate=44100, bit.depth=16, channels=1, duration=1, duration.unit="minutes") # One year of stereo 24-bit audio sampled at 96kHz audio_filesize(samp.rate=96000, bit.depth=24, channels=2, duration=1, duration.unit="years")
Search for data or analyses on audioBlast.
audioblast( type, name, endpoint = NULL, check = TRUE, max_pages = NULL, page = 1, quiet = FALSE, on.issue = stop, output = "data.frame", ... )audioblast( type, name, endpoint = NULL, check = TRUE, max_pages = NULL, page = 1, quiet = FALSE, on.issue = stop, output = "data.frame", ... )
type |
One of data, analysis, standalone. |
name |
Name of data or analysis source. |
endpoint |
Optionally specify endpoint of an audioBlast module. |
check |
Logical. Performs sanity check on input before sending to audioBLAST. |
max_pages |
Maximum number of data pages to return, by default this is set to NULL and returns all pages. |
page |
First page of results to request, defaults to 1. |
quiet |
If true will not print progress. Silence is a virtue. |
on.issue |
Function to call on error or warning. By default |
output |
By default a |
... |
Fields and values to filter on. Any field defined by audioBLAST. |
A data frame
## Not run: audioblast("data", "recordings", taxon="Gryllotalpa vineae") ## End(Not run)## Not run: audioblast("data", "recordings", taxon="Gryllotalpa vineae") ## End(Not run)
Downloads audio files associated with a search using the audioBlast() function.
audioblastDownload( d, metadata = TRUE, skip.existing = TRUE, dir = ".", quiet = FALSE, on.issue = .audioblastIssue )audioblastDownload( d, metadata = TRUE, skip.existing = TRUE, dir = ".", quiet = FALSE, on.issue = .audioblastIssue )
d |
Data returned from a search using audioBlast(). |
metadata |
If true saves the data in d as a csv file. |
skip.existing |
If true will not overwrite existing files. |
dir |
Directory to save files to. |
quiet |
If true will not print progress. |
on.issue |
Function to call on error or warning. By default |
No return value, called for its side effect of downloading files.
Reads and parses an AudioMoth configuration file.
audiomothConfig(filename)audiomothConfig(filename)
filename |
Path to the configuration file to read |
A data frame of the configuration settings, with columns Key and Value
## Not run: audiomothConfig("./CONFIG.TXT") ## End(Not run)## Not run: audiomothConfig("./CONFIG.TXT") ## End(Not run)
Reads and parses metadata stored in wave files produced by AudioMoth devices.
audiomothWave(filename)audiomothWave(filename)
filename |
Path to the wave file to read |
A list of extracted parameters
## Not run: audiomothWave("./FILENAME.WAV") ## End(Not run)## Not run: audiomothWave("./FILENAME.WAV") ## End(Not run)
Creates an automatic bandpass filter based on the strongest frequency. The allowed bandwidth can be an integer multiple of the bandwidth at either -3dB or -10dB.
autoBandPass(wave, bw = "-3dB", n.bw = 1, lowcut = 1000)autoBandPass(wave, bw = "-3dB", n.bw = 1, lowcut = 1000)
wave |
A Wave object |
bw |
Either -3dB or -10dB. This is calculated by |
n.bw |
The number of bandwidths either side of the centre of the centre to keep |
lowcut |
High-pass filtering is applied at this frequency before calculating the centre frequency and bandwidth |
A band-pass filtered Wave object
## Not run: autoBandPass(sheep) autoBandPass(sheep, bw="-3dB", n.bw=1, lowcut=1000) autoBandPass(sheep, bw="-10dB", n.bw=2, lowcut=0) ## End(Not run)## Not run: autoBandPass(sheep) autoBandPass(sheep, bw="-3dB", n.bw=1, lowcut=1000) autoBandPass(sheep, bw="-10dB", n.bw=2, lowcut=0) ## End(Not run)
Creates a band pass WaveFilter between values specified to a Wave object.
bandpass(from, to, ...)bandpass(from, to, ...)
from |
Bottom of bandpass frequency (Hz). |
to |
Top of bandpass frequency (Hz). |
... |
Further arguments to pass to ffilter. |
This is a simple wrapper function to the seewave ffilter function allowing its use with filterw and pipes.
A WaveFilter object.
## Not run: nwave <- noise("white", duration=44100, samp.rate=44100) fwave <- filterWave(nwave, bandpass(from=1000, to=2000)) nwave |> filterWave(bandpass(from=1000, to=2000)) -> fwave ## End(Not run)## Not run: nwave <- noise("white", duration=44100, samp.rate=44100) fwave <- filterWave(nwave, bandpass(from=1000, to=2000)) nwave |> filterWave(bandpass(from=1000, to=2000)) -> fwave ## End(Not run)
Given the time differences of arrival of a sound between the microphones of an array, and the positions of those microphones, estimates the direction the sound arrived from.
bearing(delays, positions, speed = NULL, unit = "degrees")bearing(delays, positions, speed = NULL, unit = "degrees")
delays |
Time differences of arrival in seconds, one per microphone, as
returned by |
positions |
Positions of the microphones in metres, as a matrix or data
frame with one row per microphone (in the same order as |
speed |
The speed of sound in metres per second. The default is the value
|
unit |
Unit for the returned angles, either "degrees" (the default) or "radians". |
The sound is assumed to be far enough away that the wavefront reaching the array is flat, in which case the delay at each microphone depends on the direction the sound came from but not on how far away it was. "Far enough" is relative to the size of the array: a few array widths is usually sufficient. No distance to the source is estimated, and none can be from a single array under this assumption.
The direction is returned as an azimuth measured anticlockwise from the
positive x axis of the coordinates the microphone positions were given in. If
those coordinates have x pointing east and y pointing north, the compass
bearing of the source is (90 - azimuth) %% 360 degrees.
Two microphones, or any number of microphones in a straight line, determine only the angle between the direction of the sound and the axis of the array: every direction on a cone around that axis gives the same delays. For an array lying in a line in two dimensions this leaves two possible bearings, mirrored about the array axis, and both are returned. Microphones lying in a plane, with positions given in three dimensions, likewise leave two possible directions mirrored about that plane. For microphones in a line with positions given in three dimensions no bearing can be recovered, and only the angle from the array axis is returned.
A set of delays that is consistent with a plane wave has a magnitude of 1
and a residual of 0. A magnitude far from 1, or a residual that is an
appreciable fraction of the size of the array, means the delays are not
consistent with any single direction and the bearing should not be trusted.
Common causes are a correlation peak found on the wrong cycle of a tonal
sound, a source too close to the array for the plane wave assumption, and two
sounds overlapping in the window correlated.
Neither check is available from every array. The residual is only meaningful where there are more microphones than one more than the number of dimensions the positions are given in, as fewer leave the delays exactly enough to fit a direction to. The magnitude is only meaningful for an array that determines the direction fully, as one that does not fits only the part of the direction it can see. For a pair of microphones neither is available, and delays that are not physically possible are all that can be detected.
Where the array determines the direction fully the bearing does not depend on the speed of sound, which only scales the delays: getting it wrong moves the magnitude away from 1 but leaves the direction alone. Where the array leaves an ambiguity the bearing does depend on it, so a pair of microphones is worth giving a speed calculated for the conditions of the recording.
A list holding:
azimuth The direction the sound arrived from, or two directions where the array leaves an ambiguity (see Details), or NA where no direction can be recovered.
elevation The angle above the horizontal, for positions given in three dimensions. NA otherwise.
direction A matrix holding the unit vector of each direction in the coordinates the positions were given in.
cone For microphones in a line with positions given in three dimensions, the angle between the direction of the sound and the axis of the array, measured from the first microphone towards the last. NA otherwise.
residual The root mean square difference, in metres, between the path length differences the estimate implies and those the delays give.
magnitude The length of the direction vector the fit produced, before it was scaled to a unit vector, which is 1 for delays that are exactly consistent with a plane wave (see Details). Where the array leaves an ambiguity this is the length of the part of the direction the array can see, which is at most 1.
speed The speed of sound used.
unit The unit the angles are given in.
ambiguous Whether the array leaves more than one possible direction.
tdoa(), which produces the delays this function takes.
# Three microphones in a right angled triangle, 1m apart mics <- rbind(c(0, 0), c(1, 0), c(0, 1)) # A sound arriving from the east reaches the eastern microphone first bearing(c(0, -1/343, 0), mics) # A stereo pair leaves two possible bearings bearing(c(0, -0.5/343), rbind(c(0, 0), c(1, 0)))# Three microphones in a right angled triangle, 1m apart mics <- rbind(c(0, 0), c(1, 0), c(0, 1)) # A sound arriving from the east reaches the eastern microphone first bearing(c(0, -1/343, 0), mics) # A stereo pair leaves two possible bearings bearing(c(0, -0.5/343), rbind(c(0, 0), c(1, 0)))
This function computes a beatSpectrum and calculates some basic
measurements of its complexity. The complexity value is calculated as the
maximum identified repeating period (in seconds) divided by the number of
peaks.
beatComplexity(wave, plot = FALSE)beatComplexity(wave, plot = FALSE)
wave |
A Wave object |
plot |
If TRUE a spectrogram overlaid with the peaks is plotted. |
A list of the complexity, a vector of the peak periods, and the number of peaks.
## Not run: beatComplexity(sheep) beatComplexity(sheep, plot=TRUE) ## End(Not run)## Not run: beatComplexity(sheep) beatComplexity(sheep, plot=TRUE) ## End(Not run)
Beat spectra represent the periodicity in signal amplitude. It is computed by performing a continuous wavelet transform on the envelope of a preprocessed signal, and processing the average power per frequency band.
beatSpectrum(wave, min_period = 0.005, max_period = 30, dj = 1/32, ...)beatSpectrum(wave, min_period = 0.005, max_period = 30, dj = 1/32, ...)
wave |
an R object or path to a wave file |
min_period |
the minimal rhythmicity period expected, in seconds |
max_period |
the maximal rhythmicity period expected, in seconds |
dj |
the frequency resolution of the cwt (in voices per octave) |
... |
extra arguments passed to |
a spectrum as a data frame.
It contains two columns: power and period.
The number of rows depend on the resolution and frequency range.
Quentin Geissmann
## Not run: beatSpectrum(sheep) beatSpectrum(sheep, min_period=0.005, max_period=30, dj=1/32) ## End(Not run)## Not run: beatSpectrum(sheep) beatSpectrum(sheep, min_period=0.005, max_period=30, dj=1/32) ## End(Not run)
This function takes a list of sound files and analyses them using the
BirdNET-Analyzer (Kahl et al. 2021). The function
either returns a data frame with the results of the analysis or a list of
Annotation objects.
birdNetAnalyse( files, lat = NULL, lon = NULL, date = NULL, output = "Annotation" )birdNetAnalyse( files, lat = NULL, lon = NULL, date = NULL, output = "Annotation" )
files |
A character vector of file paths. |
lat |
A latitude or vector of latitudes. |
lon |
A longitude or vector of longitudes. |
date |
A |
output |
One of "data.frame" or "Annotation". |
A list of Annotation objects, or a data frame if output is "data.frame".
Kahl S, Wood CM, Eibl M, Klinck H (2021). “BirdNET: A deep learning solution for avian diversity monitoring.” Ecological Informatics, 61.
## Not run: birdnetAnalyse(files=c("path/to/file1.wav", "path/to/file2.wav"), output="data.frame") ## End(Not run)## Not run: birdnetAnalyse(files=c("path/to/file1.wav", "path/to/file2.wav"), output="data.frame") ## End(Not run)
Used to process the output of acoustic index functions from the soundecology package when using allChannels.
channels_se(...)channels_se(...)
... |
Export from a bioacoustic index function from the soundecology package |
A list containing the value calculated for the left channel.
When plotting rings or horizons that are meant to cover the entirety of the time period in a dielPlot() or yearlyPlot() this function append the beginning values to the end to ensure an entire loop is created.
circularise(values)circularise(values)
values |
A vector if values |
The input vector with its first value appended, so that it closes on itself.
The concat() method is a more flexible version of the bind() method
from tuneR package, that allows specifying more advanced types of
concatenation. Setting method to "noClick" will remove any click between
Wave objects caused by sudden jumps in amplitude by applying tuneR::prepComb()
appropriately with default value of zero (this is only effective for the left
channel or stereo or multi-channel recordings).
concat(object, ..., method = "bind") ## S4 method for signature 'Wave' concat(object, ..., method = "bind") ## S4 method for signature 'WaveMC' concat(object, ..., method = "bind") ## S4 method for signature 'TaggedWave' concat(object, ..., method = "bind") ## S4 method for signature 'TaggedWaveMC' concat(object, ..., method = "bind")concat(object, ..., method = "bind") ## S4 method for signature 'Wave' concat(object, ..., method = "bind") ## S4 method for signature 'WaveMC' concat(object, ..., method = "bind") ## S4 method for signature 'TaggedWave' concat(object, ..., method = "bind") ## S4 method for signature 'TaggedWaveMC' concat(object, ..., method = "bind")
object |
A Wave like object. |
... |
Wave like objects to concatenate to object. |
method |
One of "bind", "noClick". Default is "bind". |
A concatenated Wave like object, with type of object.
Converts file size measurements into bytes. Both decimal units, which are powers of 1000, and binary units, which are powers of 1024, are accepted.
convert2bytes(S, input = "bits")convert2bytes(S, input = "bits")
S |
The value to convert |
input |
The unit to convert, one of those given by fileSizeUnits(), or "bits" or "bytes". |
The numeric value in bytes
convert2bytes(8, input="bits") convert2bytes(1, input="kB") convert2bytes(1, input="KiB")convert2bytes(8, input="bits") convert2bytes(1, input="kB") convert2bytes(1, input="KiB")
Converts temperature measurements into Celsius
convert2Celsius(temp, input = "K")convert2Celsius(temp, input = "K")
temp |
The value of the temperature to convert |
input |
The unit of the temperature to convert, allowed values are "K", "F". |
Numeric value in degrees Celsius
convert2Celsius(15, input="K") convert2Celsius(15, input="F")convert2Celsius(15, input="K") convert2Celsius(15, input="F")
Converts angle measurements into degrees
convert2degrees(A, input = "radians")convert2degrees(A, input = "radians")
A |
The angle value to convert |
input |
The unit of angle to convert, allowed values are "radians". |
The numeric value in degrees
Converts pressure measurements into dyne per square centimetre
convert2dyne_cm2(P, input = "kPa")convert2dyne_cm2(P, input = "kPa")
P |
The value of the pressure to convert |
input |
The unit of the pressure to convert, allowed values are "Pa", "kPa". |
The numeric value in dyne per square centimetre.
convert2dyne_cm2(1, input="Pa") convert2dyne_cm2(1, input="kPa")convert2dyne_cm2(1, input="Pa") convert2dyne_cm2(1, input="kPa")
Converts temperature measurements into Fahrenheit
convert2Fahrenheit(temp, input)convert2Fahrenheit(temp, input)
temp |
The value of the temperature to convert |
input |
The unit of the temperature to convert, allowed values are "K", "C". |
No return value, this conversion is not implemented and the function raises an error.
## Not run: convert2Fahrenheit(15, input = "C") ## End(Not run)## Not run: convert2Fahrenheit(15, input = "C") ## End(Not run)
Converts temperature measurements into Kelvin
convert2Kelvin(temp, input = "C")convert2Kelvin(temp, input = "C")
temp |
The value of the temperature to convert |
input |
The unit of the temperature to convert, allowed values are "C", "F". |
Numeric value in Kelvin
convert2Kelvin(15, input="C") convert2Kelvin(15, input="F")convert2Kelvin(15, input="C") convert2Kelvin(15, input="F")
Converts pressure measurements into Pascals
convert2Pascals(P, input = "kPa")convert2Pascals(P, input = "kPa")
P |
The value of the pressure to convert |
input |
The unit of the pressure to convert, allowed values are "kPa", "dyne_cm2". |
The numeric value in Pascals
convert2Pascals(1000, input="kPa") convert2Pascals(10, input="dyne_cm2")convert2Pascals(1000, input="kPa") convert2Pascals(10, input="dyne_cm2")
Converts angle measurements into radians
convert2radians(A, input = "degrees")convert2radians(A, input = "degrees")
A |
The angle value to convert |
input |
The unit of angle to convert, allowed values are "degrees". |
The numeric value in radians
Converts time measurements into seconds
convert2seconds(T, input = "minutes", origin = "day")convert2seconds(T, input = "minutes", origin = "day")
T |
The time value to convert |
input |
The unit of time to convert, allowed values are "minutes", "hours", "days", "years", "HHMM". |
origin |
For POSIX whether to return relative to start of day ("day") or Unix epoch ("unix") |
The numeric value in seconds
Uses the corenv function from seewave to calculate the envelope correlation for timed events between the channels of a WaveMC object
corWaveMC(wave, times, window, cluster = NULL, ...)corWaveMC(wave, times, window, cluster = NULL, ...)
wave |
A WaveMC object |
times |
One or more times of events to correlate |
window |
Width of the window to correlate in seconds (centred on times) |
cluster |
A cluster for parallel execution |
... |
Additional arguments passed to |
The delays are the offsets corenv() reports, with the sign changed so that a
positive delay means the sound arrived at that channel later than it arrived
at the first channel, which is the convention tdoa() and bearing() use.
corenv() resolves an offset only to a whole sample, and reports any delay of
zero or less as one sample greater than it is. tdoa() with
method="envelope" measures the same thing without either limitation, and its
output can be passed to bearing().
corenv() correlates ranks rather than values unless it is told otherwise,
which for a recording with quiet stretches between events can put the largest
correlation at no offset at all whatever the offset really is. Pass
method="pearson" if the delays look implausible.
A list with one entry per event, each holding the corenv list for
every channel in correlations, and the delay of every channel relative to
the first in delays (see Details).
tdoa(), which measures the time differences of arrival between
channels, and bearing(), which turns them into a direction.
Extract a section of a Wave or WaveMC object based on sample positions. This function will automatically detect if a Wave object is stereo, and returns the same class of object it was given.
cutws(wave, from = 1, to = Inf, plot = FALSE)cutws(wave, from = 1, to = Inf, plot = FALSE)
wave |
A Wave or WaveMC object |
from |
First sample to return |
to |
Last sample to return |
plot |
If TRUE shows the cut region within the original waveform |
A Wave or WaveMC object
## Not run: cutws(sheep, 1, 20) cutws(sheep, 1, 20, plot=TRUE) ## End(Not run)## Not run: cutws(sheep, 1, 20) cutws(sheep, 1, 20, plot=TRUE) ## End(Not run)
Make a sequence of data into a normalised Wave object.
data2Wave( left, samp.rate = 44100, bit = 16, unit = NULL, remove.offset = TRUE, normalise = TRUE )data2Wave( left, samp.rate = 44100, bit = 16, unit = NULL, remove.offset = TRUE, normalise = TRUE )
left |
Data for mono audio channel |
samp.rate |
Sampling rate for Wave object |
bit |
Bit depth of Wave object |
unit |
See tuneR::normalize. If NULL this is handled automatically. |
remove.offset |
If TRUE any DC offset is removed |
normalise |
If TRUE the output Wave is normalised to the range implied by
|
A mono Wave object.
pattern <- seq(from=-1, to=1, length.out=100) data <- rep.int(pattern, 100) w <- data2Wave(data)pattern <- seq(from=-1, to=1, length.out=100) data <- rep.int(pattern, 100) w <- data2Wave(data)
Given a start time and (optionally) a duration returns the phase of day at a given location. This is primarily used to calculate phase of day information for soundscape recording projects.
dayPhase( time = Sys.time(), duration = 40000, lat = 50.1, lon = 1.83, tz = "UTC" )dayPhase( time = Sys.time(), duration = 40000, lat = 50.1, lon = 1.83, tz = "UTC" )
time |
A time object representing the start time of a recording |
duration |
Duration of recording in seconds |
lat |
Latitude of recording device |
lon |
Longitude of recording device |
tz |
Time-zone of recording device when recording was made |
Data frame of day phases with absolute timestamps and relative times within file
dayPhase(time=as.POSIXct("2024-06-15 20:00:00", tz="UTC"), duration=40000)dayPhase(time=as.POSIXct("2024-06-15 20:00:00", tz="UTC"), duration=40000)
Phases of days
daysPhases( date = Sys.Date(), period = "year", plot = FALSE, lat = 50.1, lon = 1.83, tz = "UTC" )daysPhases( date = Sys.Date(), period = "year", plot = FALSE, lat = 50.1, lon = 1.83, tz = "UTC" )
date |
A time object representing the start time of a recording |
period |
"month" or "year" |
plot |
If true plots the data, default FALSE |
lat |
Latitude of recording device |
lon |
Longitude of recording device |
tz |
Time-zone of recording device when recording was made |
A data frame with a row for each day, giving the times of each phase of the day and the state of the moon.
daysPhases(date=as.Date("2024-06-15"), period="month")daysPhases(date=as.Date("2024-06-15"), period="month")
Creates a default cluster using one less than the total cores available on the system. By default this uses forking, which is not be available on Windows. Hence, the fork parameter has no effect on Windows.
defaultCluster(fork = TRUE)defaultCluster(fork = TRUE)
fork |
If TRUE uses forking to create the cluster (Unix like systems only) |
A cluster object for parallel processing
## Not run: cl <- defaultCluster() stopCluster(cl) cl <- defaultCluster(FALSE) stopCluster(cl) ## End(Not run)## Not run: cl <- defaultCluster() stopCluster(cl) cl <- defaultCluster(FALSE) stopCluster(cl) ## End(Not run)
Given an object that can be coerced to POSIXlt or is in a supported string format, return the fraction of a day represented by the object.
dielFraction(t, input = "POSIX", unit = "radians")dielFraction(t, input = "POSIX", unit = "radians")
t |
Object to be converted to a fraction |
input |
One of POSIX (default) or HHMM |
unit |
If set to radians outputs a position around a circle. If set to fraction outputs the raw fraction. |
The position of the time within the day, in radians or as a fraction of a day.
Draws a histogram on a dielPlot() using pre-defined bins related to time of day.
dielHistogram( times, by = "hour", col = "grey", maxval = NA, presence.only = FALSE, limits = c(1, 2), rot = tzRot(0) )dielHistogram( times, by = "hour", col = "grey", maxval = NA, presence.only = FALSE, limits = c(1, 2), rot = tzRot(0) )
times |
A vector of times that can be processed by dielFraction(). |
by |
Controls the size of histogram bins, one of "hour", "15minute", "30minute". |
col |
Colour of the plot. |
maxval |
By default scales histogram within limits, specifying a maximum value here allows comparison between plots. |
presence.only |
Only show presence/absence not values. |
limits |
Limits of the plotting (see dielPlot()). |
rot |
Rotation of the plot, which must match the dielPlot() being drawn on. |
A data frame of start and end points of bins.
Generates labels for a dielPlot() in 12- or 24-hour format. Labels are generated at three hourly intervals.
dielLabels(format = "clock24")dielLabels(format = "clock24")
format |
One of clock24 (default) or clock12 |
A character vector of eight labels, at three hourly intervals.
dielLabels() dielLabels("clock12")dielLabels() dielLabels("clock12")
A diel plot shows the times of night, twilight and the maximum altitude of the sun for a given date.
dielPlot( date, lat, lon, limits = c(0, 2), plot = NULL, rot = tzRot(0), method = "plotrix", legend = FALSE )dielPlot( date, lat, lon, limits = c(0, 2), plot = NULL, rot = tzRot(0), method = "plotrix", legend = FALSE )
date |
Date to plot. |
lat |
Numeric latitude. |
lon |
Numeric longitude. |
limits |
Plotting limits of the daylight regions, default to c(1,2) |
plot |
Character vector of components to plot |
rot |
Either "Solar Noon" or an offset calculated by tz |
method |
Plotting library to use |
legend |
Whether to show a legend |
Called for its side effect of drawing a plot. The return value is that of the underlying plotting function and should not be relied on.
Generates positions for three-hourly labels of a dielPlot() in radians.
dielPositions(format = "3hourly")dielPositions(format = "3hourly")
format |
One of "3hourly" (default), "hours", or "minutes" |
A numeric vector of label positions, in radians.
dielPositions() dielPositions("hours") dielPositions("minutes")dielPositions() dielPositions("hours") dielPositions("minutes")
Plot rings on a diel plot.
dielRings( names, starts, ends, cols = "grey", format = "HHMM", limits = c(1, 2), legend = TRUE, rot = tzRot(0) )dielRings( names, starts, ends, cols = "grey", format = "HHMM", limits = c(1, 2), legend = TRUE, rot = tzRot(0) )
names |
Labels for the rings |
starts |
Start times for rings in HHMM string format |
ends |
End times for rings in HHMM string format |
cols |
Colours of the rings |
format |
Defaults to HHMM |
limits |
Region of a dielPlot() to plot rings. Defaults to c(1,2) |
legend |
Boolean. Whether to plot a legend. |
rot |
Rotation of the plot, which must match the dielPlot() being drawn on. |
Called for its side effect of drawing on the current plot. The return value is that of the underlying plotting function and should not be relied on.
Dolbear (1897) was the first to publish a formula for how the rate of chirping of crickets varies with temperature, using the tree cricket Oecanthus fultoni.
dolbear(n = NULL, t = NULL, species = "Oecanthus fultoni")dolbear(n = NULL, t = NULL, species = "Oecanthus fultoni")
n |
Chirps per minute |
t |
Temperature in Celsius |
species |
Species to use (by default Oecanthus fultoni), NULL to calculate for all species. |
Subsequent research by Dolbear and others have published additional formulae for other species: Oecanthus fultoni (Fulton 1925), Oecanthus rileyi (Walker 1962), Oecanthus alexanderi (Walker and Collins 2010), and Oecanthus allardi (Allard 1957).
Data frame with t and n calculated for matching species.
Allard HA (1957).
“The stridulations of some crickets in the Dominican Republic.”
Journal Washington Academy of Sciences, 47, 150–152.
Dolbear AE (1897).
“The Cricket as a Thermometer.”
The American Naturalist, 31(371), 970–971.
ISSN 00030147, 15375323.
http://www.jstor.org/stable/2453256.
Fulton BB (1925).
“Physiological variation in the snowy tree cricket, Oecanthus fultoni, De Geer.”
Annals of the Entomological Society of America, 18, 363–383.
Walker TJ (1962).
“The taxonomy and calling songs of United States tree crickets (Orthoptera: Gryllidae: Oecanthinae). I. The genus Neoxabea and the niveus and varicornis groups of the genus Oecanthus.”
Annals Entomological Society of America, 55, 303–322.
http://entnemdept.ifas.ufl.edu/walker/Buzz/s576lw62.pdf.
Walker TJ, Collins N (2010).
“New World thermometer crickets: the Oecanthus rileyi species group and a new species from North America.”
Journal of Orthoptera Research, 19(2).
ISSN 10826467, 19372426.
http://www.jstor.org/stable/25822725.
dolbear(n=6) dolbear(t=25)dolbear(n=6) dolbear(t=25)
Proportion of a wave with signal above the limit
dutyCycle(wave, limit = 0.1, output = "unit", normalise = TRUE)dutyCycle(wave, limit = 0.1, output = "unit", normalise = TRUE)
wave |
A Wave object. Stereo Wave and WaveMC objects are passed to allChannels(), which returns a list with one duty cycle per channel. |
limit |
Threshold above which to consider the signal |
output |
If "unit" the duty cycle will be in the range 0-1. For a percentage use "percent". |
normalise |
If TRUE the Wave is normalised using tuneR |
A numerical value for the duty cycle between 0 and 1 (or 0 and 100% if percentage output). For multi-channel input, a list of such values.
wave <- tuneR::sine(2000) dc <- dutyCycle(wave) pc <- dutyCycle(wave, output="percent")wave <- tuneR::sine(2000) dc <- dutyCycle(wave) pc <- dutyCycle(wave, output="percent")
Create a diel plot with labels but without sun altitude or times of day plotted.
emptyDiel(method = "plotrix", rot = pi)emptyDiel(method = "plotrix", rot = pi)
method |
Plotting package to use |
rot |
Rotation of the origin (defaults to pi) |
Called for its side effect of drawing a plot. The return value is that of the underlying plotting function and should not be relied on.
Create a yearly plot with labels but without sun or night duration plotted.
emptyYearly(year = 2022, method = "plotrix", rot = pi)emptyYearly(year = 2022, method = "plotrix", rot = pi)
year |
Year to plot (allows for leap years) |
method |
Plotting package to use |
rot |
Rotation of the origin (defaults to pi) |
Called for its side effect of drawing a plot. The return value is that of the underlying plotting function and should not be relied on.
Calculates the peak, centre, bandwidth and quality factor. The quality factor (Q) is calculated at both -3dB and -10dB as discussed by Bennett-Clark (1999) https://doi.org/10.1080/09524622.1999.9753408.
entropyStats(wave)entropyStats(wave)
wave |
A Wave object. Stereo Wave and WaveMC objects are passed to allChannels(), which returns one set of statistics per channel. |
A list of spectral entropy types. For multi-channel input, one such list per channel.
## Not run: entropyStats(sheep) ## End(Not run)## Not run: entropyStats(sheep) ## End(Not run)
Calculates a false-colour index spectrogram, in which three acoustic indices are calculated for each frequency bin of each time window and mapped to the red, green and blue channels of an image. Long recordings can be summarised in a single image, with different sounds appearing as different colours.
fcis( x, window.length = NULL, indices = c("power", "ACI", "entropy"), wl = 256, cluster = NULL )fcis( x, window.length = NULL, indices = c("power", "ACI", "entropy"), wl = 256, cluster = NULL )
x |
A Wave object, or a vector of filenames which are treated as consecutive parts of one recording. |
window.length |
Length of each column of the image in samples. If NULL, each file gives a single column. |
indices |
The three indices to map to the red, green and blue channels. |
wl |
Window length used for the spectrograms. |
cluster |
A cluster from the 'parallel' package for multi-core computation. This is only worthwhile when x is a filename and the windows are long, as each worker then reads its own part of the file. Passing a Wave object sends a copy of it to every worker, which takes longer than the calculation itself. |
Indices are scaled across the whole of the input, so that colours are comparable
between the windows of one spectrogram but not between separate spectrograms. The
available indices are described in fcisIndexNames.
An object of class "fcis", being a list of the colours as a character matrix of one entry per frequency bin and window, the matrix of values for each index, the frequencies of the bins in kHz, the duration of a window in seconds, and the names of the indices used.
## Not run: f <- fcis(wave, window.length=44100) plot(f) f <- fcis(wave, window.length=44100, indices=c("background", "ACI", "cover")) ## End(Not run)## Not run: f <- fcis(wave, window.length=44100) plot(f) f <- fcis(wave, window.length=44100, indices=c("background", "ACI", "cover")) ## End(Not run)
The indices available as channels of a false-colour index spectrogram. Each is calculated separately for every frequency bin of a spectrogram, giving one value per bin rather than one value for the whole signal.
fcisIndexNames()fcisIndexNames()
Mean of the squared amplitude.
Acoustic complexity index, the summed absolute difference between consecutive time frames, divided by the total amplitude in the bin.
Temporal entropy of the amplitude, scaled to between 0 and 1. A bin whose amplitude is constant over time has an entropy of 1.
An estimate of the background level, taken as the tenth percentile of the amplitude over time.
The proportion of time frames whose amplitude is more than three times the background level of the bin.
A character vector of index names.
fcisIndexNames()fcisIndexNames()
The units understood by convert2bytes() and produced by humanBytes(). Decimal units are powers of 1000 and binary units are powers of 1024.
fileSizeUnits(units = "decimal")fileSizeUnits(units = "decimal")
units |
One of "decimal" or "binary" |
A character vector of unit names, from smallest to largest.
fileSizeUnits() fileSizeUnits("binary")fileSizeUnits() fileSizeUnits("binary")
A WaveFilter object is an object containing information necessary for the filterw function to apply the filter to a Wave object. This is designed to allow a pipe operator (either magrittr or base R) to be used to apply filters to a Wave in a pipeline.
filterWave(w, filt, cl = NULL)filterWave(w, filt, cl = NULL)
w |
A Wave object. |
filt |
Wave object with the selected filter applied. |
cl |
Optional. If a cluster is specified, the filter will be applied in parallel. |
Supported filters include those from the seewave package.
A filtered Wave or WaveMC object, or a list of such objects if given a list.
Calculates the frequency of a sound wave given the wavelength and speed of sound in that medium.
frequencySound(wl, s = soundSpeed(medium = "air"))frequencySound(wl, s = soundSpeed(medium = "air"))
wl |
Wavelength |
s |
Speed of sound (defaults to the speed of sound in air) |
Frequency of the sound in Hertz
f <- frequencySound(wl=100, s=343)f <- frequencySound(wl=100, s=343)
Calculates the peak, centre, bandwidth and quality factor. The quality factor (Q) is calculated at both -3dB and -10dB as discussed by Bennett-Clark (1999) <doi: 10.1080/09524622.1999.9753408>.
frequencyStats(wave, wave_spec = NULL, warn = TRUE, lowcut = 1, plot = FALSE)frequencyStats(wave, wave_spec = NULL, warn = TRUE, lowcut = 1, plot = FALSE)
wave |
A Wave object. Stereo Wave and WaveMC objects are passed to allChannels(), which returns one set of statistics per channel. |
wave_spec |
A precomputed spectrum (optional, if not present will be generated) |
warn |
If TRUE provides warnings when values are not consistent |
lowcut |
Frequency (in kHz) values below which are ignored. |
plot |
IF TRUE displays values |
A list of frequency statistics, with an entry for each of the -3dB and -10dB thresholds.
Adding noise to a Wave like object allows for testing of the robustness of automated identification algorithms to noise.
generateNoise( wave, noise = c("white"), noise.add = FALSE, noise.ratio = 0.5, noise.ref = "file", output = "list" )generateNoise( wave, noise = c("white"), noise.add = FALSE, noise.ratio = 0.5, noise.ref = "file", output = "list" )
wave |
Object to add noise to ( |
noise |
Vector of noise to add (unif, gaussian, white, pink, power, red) |
noise.add |
If TRUE all noise sources are added to wave. If FALSE separate outputs are created for each noise source. |
noise.ratio |
Ratio of maximum noise amplitude to the maximum amplitude in wave. |
noise.ref |
Reference maximum for noise.ratio. If "max" then the maximum amplitude, if "file" then the maximum amplitude of wave. |
output |
TODO: Is this implemented? |
A list of Wave objects with the required noise added.
Given a Wave-like object (or a list of Wave-like objects), generate
new Wave-like objects with time masking.
generateTimeMask(wave, method = "squarewave", dutyCycle = 0.95, n.periods = 10)generateTimeMask(wave, method = "squarewave", dutyCycle = 0.95, n.periods = 10)
wave |
A |
method |
The method to use for time masking (one of "squarewave", "random). |
dutyCycle |
The duty cycle of the output. A value of 0.95 means that 5% of the time is masked. |
n.periods |
The number of waves to generate in the squarewave method. |
The Wave or WaveMC object with the time mask applied.
Given a Wave-like object (or list of Wave-like objects), this function generates time-shifted versions of the object. The time-shifted versions are generated by adding a constant amount of time to the start or end of the object. This is achieved by either inserting silence and truncating the object to the original length, or by rotating the audio within the object.
generateTimeShift(wave, type = "silent", amount = c(1, 2), where = "start")generateTimeShift(wave, type = "silent", amount = c(1, 2), where = "start")
wave |
A Wave or WaveMC object, or a list of such objects. |
type |
The type of time-shift to apply. Either "silent" or "rotate". |
amount |
Vector of amount of time to shift by (seconds). |
where |
Where to insert silence if |
A Wave-like object or list of Wave-like objects.
Imports the scikit-maad object into R. This allows reuse of the same object between function calls.
getMaad()getMaad()
The scikit-maad Python module, with its sound and features submodules attached.
Wrapper around various Google packages to simplify speech transcription.
gs_transcribe(filename, bucket = NULL, ...)gs_transcribe(filename, bucket = NULL, ...)
filename |
Path to file for analysis |
bucket |
Storage bucket on Google Cloud for larger files |
... |
Additional arguments to pass to gl_speech() |
A gs_transcribe object containing details of the transcription
## Not run: gs_transcribe("demo.wav") ## End(Not run)## Not run: gs_transcribe("demo.wav") ## End(Not run)
Given an input of bytes calculates the result in a sensible output unit (e.g. MB, GB, PB). Decimal units are powers of 1000, and binary units powers of 1024.
humanBytes(S, units = "decimal", digits = 3)humanBytes(S, units = "decimal", digits = 3)
S |
Number of bytes. A vector may be given. |
units |
One of "decimal", giving units such as kB, or "binary", giving units such as KiB. |
digits |
Number of decimal places to round to, or NULL for no rounding. |
String in human readable format, one for each value of S.
humanBytes(1500) humanBytes(1500, units="binary") humanBytes(c(1, 1024, 1e6))humanBytes(1500) humanBytes(1500, units="binary") humanBytes(c(1, 1024, 1e6))
Given a time calculates the result in a sensible output unit (e.g. minutes, hours).
humanTime(S, unit = "seconds", digits = 3)humanTime(S, unit = "seconds", digits = 3)
S |
Time to convert in unit. A vector may be given. |
unit |
The unit of time to convert |
digits |
Number of decimal places to round to, or NULL for no rounding. |
String in human readable format, one for each value of S.
humanTime(90) humanTime(c(1, 90, 7200)) humanTime(1, unit="hours")humanTime(90) humanTime(c(1, 90, 7200)) humanTime(1, unit="hours")
Jitter is a measure of the variability of the length of successive periods in the waveform. Absolute jitter is the mean absolute difference between the lengths of consecutive periods, in samples; relative jitter divides this by the mean period length. A waveform of constant period has a jitter of zero.
jitter(wave, method = "absolute")jitter(wave, method = "absolute")
wave |
A Wave object |
method |
One of "absolute" or "relative" |
Periods are located from zero crossings, so they are measured to the nearest sample. A tone whose period is not a whole number of samples will report a small amount of jitter for this reason.
The jitter, in samples for method "absolute" and as a proportion of the mean period for method "relative"
## Not run: jitter(sheep, method="absolute") jitter(sheep, method="relative") ## End(Not run)## Not run: jitter(sheep, method="absolute") jitter(sheep, method="relative") ## End(Not run)
Takes labels from Google Speech API transcript and pads the time by a specified number of seconds.
labelPadding(t, pad = 0.5, max_t = NULL)labelPadding(t, pad = 0.5, max_t = NULL)
t |
Transcript from Google Speech API |
pad |
Amount of time (in seconds) to add to start and end |
max_t |
Optional. The duration of the file, so padding does not exceed length of file. |
A modified Google Speech API transcript object
## Not run: labelPadding(t, pad=2, max_t=duration(wave)) ## End(Not run)## Not run: labelPadding(t, pad=2, max_t=duration(wave)) ## End(Not run)
Takes labels from Google Speech API transcript and combines overlapping labels.
labelReduction(t)labelReduction(t)
t |
Transcript from Google Speech API |
A list containing start and end times of speech containing regions
## Not run: labelReduction(t) ## End(Not run)## Not run: labelReduction(t) ## End(Not run)
ACI depends on the duration of the spectrogram as the derivation of the signal is normalized by the sum of the signal. Thus, if the background noise is high due to high acoustic activity the normalization by the sum of the signal reduced ACI. So ACI is low when there is no acoustic activity or high acoustic activity with continuous background noise. ACI is high only when acoustic activity is medium, with sounds well above the background noise.
maad_acoustic_complexity_index(object, maad = NULL)maad_acoustic_complexity_index(object, maad = NULL)
object |
A Wave object or a spectrogram_maad object generated by
|
maad |
An optional maad object. If not provided, one will be created using |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.temporal_acoustic_complexity_index.html (Pieretti et al. 2011).
List comprising:
ACI_xx |
Acoustic Complexity Index. |
ACI_per_bin |
Acoustic Complexity Index. |
ACI_sum |
Sum of ACI value per frequency bin (Common definition) |
Pieretti N, Farina A, Morri D, Gage SH (2011). “A new methodology to infer the singing activity of an avian community: the Acoustic Complexity Index (ACI).” Ecological Indicators, 11, 868–873. doi:10.1016/j.ecolind.2010.11.005.
The spectral entropy of a signal measures the energy dispersion along frequencies. Low values indicates a concentration of energy around a narrow frequency band. If the DC value is not removed before processing the large peak at f=0Hz will lower the entropy of the signal.
maad_frequency_entropy(object, compatibility = "QUT", maad = NULL)maad_frequency_entropy(object, compatibility = "QUT", maad = NULL)
object |
A Wave object or a spectrogram_maad object generated by
|
compatibility |
One of "QUT" (Towsey et al. 2018) or "seewave" (Sueur et al. 2008). Default is "QUT". |
maad |
An optional maad object. If not provided, one will be created using |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.frequency_entropy.html
List comprising:
Hf |
Frequency entropy. |
Ht_per_bin |
Temporal entropy per frequency bin. |
Sueur J, Aubin T, Simonis C (2008).
“Seewave, a free modular tool for sound analysis and synthesis.”
Bioacoustics, 18(2), 213–226.
Towsey M, Truskinger A, Cottman-Fields M, Roe P (2018).
“Ecoacoustics Audio Analysis Software.”
https://github.com/QutEcoacoustics/audio-analysis.
Count the number of frequency peaks on a mean spectrum. This function was adapted from the function fpeaks of the R package Seewave (Sueur et al. 2008).
maad_number_of_peaks( object, mode = "dB", min_peak_val = NULL, min_freq_dist = 200, slopes = c(1, 1), prominence = 0, maad = NULL )maad_number_of_peaks( object, mode = "dB", min_peak_val = NULL, min_freq_dist = 200, slopes = c(1, 1), prominence = 0, maad = NULL )
object |
A Wave object or a spectrogram_maad object generated by
|
mode |
One of "dB", "linear". |
min_peak_val |
Only peaks above this threshold will be considered. |
min_freq_dist |
Frequency threshold parameter (in Hz). If the frequency difference of two successive peaks is less than this threshold, then the peak of highest amplitude will be kept only. |
slopes |
Refers to the amplitude slopes of the peak. The first value is the left slope and the second value is the right slope. Only peaks with higher slopes than threshold values will be kept. |
prominence |
The first element is the minimal prominence and the second element is the maximal prominence. If a single number is provided it is interpreted as the minimal value, and no maximal value will be used. |
maad |
An optional maad object. If not provided, one will be created
using |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.number_of_peaks.html
Numeric number of peaks
Acoustic activity corresponds to the portion of the spectrogram above a threshold frequency per frequency along time axis (Towsey 2017).
maad_spectral_activity(object, dB_threshold = 6, maad = NULL)maad_spectral_activity(object, dB_threshold = 6, maad = NULL)
object |
A Wave object or a spectrogram_maad object. |
dB_threshold |
dB threshold of activity (default = 6). |
maad |
An optional maad object. If not provided, one will be created using |
The function computes for each frequency bin:
ACTfract |
Proportion (fraction) of points above the threshold. |
ACTcount |
Total number of points above the threshold. |
ACTmean |
Mean value (in dB) of the portion of the signal above the threshold. |
Towsey M (2017). “The calculation of acoustic indices derived from long-duration recordings of the natural environment.” Queensland University of Technology. https://eprints.qut.edu.au/110634/1/QUTePrints110634_TechReport_Towsey2017August_AcousticIndices%20v3.pdf.
Compute different entropies based on the average spectrum, its variance, and its maxima.
maad_spectral_entropy(object, flim = NULL, maad = NULL)maad_spectral_entropy(object, flim = NULL, maad = NULL)
object |
A Wave object or a spectrogram_maad object generated by
|
flim |
A numeric vector of length 2 specifying the frequency limits for the entropy calculation. |
maad |
An optional maad object. If not provided, one will be created using |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.spectral_entropy.html
List comprising:
EAS |
Entropy of Average Spectrum. |
ECU |
Entropy of spectral variance (along the time axis for each frequency). |
ECV |
Entropy of Coefficient of Variation (along the time axis for each frequency). |
EPS |
Entropy of spectral maxima (peaks). |
EPS_KURT |
Kurtosis of spectral maxima. |
EPS_SKEW |
Skewness of spectral maxima. |
This is a wrapper function for the maad.sound.spectrogram function
from the scikit-maad package for Python. It computes the spectrogram of a
sound wave. Further usage details are provided at
https://maad.readthedocs.io/en/latest/maad.sound.html#maad.sound.spectrogram.
maad_spectrogram(wave, mode = "power", ..., maad = NULL)maad_spectrogram(wave, mode = "power", ..., maad = NULL)
wave |
A Wave object |
mode |
The type of spectrogram to compute. Options are "power", "amplitude" "complex". Default is "power". |
... |
Additional arguments to pass to |
maad |
An optional |
Generically a spectrogram_maad object.
This is a wrapper function for the maad.sound.spectrum function.
It computes the spectrum of a sound wave. Further usage details are provided at
https://maad.readthedocs.io/en/latest/maad.sound.html#maad.sound.spectrum.
maad_spectrum(wave, ..., maad = NULL)maad_spectrum(wave, ..., maad = NULL)
wave |
A Wave object |
... |
Additional arguments to pass to |
maad |
An optional |
A list comprising:
pxx |
Power spectral density estimate. |
f_idx |
Index of sample frequencies. |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.temporal_activity.html (Towsey 2013).
maad_temporal_activity( wave, dB_threshold = 3, mode = "fast", Nt = 512, maad = NULL )maad_temporal_activity( wave, dB_threshold = 3, mode = "fast", Nt = 512, maad = NULL )
wave |
A Wave object. |
dB_threshold |
dB threshold of activity (default = 3). |
mode |
Mode of the envelope calculation. Can be "fast" or "Hilbert". |
Nt |
Size of each frame. The largest, the highest is the approximation. |
maad |
An optional maad object. If not provided, one will be created using |
List of calculated values, comprising:
ACTfrac |
fraction)of points above the threshold for each frequency bin. |
ACTcount |
total number of points above the threshold for each frequency bin. |
ACTmean |
mean value (in dB) of the portion of the signal above the threshold. |
Towsey M (2013). “Noise Removal from Waveforms and Spectrograms Derived from Natural Recordings of the Environment.” Queensland University of Technology. https://eprints.qut.edu.au/216373/.
For addition documentation see https://scikit-maad.github.io/generated/maad.features.temporal_entropy.html.
maad_temporal_entropy( wave, compatibility = "QUT", mode = "fast", Nt = 512, maad = NULL )maad_temporal_entropy( wave, compatibility = "QUT", mode = "fast", Nt = 512, maad = NULL )
wave |
A Wave object. |
compatibility |
One of "QUT" (Towsey et al. 2018), "seewave" (Sueur et al. 2008). |
mode |
Mode of the envelope calculation. Can be "fast" or "hilbert". |
Nt |
Size of each frame. The largest, the highest is the approximation. |
maad |
An optional maad object. If not provided, one will be created using |
Numeric entropy of the envelope.
Sueur J, Aubin T, Simonis C (2008).
“Seewave, a free modular tool for sound analysis and synthesis.”
Bioacoustics, 18(2), 213–226.
Towsey M, Truskinger A, Cottman-Fields M, Roe P (2018).
“Ecoacoustics Audio Analysis Software.”
https://github.com/QutEcoacoustics/audio-analysis.
An acoustic event corresponds to the period of the signal above a threshold. An acoustic event could be short (at list one point if rejectDuration is None) or very long (the duration of the entire audio). Two acoustic events are separated by a period with low audio signal (i.e. below the threshold).
maad_temporal_events( wave, dB_threshold = 3, rejectDuration = 0.1, mode = "fast", Nt = 512, maad = NULL )maad_temporal_events( wave, dB_threshold = 3, rejectDuration = 0.1, mode = "fast", Nt = 512, maad = NULL )
wave |
A Wave object. |
dB_threshold |
dB threshold of activity (default = 3). |
rejectDuration |
Duration of the silence to reject an acoustic event (default = 0.1). |
mode |
Mode of the envelope calculation. Can be "fast" or "Hilbert". |
Nt |
Size of each frame. The larger, the highest is the approximation. |
maad |
An optional maad object. If not provided, one will be created using |
For addition documentation see https://scikit-maad.github.io/generated/maad.features.temporal_events.html (Towsey 2013) (Towsey et al. 2018).
List of calculated values, comprising:
EVTfrac |
fraction of points above the threshold for each frequency bin. |
EVTcount |
total number of points above the threshold for each frequency bin. |
EVTmean |
mean value (in dB) of the portion of the signal above the threshold. |
EVN |
logical vector or matrix with 1 corresponding to event position. |
Towsey M (2013).
“Noise Removal from Waveforms and Spectrograms Derived from Natural Recordings of the Environment.”
Queensland University of Technology.
https://eprints.qut.edu.au/216373/.
Towsey M, Truskinger A, Cottman-Fields M, Roe P (2018).
“Ecoacoustics Audio Analysis Software.”
https://github.com/QutEcoacoustics/audio-analysis.
For addition documentation see https://scikit-maad.github.io/generated/maad.features.temporal_median.html.
maad_temporal_median(wave, mode = "fast", Nt = 512, maad = NULL)maad_temporal_median(wave, mode = "fast", Nt = 512, maad = NULL)
wave |
A Wave object. |
mode |
Mode of the envelope calculation. Can be "fast" or "hilbert". |
Nt |
Size of each frame. The largest, the highest is the approximation. |
maad |
An optional maad object. If not provided, one will be created using |
Numeric median of the envelope.
Maps three vectors of equal length to RGB for use in false-colour index spectrograms
map2RGB(red, green, blue)map2RGB(red, green, blue)
red |
The red channel vector |
green |
The green channel vector |
blue |
The blue channel vector |
A vector of RGB values
Checks a list of annotations for those that are overlapping in the time or
frequency domain, and returns a list where overlapping annotations are merged.
Annotation objects must have the same file, type and value to be merged.
merge_annotations(annotations, domain = "time", same.source = TRUE)merge_annotations(annotations, domain = "time", same.source = TRUE)
annotations |
A list of Annotation objects. |
domain |
Domain of the annotations, either "time" or "frequency". |
same.source |
If TRUE, annotations must have the same source to be merged. |
A list of Annotation objects.
Calculates the natural frequency given the inductance, capacitance and resistance. In the acoustic case the inductance is inertia or mass, the capacitance is elasticity (bulk modulus) and resistance is composed of air resistance and related quantities. All units are SI.
naturalFrequency(L, C = NULL, R)naturalFrequency(L, C = NULL, R)
L |
Inductance |
C |
Capacitance, by default IUPAC standard pressure. |
R |
Resistance |
For isothermal compression, the bulk modulus is equal to the pressure. The default value of C therefore is the IUPAC standard pressure.
The natural frequency, in Hertz.
naturalFrequency(L=20,R=0.5) naturalFrequency(L=20,C=1/4,R=0.5)naturalFrequency(L=20,R=0.5) naturalFrequency(L=20,C=1/4,R=0.5)
Similar to normalize() from the tuneR package but automatically identifies the unit parameter.
normalise(wave, unit = NULL, ...)normalise(wave, unit = NULL, ...)
wave |
Wave or WaveMC object |
unit |
If not null behaves as in normalize() from tuneR, if null the unit is automatically identified. |
... |
Additional arguments passed to normalize() from tuneR |
Normalised Wave or WaveMC object
Runs a function on the wave and outputs values in the Natural Time Domain (see Varotsos, Sarlis & Skordas(2011) https://doi.org/10.1007/978-3-642-16449-1).
ntd(wave, events, FUN, normalise = FALSE, argument = "wave", ...)ntd(wave, events, FUN, normalise = FALSE, argument = "wave", ...)
wave |
A Wave object containing pulses |
events |
Onset of detected events, e.g. from pulseDetection() |
FUN |
The function to run |
normalise |
If TRUE the output is a probability density |
argument |
If "wave" supplies a weave object to the function, if "vector" supplies the left channel as a numeric vector. |
... |
Additional arguments to FUN |
A list of outputs form the applied function
Attempts to extract meaningful information from a filename, typically the date and time a recording started.
parseFilename(file, format = NULL, timezone = "UTC")parseFilename(file, format = NULL, timezone = "UTC")
file |
A filename (or list of filenames). |
format |
Optionally force a given format (see Details). If NULL (default) an attempt is made to automatically detect the format for each file. If "match" and a list of filenames is given then an attempt will be made to find a format that matches all files. This may give incorrect results if the filename is ambiguous (see Details). |
timezone |
The timezone the clock of the recorder was set to, defaults to "UTC" (see Details). |
It is sometimes impossible to accurately determine the format of a filename, e.g. when an eight-digit 'AudioMoth HEX' only contains numbers it could be confused with a YYYYMMDD format. If a list of filenames is given and the "match" format is specified then an effort will be made to determine the most likely format that applies to all filenames.
Most supported formats write a wall clock (e.g. 20200609_191730) into the
filename, with no indication of the timezone the clock of the recorder was
set to. The timezone argument states which timezone that wall clock
belongs to, and defaults to UTC, which is what AudioMoth devices use unless
they are configured otherwise. The datetime returned is therefore the same
instant whatever timezone the machine running the analysis is set to.
The 'AudioMoth HEX' and 'timestamp' formats are exceptions: these encode an
instant rather than a wall clock, so for them timezone only sets the
timezone the datetime is displayed in.
AudioMoth - The newer format for AudioMoth devices consists of a standard YYYYMMDD_HHMMSS.wav format. An eight character hexadecimal filename given this format is treated as 'AudioMoth HEX'.
AudioMoth HEX - Older format for AudioMoth devices consisting of eight
hexadecimal characters giving the number of seconds since
1970-01-01 00:00:00 UTC. Conversion is handled by a call to the
audiomoth() function from the seewave package
(Sueur et al. 2008).
timestamp - A standard date-time format. Uses the R standard origin of 1970-01-01 00:00:00 UTC.
Wildlife Acoustics SM2 - Can also be used for Wildlife Acoustics SM4
devices. The filename is split by a call to seewave::songmeter().
Wildlife Acoustics SM3 - The filename is split by a call to
seewave::songmeter().
YYYYMMDD_HHMMSS - A standard date-time format.
YYYYMMDD - A standard date format, the time is taken to be midnight.
A list of file, type of match, datetime. If a list of filenames is
given then a list of such lists is returned.
It is possible to determine additional properties from some files, these will
be added to the list.
Sueur J, Aubin T, Simonis C (2008). “Seewave, a free modular tool for sound analysis and synthesis.” Bioacoustics, 18(2), 213–226.
parseFilename("5E90A4D4.wav")parseFilename("5E90A4D4.wav")
Detects pulses in a Wave using the method described in Dietrich et al (2004) https://doi.org/10.1016/j.patcog.2004.04.004.
pd_dietrich2004( wave, U = 120, gamma = 0.05, alpha = 1.4, scaling = 32, V = 480, psi = 1 )pd_dietrich2004( wave, U = 120, gamma = 0.05, alpha = 1.4, scaling = 32, V = 480, psi = 1 )
wave |
A Wave object |
U |
Window length |
gamma |
Gamma |
alpha |
Alpha |
scaling |
Scaling |
V |
V Window length |
psi |
Psi |
A list of input values plus the onset and offset times of pulses
Detects pulses in a Wave.
pd_simple( wave, U = 120, gamma = 0.05, alpha = 1.4, scaling = 32, V = 480, psi = 1 )pd_simple( wave, U = 120, gamma = 0.05, alpha = 1.4, scaling = 32, V = 480, psi = 1 )
wave |
A Wave object |
U |
Window length |
gamma |
Gamma |
alpha |
Alpha |
scaling |
Scaling |
V |
V Window length |
psi |
Psi |
A list of input values plus the onset and offset times of pulses.
Plot a false-colour index spectrogram
## S3 method for class 'fcis' plot( x, xlab = NULL, ylab = "Frequency (kHz)", main = "False-colour index spectrogram", ... )## S3 method for class 'fcis' plot( x, xlab = NULL, ylab = "Frequency (kHz)", main = "False-colour index spectrogram", ... )
x |
An object of class "fcis" |
xlab |
Label for the x axis |
ylab |
Label for the y axis |
main |
Title for the plot |
... |
Additional parameters passed to plot() |
No return value, called for its side effect of drawing a plot.
## Not run: plot(fcis(wave, window.length=44100)) ## End(Not run)## Not run: plot(fcis(wave, window.length=44100)) ## End(Not run)
This function is used to create a PseudoWave object that can be used to generate a Wave object when operated on.
pseudoWave( type = NA_character_, subtype = NA_character_, scale = 1, offset = 0, seed = 1, params = list() )pseudoWave( type = NA_character_, subtype = NA_character_, scale = 1, offset = 0, seed = 1, params = list() )
type |
Type of PseudoWave (e.g. "noise", "sine") |
subtype |
Subtype of PseudoWave (e.g. "white" if type is "noise") |
scale |
The Wave channels are multiplied by this value |
offset |
This value is added to the Wave channels |
seed |
Random seed, so that the same PseudoWave gives the same samples every time. Pass NA for a fresh random sequence on each use. Setting a seed does not disturb the random numbers drawn elsewhere in the session. |
params |
List of additional parameters to pass to generating function |
A PseudoWave object.
pw <- pseudoWave("noise", "white") pw <- pseudoWave("sine", params=list("f0"=440)) ## Not run: pw <- pseudoWave("file", "myfile.wav") ## End(Not run)pw <- pseudoWave("noise", "white") pw <- pseudoWave("sine", params=list("f0"=440)) ## Not run: pw <- pseudoWave("file", "myfile.wav") ## End(Not run)
An S4 class to represent a PseudoWave object that is converted to a Wave object when operated on.
typeType of PseudoWave (e.g. "noise")
subtypeSubtype of PseudoWave (e.g. "white" if type is "noise")
scaleThe Wave channels are multiplied by this value
offsetThis value is added to the Wave channels
seedRandom seed, so that the same PseudoWave gives the same samples every time. NA draws a fresh sequence on each use.
paramsList of additional parameters to pass to generating function
Generate a single pulse, either a Dirac pulse (Dirac delta) or a square pulse.
pulse( type = "dirac", leading = 22050, pulse.length = 1, duration = samp.rate, samp.rate = 44100, bit = 1, pcm = FALSE, stereo = FALSE, output = "Wave", invert = FALSE )pulse( type = "dirac", leading = 22050, pulse.length = 1, duration = samp.rate, samp.rate = 44100, bit = 1, pcm = FALSE, stereo = FALSE, output = "Wave", invert = FALSE )
type |
Either "dirac" or "square". |
leading |
The number of samples before the pulse. |
pulse.length |
The number of samples in the pulse (for "square"). |
duration |
The total number of samples generated. |
samp.rate |
The sample rate. |
bit |
The bit depth. |
pcm |
Whether Wave generated is PCM (see tuneR). |
stereo |
Whether Wave generated is stereo. |
output |
The output format ("Wave"). |
invert |
Whether to invert the pulse. |
Specified by output.
Detects pulses in a Wave. Stereo and multi-channel waves are analysed one channel at a time, giving one result per channel.
pulseDetection(wave, method = "simple", ...)pulseDetection(wave, method = "simple", ...)
wave |
A Wave object containing pulses |
method |
Which method to use for pulse detection |
... |
Other arguments to pass to pulse detection function |
The output of the pulse detection method used.
Used to locate area of no pulses from the results of pulseDetection().
pulseIntervals(pulses, nsd = 2)pulseIntervals(pulses, nsd = 2)
pulses |
The result of a pulseDetection. |
nsd |
The number of standard deviations each sid of the mean pulse interval to discard |
A list of onset and offset times for pulses
This function installs scikit-maad in the sonicscrewdriver environment using reticulate.
pythonInstall(unattended = FALSE)pythonInstall(unattended = FALSE)
unattended |
If TRUE then the function will not prompt the user to install the environment in a non-interactive session. |
No return value, called for its side effect of creating the Python environment.
## Not run: pythonInstall() pythonInstall(unattended=TRUE) ## End(Not run)## Not run: pythonInstall() pythonInstall(unattended=TRUE) ## End(Not run)
Calculates the power returned from an echolocation pulse
radarPower(P_t, r, area, G_t = 1, G_r = 1, wl = 1)radarPower(P_t, r, area, G_t = 1, G_r = 1, wl = 1)
P_t |
Power transmitted (from sender) |
r |
Range of the target |
area |
Effective cross-sectional area of the target |
G_t |
Transmitter gain |
G_r |
Receiver gain |
wl |
Wavelength (use only with G_r and G_t) |
The received power
radarPower(12, 20, 0.05) radarPower(12, 20, 0.05, G_t=1.2, G_r=1.5, wl=0.045)radarPower(12, 20, 0.05) radarPower(12, 20, 0.05, G_t=1.2, G_r=1.5, wl=0.045)
Calculates the distance of an object based on the round trip time of an echolocation pulse
radarRange(t, c = soundSpeed(medium = "air"))radarRange(t, c = soundSpeed(medium = "air"))
t |
Time in seconds |
c |
Speed of sound in transmission medium m/s (by default air) |
Distance to object
radarRange(2) radarRange(2, c=343) radarRange(2, c=soundSpeed(medium = "sea water"))radarRange(2) radarRange(2, c=343) radarRange(2, c=soundSpeed(medium = "sea water"))
Used to plot sectors, annuli and horizons on a dielPlot() or yearlyPlot(). The polygon has an inner and outer horizon - which can be set to a fixed radius or a vector.
radialPolygon( angle1, angle2, radius1, radius2, col = "grey", border = NA, rot = -pi, angleinc = 0.01, reverse = TRUE, ... )radialPolygon( angle1, angle2, radius1, radius2, col = "grey", border = NA, rot = -pi, angleinc = 0.01, reverse = TRUE, ... )
angle1 |
Angles for the inner line |
angle2 |
Angles for the outer line |
radius1 |
Radii for the inner line |
radius2 |
Radii for the outer line |
col |
Colour of the polygon |
border |
Border colour (see polygon() for details) |
rot |
Rotation of the plot, defaults to pi to match dielPlot() and yearlyPlot() |
angleinc |
The angular increment in radians for calculating circular lines |
reverse |
If FALSE plots in an anti-clockwise direction |
... |
Other parameters passed to polygon() |
No return value, called for its side effect of drawing a polygon on the current plot.
Detects rainfall in a Wave. An uncalibrated version of Bedoya et al (2017) https://doi.org/10.1016/j.ecolind.2016.12.018 is available in this package. The hardRain package can also be accessed via this wrapper.
rainfallDetection(wave, method = "bedoya2017", ...)rainfallDetection(wave, method = "bedoya2017", ...)
wave |
A Wave object to detect rainfall in. Stereo Wave and WaveMC objects are passed to allChannels(), which returns one value per channel. |
method |
Which rainfall detection method to use ("bedoya2017") |
... |
Other arguments to pass to rain detection function |
Numeric value from the rainfall detection algorithm chosen. For multi-channel input, a list of such values.
## Not run: rainfallDetection(sheep, method="bedoya2017") ## End(Not run)## Not run: rainfallDetection(sheep, method="bedoya2017") ## End(Not run)
Reads an Audacity label file and returns either a list of Annotation objects
or a data frame.
readAudacityLabels(file, output = "annotations")readAudacityLabels(file, output = "annotations")
file |
Path to the Audacity label file. |
output |
One of "annotations" or "data.frame". |
A list of Annotation objects, or a data frame if output is "data.frame".
This file is used to read an audio file and return a Wave object, it is an abstraction function for various specific audio reading functions. If no existing method can be identified an attempt is made to use the av package to read the audio.
readAudio(file, mime = "auto", from = 0, to = Inf, units = "seconds")readAudio(file, mime = "auto", from = 0, to = Inf, units = "seconds")
file |
File to read |
mime |
MIME type of file to read, or "auto". Supported types are "audio/x-wav" and "audio/mpeg" (MP3) |
from |
Start point in file to return |
to |
End point in file to return |
units |
One of "samples", "seconds", "minutes", "hours". Default is "seconds". |
Files read through the av package (which is everything that is not WAVE or
MP3, e.g. FLAC) are returned at the bit depth the file was stored at, so that
the same audio compares equal however it was read. The av package does not
report a bit depth of 24, and returns 24bit audio as 32bit, so the samples of
a 24bit file are 256 times those tuneR::readWave() would give for the same
audio stored as WAVE. Audio stored as floating point is returned as 32bit.
A Wave object
Reads a single file, or directory of files, output by BirdNet Analyser.
readBirdNet(file, filename_parsing = "none")readBirdNet(file, filename_parsing = "none")
file |
Filename or directory |
filename_parsing |
Allows for filename parsing, accepted values are one of none, audiomoth, timestamp. |
A data frame.
The Seeed Studio Respeaker-6 when used as described in the documentation saves an eight channel audio file with channels 7 and 8 not containing input audio. This function reads such a file and saves it as a six channel file.
readRespeaker6(filename, from = 1, to = Inf, units = "samples", header = FALSE)readRespeaker6(filename, from = 1, to = Inf, units = "samples", header = FALSE)
filename |
file to read. |
from |
Where to start reading the wave in units. |
to |
Where to stop reading the wave in units. |
units |
Units in which from and to is given, the default is "samples", but can be set to time intervals such as "seconds". |
header |
If TRUE, just header information of the Wave file are returned, otherwise (the default) the whole Wave object. |
A WaveMC object.
Provides the standard reference intensity level.
referenceIntensity(unit = "watt_cm2")referenceIntensity(unit = "watt_cm2")
unit |
Unit to return, "watt_cm2" |
The reference sound intensity, in the unit specified.
ri <- referenceIntensity()ri <- referenceIntensity()
Provides the standard reference pressure level.
referencePressure(unit = "Pa")referencePressure(unit = "Pa")
unit |
Unit to return, "Pa" or "dyne_cm2" |
The reference sound pressure, in the unit specified.
rp <- referencePressure() rp <- referencePressure(unit="dyne_cm2")rp <- referencePressure() rp <- referencePressure(unit="dyne_cm2")
Specifies a time-bounded region to analyse.
region(unit, from = 0, to = Inf)region(unit, from = 0, to = Inf)
unit |
Unit of time (one of samples, seconds, minutes, hours) |
from |
Start time |
to |
End time |
A TimeRegion object.
Calculates the resonant frequency given the inductance and capacitance. In the acoustic case the inductance is inertia or mass, the capacitance is elasticity (bulk modulus) and resistance is composed of air resistance and related quantities. All units are SI.
resonantFrequency(L, C = NULL)resonantFrequency(L, C = NULL)
L |
Inductance |
C |
Capacitance, if NULL (the default) the IUPAC standard pressure is used. |
For isothermal compression, the bulk modulus is equal to the pressure. The default value of C therefore is the IUPAC standard pressure.
The resonant frequency, in Hertz.
f <- resonantFrequency(L=1)f <- resonantFrequency(L=1)
Calculates the time represented by n samples in a Wave.
sDuration(n = 1, wave = NULL, samp.rate = NULL)sDuration(n = 1, wave = NULL, samp.rate = NULL)
n |
The number of the samples |
wave |
A Wave object containing pulses |
samp.rate |
Integer sampling rate |
A numeric value in seconds
sDuration(n=20, samp.rate=44100) ## Not run: sDuration(n=20, wave=sheep)#' ## End(Not run)sDuration(n=20, samp.rate=44100) ## Not run: sDuration(n=20, wave=sheep)#' ## End(Not run)
The frequencyStats of the sheep data file from the seewave package.
sheepFrequencyStatssheepFrequencyStats
An object of class list of length 3.
Shimmer is a measure of the variability of amplitude between successive periods in the waveform. It is returned in decibels, as the mean absolute difference in level between the peak amplitudes of consecutive periods. A waveform of constant amplitude has a shimmer of zero.
shimmer(wave)shimmer(wave)
wave |
A Wave object |
The shimmer in decibels
## Not run: shimmer(sheep) ## End(Not run)## Not run: shimmer(sheep) ## End(Not run)
Sorts a list of annotations by either start time, frequency, or both.
sort_annotations(annotations, domain = "time", decreasing = FALSE)sort_annotations(annotations, domain = "time", decreasing = FALSE)
annotations |
A list of Annotation objects. |
domain |
Domain of the annotations, either "time", "frequency", or "both". |
decreasing |
If TRUE, sort in decreasing order. |
A list of Annotation objects.
Given sufficient parameters (i.e. wavelength and frequency, bulk modulus and density) this function calculates the speed of sound.
soundSpeed( medium = NULL, method = NULL, wl = NULL, f = NULL, bulkModulus = NULL, density = NULL, ... )soundSpeed( medium = NULL, method = NULL, wl = NULL, f = NULL, bulkModulus = NULL, density = NULL, ... )
medium |
Propagation medium (e.g. "air"), or "all" to return a list of all available media. |
method |
Use a specific method to calculate the speed of sound (see Details). |
wl |
Wavelength |
f |
Frequency |
bulkModulus |
Bulk modulus |
density |
Density |
... |
Additional parameters passed to the method. |
The speed of sound can be calculated using the following methods:
cramer Uses the method described in Cramer (1993). Additional parameters are:
temp Temperature
temp.unit Temperature unit
pressure Pressure
pressure.unit Pressure unit
RH Relative humidity
MoleFracCO2 Mole fraction of CO2
seewave Delegates the calculation of the speed of sound in air to the
package seewave (Sueur et al. 2008). This calculation is
. performed as .
Additional parameters are:
temp Temperature
The speed of sound in the medium, in metres per second.
Cramer O (1993).
“The variation of the specific heat ratio and the speed of sound in air with temperature, pressure, humidity, and CO2 concentration.”
The Journal of the Acoustical Society of America, 93(5), 2510–2516.
ISSN 0001-4966.
doi:10.1121/1.405827.
Sueur J, Aubin T, Simonis C (2008).
“Seewave, a free modular tool for sound analysis and synthesis.”
Bioacoustics, 18(2), 213–226.
soundSpeed(medium="air") soundSpeed(medium="sea water") soundSpeed(method="cramer", temp=14, pressure=3, RH=10) soundSpeed(method="cramer", temp=14, temp.unit="C", pressure=3, pressure.unit="kPa", RH=10) t <- 1:30 s <- lapply(t, function(x){soundSpeed(method="cramer", temp=x)})soundSpeed(medium="air") soundSpeed(medium="sea water") soundSpeed(method="cramer", temp=14, pressure=3, RH=10) soundSpeed(method="cramer", temp=14, temp.unit="C", pressure=3, pressure.unit="kPa", RH=10) t <- 1:30 s <- lapply(t, function(x){soundSpeed(method="cramer", temp=x)})
Given a list of outputs from meanspec generates a plot with the mean shown by a line, and either the minimum/maximum values or one standard deviation shown by a ribbon.
specStats(spectra, stats = "minMax", line.col = "black", ribbon.col = "grey70")specStats(spectra, stats = "minMax", line.col = "black", ribbon.col = "grey70")
spectra |
A list of spectra |
stats |
Either minMax or sd |
line.col |
Colour for the line |
ribbon.col |
Colour for the ribbon |
A ggplot2 object
An S4 class to represent a spectrogram from scikit-maad.
SxxThe spectrogram matrix
tnThe time vector
fnThe frequency vector
extentsThe extents of the spectrogram. A list of tmin, tmax, fmin, fmax.
Computes the short term energy of a Wave.
ste(wave, method = "dietrich2004", U = 120, ...)ste(wave, method = "dietrich2004", U = 120, ...)
wave |
A Wave object |
method |
Which method used to calculate the short term energy, by default "dietrich2004" to use (Dietrich et al. 2004). |
U |
Window length in samples, matching the pulse detection functions. |
... |
Other arguments to pass to ste method. |
A vector of short term energy values
Dietrich C, Palm G, Riede K, Schwenker F (2004). “Classification of bioacoustic time series based on the combination of global and local decisions.” Pattern Recognition, 37(12), 2293–2305.
## Not run: ste(sheep, method="dietrich2004") ## End(Not run)## Not run: ste(sheep, method="dietrich2004") ## End(Not run)
Dataset compiled from various sources for differing values of STP.
STPSTP
An object of class list of length 2.
This function takes two spectra from seewave (or equivalent) and subtracts their values. The spectra must have the same bins.
subtractSpectra(s1, s2, coerceNegative = TRUE)subtractSpectra(s1, s2, coerceNegative = TRUE)
s1 |
First spectrum |
s2 |
Second spectrum |
coerceNegative |
Sets any values below zero to zero in output. |
A spectrum of s1 - s2
## Not run: subtractSpectra(spec1, spec2) subtractSpectra(spec1, spec2, coerceNegative=TRUE) ## End(Not run)## Not run: subtractSpectra(spec1, spec2) subtractSpectra(spec1, spec2, coerceNegative=TRUE) ## End(Not run)
Generates a frequency swept sine wave (either linear or logarithmic) and returns it as a Wave object or vector.
sweptsine( f0 = 100, f1 = 2500, mode = "linear", sweep.time = 1, time.unit = "seconds", samp.rate = 44100, output = "wave", ... )sweptsine( f0 = 100, f1 = 2500, mode = "linear", sweep.time = 1, time.unit = "seconds", samp.rate = 44100, output = "wave", ... )
f0 |
Start frequency |
f1 |
End frequency |
mode |
One of "linear", "log" |
sweep.time |
Duration of swept wave |
time.unit |
One of "seconds", "samples" |
samp.rate |
Sample rate of swept wave |
output |
"wave" for a Wave object, or "vector" |
... |
Additional arguments to pass to data2Wave |
A swept wave object of the type specified in output.
#Generate a swept sine wave between 0Hz and 10kHz. w <- sweptsine(0, 10e3) #Generate a swept sine wave between 0Hz and 10kHz and normalise it. w <- normalise(sweptsine(0, 10e3)) #Generate a stereo swept sine wave between 100Hz and 1KHz. w <- tuneR::stereo(sweptsine(100, 1e3)) #Generate an exponentially swept sine wave between 100Hz and 1KHz. w <- sweptsine(100, 1e3, mode="log")#Generate a swept sine wave between 0Hz and 10kHz. w <- sweptsine(0, 10e3) #Generate a swept sine wave between 0Hz and 10kHz and normalise it. w <- normalise(sweptsine(0, 10e3)) #Generate a stereo swept sine wave between 100Hz and 1KHz. w <- tuneR::stereo(sweptsine(100, 1e3)) #Generate an exponentially swept sine wave between 100Hz and 1KHz. w <- sweptsine(100, 1e3, mode="log")
The TaggedWave class extended the Wave class from the tuneR package so that it can include extended metadata and the results of analyses.
metadataA list for storing metadata.
analysesA list for storing analyses.
The TaggedWaveMC class extended the WaveMC class from the tuneR package so that it can include extended metadata and the results of analyses.
metadataA list for storing metadata.
analysesA list for storing analyses.
This function takes a Wave/WaveMC object (or a list of such objects) and
returns a corresponding tagged version (TaggedWave or TaggedWaveMC).
tagWave(w, origin = "user")tagWave(w, origin = "user")
w |
A |
origin |
The origin of the object (default "user"). |
A TaggedWave or TaggedWaveMC object (or list of such objects).
Estimates the time difference of arrival (TDOA) of a sound between the channels of a multichannel recording, by generalised cross-correlation of each channel against a reference channel.
tdoa( wave, ref = 1, from = NULL, to = NULL, units = "seconds", method = "phat", max.delay = NULL, interpolate = TRUE )tdoa( wave, ref = 1, from = NULL, to = NULL, units = "seconds", method = "phat", max.delay = NULL, interpolate = TRUE )
wave |
A Wave or WaveMC object with two or more channels. |
ref |
The channel that delays are measured against. |
from |
Optionally, the start of the region to correlate. |
to |
Optionally, the end of the region to correlate. |
units |
Units in which |
method |
Correlation method, one of "phat" (the default), "cc", or "envelope" (see Details). |
max.delay |
Optionally, the largest delay to consider, in seconds. Delays larger than the time sound takes to cross the microphone array are not physically possible, and excluding them stops a spurious correlation peak being returned. |
interpolate |
If TRUE (the default) the delay is interpolated to a fraction of a sample (see Details). |
A positive delay means the sound arrived at that channel later than it arrived at the reference channel, so the reference channel is the closer of the two to the source. The delay of the reference channel against itself is zero.
Cross-correlation is performed over the whole recording unless from and to
are given, and a single delay is returned for each channel. Recordings holding
more than one event should be cut to each event in turn (see Examples), as a
correlation over several events with different directions of arrival has no
single peak to find. Cutting is also much the faster way to work, as the whole
of whatever is given is transformed at once.
The following methods are available:
phat (the default) - the phase transform, in which each frequency contributes to the correlation according to its phase alone (Knapp and Carter 1976). Discarding the magnitudes sharpens the correlation peak and makes the estimate more robust to reverberation, at the cost of weighting quiet frequencies (which are mostly noise) as heavily as loud ones.
cc - unweighted cross-correlation, normalised so that the returned correlation is between -1 and 1. Better suited to recordings with a poor signal to noise ratio, and to narrowband sounds.
envelope - cross-correlation of the Hilbert amplitude envelopes of the
channels rather than of the waveforms themselves, as seewave::corenv()
does. The only method of the three that works on a sound whose waveform does
not stay coherent between microphones, which is the usual situation for the
broadband pulses of insects and for microphones far enough apart that the
path to each differs. Delays are resolved only to the width of a feature of
the envelope, so it is the least precise of the three where the others work
at all.
The delay found is a whole number of samples, which at the sample rates used
for field recording is a coarse measure of direction. interpolate fits a
parabola to the correlation peak and its two neighbours to estimate the delay
to a fraction of a sample.
A data frame with one row per channel, holding the channel number, the channel name (NA if the channels are not named), the delay in seconds, the delay in samples, and the height of the correlation peak.
Knapp C, Carter GC (1976). “The generalized correlation method for estimation of time delay.” IEEE Transactions on Acoustics, Speech, and Signal Processing, 24(4), 320–327.
bearing(), which turns the delays into a direction.
# A noise reaching the second channel of a recording 20 samples after # it reaches the first. n <- tuneR::noise(kind="white", duration=5000, samp.rate=48000) w <- tuneR::WaveMC( cbind(n@left[101:4900], n@left[81:4880]), samp.rate = 48000, bit = 32, pcm = FALSE ) tdoa(w) # Only the middle of the recording, and only delays that an array 1m across # could produce. tdoa(w, from=0.02, to=0.08, max.delay=1/soundSpeed()) ## Not run: # Delays for each of several events in a recording, each 100ms long w <- readAudio("array.wav") events <- c(3.2, 8.7, 12.1) lapply(events, function(t) tdoa(w, from=t, to=t+0.1)) ## End(Not run)# A noise reaching the second channel of a recording 20 samples after # it reaches the first. n <- tuneR::noise(kind="white", duration=5000, samp.rate=48000) w <- tuneR::WaveMC( cbind(n@left[101:4900], n@left[81:4880]), samp.rate = 48000, bit = 32, pcm = FALSE ) tdoa(w) # Only the middle of the recording, and only delays that an array 1m across # could produce. tdoa(w, from=0.02, to=0.08, max.delay=1/soundSpeed()) ## Not run: # Delays for each of several events in a recording, each 100ms long w <- readAudio("array.wav") events <- c(3.2, 8.7, 12.1) lapply(events, function(t) tdoa(w, from=t, to=t+0.1)) ## End(Not run)
An S4 class to represent a TimeRegion within a Wave object.
fromStart position
toEnd position
unitTime unit (one of seconds, minutes, hours)
Calculates the number of samples for a given duration of a wave
tSamples(time = 1, wave = NULL, samp.rate = NULL)tSamples(time = 1, wave = NULL, samp.rate = NULL)
time |
The duration in seconds |
wave |
A Wave object containing pulses. Its sample rate is used, so it cannot be given alongside samp.rate. |
samp.rate |
Integer sampling rate |
Number of samples
tSamples(10, samp.rate=44100) ## Not run: tSamples(10, wave=sheep) ## End(Not run)tSamples(10, samp.rate=44100) ## Not run: tSamples(10, wave=sheep) ## End(Not run)
Typical volumes of everyday things.
typicalVolume(thing = NA_character_)typicalVolume(thing = NA_character_)
thing |
Volume of thing, if missing then returns all volumes |
Typical volume of thing in dBA, or if no thing parameter a data frame of all volumes
typicalVolume() typicalVolume("rocket launch")typicalVolume() typicalVolume("rocket launch")
Given a timezone offset in hours returns a rotation in radians to apply to values for a diel plot.
tzRot(tz, init = pi)tzRot(tz, init = pi)
tz |
Timezone numeric |
init |
Initial rotation. Defaults to pi. |
The rotation of the plot, in radians.
This function takes a TaggedWave/TaggedWaveMC object (or a list of such objects) and returns a corresponding Wave/WaveMC object (or list of such objects).
untagWave(w)untagWave(w)
w |
A TaggedWave or TaggedWaveMC object (or list of such objects). |
A Wave or WaveMC object.
## Not run: w <- noise("white") tw <- tagWave(w) w2 <- untagWave(tw) ## End(Not run)## Not run: w <- noise("white") tw <- tagWave(w) w2 <- untagWave(tw) ## End(Not run)
Used to upsample a Wave object. The upsampled sample rate must be an natural multiple of the current sample rate.
upsample(wave, upsample.rate, method = "basic")upsample(wave, upsample.rate, method = "basic")
wave |
Wave object to upsample. |
upsample.rate |
The sample rate to upsample to. |
method |
"basic" for linear, or a function to interpolate NAs in a vector |
A resampled Wave object
wave <- tuneR::sine(4000, samp.rate=44100) wave2 <- upsample(wave, 88200)wave <- tuneR::sine(4000, samp.rate=44100) wave2 <- upsample(wave, 88200)
Helper function to test that the input is a Wave object. Will create an error if not.
validateIsWave(wave)validateIsWave(wave)
wave |
Object to test |
The Wave object unchanged. An error is raised if it is not a Wave object.
A WaveFilter object is an object containing information necessary for the
filterWave() function to apply the filter to a Wave or TaggedWave
object. This is designed to allow a pipe operator (either magrittr or base R)
to be used to apply filters to a Wave in a pipeline. If used with a
TaggedWave object the function adds information to the processing slot
documenting its action.
descriptionDescription of the filter.
funcName of function.
paramsList of additional parameters to pass to the function.
Calculates the wavelength of a sound wave given the frequency and speed of sound in that medium.
wavelength(frequency, speed = soundSpeed(medium = "air"), unit = "m")wavelength(frequency, speed = soundSpeed(medium = "air"), unit = "m")
frequency |
Frequency of the sound in Hertz |
speed |
Speed of sound (defaults to the speed of sound in air) |
unit |
Unit to return the wavelength in, either "m" or "cm" |
Wavelength of the sound in the unit specified
wl <- wavelength(1000) wl <- wavelength(1000, speed=soundSpeed(medium="steel")) wl <- wavelength(1000, unit="cm")wl <- wavelength(1000) wl <- wavelength(1000, speed=soundSpeed(medium="steel")) wl <- wavelength(1000, unit="cm")
Separates a Wave object into windows of a defined length and runs a function on the window section. Windows may overlap, and the function can make use of 'parallel' package for multi-core processing. It will also show a progress bar if the 'pbapply' package is installed.
windowing( wave, window.length = 1000, FUN, window.overlap = 0, bind.wave = FALSE, complete.windows = TRUE, cluster = NULL, ... )windowing( wave, window.length = 1000, FUN, window.overlap = 0, bind.wave = FALSE, complete.windows = TRUE, cluster = NULL, ... )
wave |
A Wave object or filename. Using filenames may save loading an entire large file into memory. |
window.length |
The length of the analysis window (in samples). |
FUN |
FUN to be applied to windows. |
window.overlap |
The overlap between successive windows (in samples), a negative value will result in a gap between windows. |
bind.wave |
If TRUE and FUN returns wave objects, then these are combined into a single object |
complete.windows |
If TRUE (default) the final window will not be processed unless it has a length equal to window.length. |
cluster |
A cluster form the 'parallel' package for multi-core computation. |
... |
Additional parameters to FUN |
A list of the results of FUN for each window, or a single Wave object if bind.wave is TRUE.
## Not run: windowing(wave, window.length=1000, FUN=duration, window.overlap=0, bind.wave=TRUE) ## End(Not run)## Not run: windowing(wave, window.length=1000, FUN=duration, window.overlap=0, bind.wave=TRUE) ## End(Not run)
Save a time region defined by an Annotation object as a Wave file
writeAnnotationWave(annotation, wave = NULL)writeAnnotationWave(annotation, wave = NULL)
annotation |
An Annotation object. |
wave |
(Optional) A Wave object, if not given will load the wave file from Annotation filename. |
No return value, called for its side effect of writing a Wave file.
Writes a list of Annotation objects to an Audacity label file.
Internally this uses the write.audacity() function from the seewave
package (Sueur et al. 2008).
writeAudacityLabels(annotations, file)writeAudacityLabels(annotations, file)
annotations |
A list of |
file |
Path to the Audacity label file. |
No return value, called for its side effect of writing a label file.
Sueur J, Aubin T, Simonis C (2008). “Seewave, a free modular tool for sound analysis and synthesis.” Bioacoustics, 18(2), 213–226.
This function writes a Wave or WaveMC object to a file, it is an
abstraction function for various specific audio writing functions and is
the counterpart of readAudio(). WAVE files are written directly, other
formats are written by converting a temporary WAVE file using the av
package. If the av package is not available FLAC files can also be written
using the flac program via the seewave package
(Sueur et al. 2008).
writeAudio(wave, file, mime = "auto", ...)writeAudio(wave, file, mime = "auto", ...)
wave |
A Wave or WaveMC object to write. The channels of a WaveMC object
must be named, as the name is what records the position of each channel in
the file (see |
file |
File to write. |
mime |
MIME type of the file to write, or "auto" (the default) to determine it from the file extension (see Details). |
... |
Additional arguments passed to the function performing the write:
|
The MIME type of the file to write is determined from the file extension,
unless it is given in the mime argument. Any format supported by the
encoders available to the av package can be written, commonly used types
include:
audio/x-wav (.wav) - written by tuneR::writeWave().
audio/flac (.flac)
audio/mpeg (.mp3)
audio/mp4 (.m4a)
Which other formats can be written depends on the encoders available to the
av package, and some encoders accept only certain sample rates (e.g. Opus
requires 48kHz or one of its divisors).
Audio written to a lossy format (e.g. MP3) will not be identical to the audio held in the object, and audio written to a format that does not support the bit depth or channel count of the object will be converted by the encoder.
The path of the file written, invisibly.
Sueur J, Aubin T, Simonis C (2008). “Seewave, a free modular tool for sound analysis and synthesis.” Bioacoustics, 18(2), 213–226.
w <- tuneR::sine(440, duration=1000) f <- tempfile(fileext=".wav") writeAudio(w, f) file.remove(f) ## Not run: # Requires the av package writeAudio(w, "tone.mp3") writeAudio(w, "tone.flac") ## End(Not run)w <- tuneR::sine(440, duration=1000) f <- tempfile(fileext=".wav") writeAudio(w, f) file.remove(f) ## Not run: # Requires the av package writeAudio(w, "tone.mp3") writeAudio(w, "tone.flac") ## End(Not run)
Given an object that can be coerced to POSIXlt, return the fraction of a year represented by the object.
yearlyFraction(t, year = 2022, input = "POSIX", unit = "radians")yearlyFraction(t, year = 2022, input = "POSIX", unit = "radians")
t |
Object to be converted to a fraction |
year |
Year to calculate fractions of (allows for leap years) |
input |
One of POSIXlt (default) |
unit |
If set to radians outputs a position around a circle. If set to fraction outputs the raw fraction. |
The position of the date within the year, in radians or as a fraction of a year.
Generates monthly labels for a yearlyPlot().
yearlyLabels()yearlyLabels()
A character vector of twelve month abbreviations.
ToDO......
yearlyPlot( year = 2022, lat, lon, limits = c(0, 2), plot = NULL, method = "plotrix", legend = FALSE )yearlyPlot( year = 2022, lat, lon, limits = c(0, 2), plot = NULL, method = "plotrix", legend = FALSE )
year |
Year to plot (allows for leap years). |
lat |
Numeric latitude. |
lon |
Numeric longitude. |
limits |
Plotting limits of the daylight regions, default to c(1,2) |
plot |
Character vector of components to plot |
method |
Plotting library to use |
legend |
Whether to show a legend |
Called for its side effect of drawing a plot. The return value is that of the underlying plotting function and should not be relied on.
Generates positions for monthly labels of a yearlyPlot() in radians. The positions can either be for the start of the month, or middle of the month.
yearlyPositions(year = 2022, format = "months")yearlyPositions(year = 2022, format = "months")
year |
Year to calculate |
format |
One of months, mid-months, days |
The function allows for leap years if the year parameter is provided.
A numeric vector of label positions, in radians.
Returns a vector of the position (in samples) of zero crossings in a Wave object
zerocross(wave)zerocross(wave)
wave |
A Wave object |
A vector of zero crossing locations
## Not run: zerocross(sheep) ## End(Not run)## Not run: zerocross(sheep) ## End(Not run)
This function takes a spectrum from seewave and creates a new zero-valued spectrum with the same structure.
zeroSpectrum(s1)zeroSpectrum(s1)
s1 |
Spectrum to emulate the structure of. |
A zero-valued spectrum.
## Not run: zeroSpectrum(spec) ## End(Not run)## Not run: zeroSpectrum(spec) ## End(Not run)