Title: | Time Domain Signal Coding |
---|---|
Description: | Functions for performing time domain signal coding as used in Chesmore (2001) <doi:10.1016/S0003-682X(01)00009-3>, and related tasks. This package creates the standard S-matrix and A-matrix (with variable lag), has tools to convert coding matrices into distributed matrices, provides published codebooks and allows for extraction of code sequences. |
Authors: | Ed Baker [aut, cre] |
Maintainer: | Ed Baker <[email protected]> |
License: | GPL-3 |
Version: | 1.0.4 |
Built: | 2024-12-22 06:45:03 UTC |
Source: | CRAN |
This function converts a coding matrix of any kind into a distributed matrix as described in Farr (2007).
c2dmatrix(t, sf = 100)
c2dmatrix(t, sf = 100)
t |
A tdsc object or a matrix |
sf |
The scaling factor |
Farr (2007) “Automated Bioacoustic Identification of Statutory Quarantined Insect Pests”. PhD thesis. University of York.
c2dmatrix(as.matrix(c(1,2,3,4), nrow=2))
c2dmatrix(as.matrix(c(1,2,3,4), nrow=2))
Coding matrix used for Orthoptera.
data(chesmore2001)
data(chesmore2001)
Matrix
Chesmore, E David (2001). “Application of time domain signal coding and artificial neural networks to passive acoustical identification of animals”. In: Applied Acoustics 62.12, pp. 1359–1374.
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) data(chesmore2001) t <- tdsc(wave, coding_matrix=chesmore2001)
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) data(chesmore2001) t <- tdsc(wave, coding_matrix=chesmore2001)
Identifies unused codes across multiple S-matrices. Unused bands can be used to reduce the codebook as in Stammers (2011).
emptyBands(...)
emptyBands(...)
... |
Two or more TDSC objects |
Stammers (2011) “Audio Event Classification for Urban Soundscape Analysis”. PhD thesis. University of York.
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) emptyBands(t,t)
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) emptyBands(t,t)
Coding matrix used by Farr (2007).
data(farr2007)
data(farr2007)
Matrix
Farr (2007) “Automated Bioacoustic Identification of Statutory Quarantined Insect Pests”. PhD thesis. University of Hull.
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) data(farr2007) t <- tdsc(wave, coding_matrix=farr2007)
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) data(farr2007) t <- tdsc(wave, coding_matrix=farr2007)
Identifies sequences of codes that follow each other from time domain signal analysis, and optionally plots them as a Sankey diagram.
followingCodes( tdsc, depth = 2, min_code = 0, max_code = 10, colourCode = 1, plot = F, ... )
followingCodes( tdsc, depth = 2, min_code = 0, max_code = 10, colourCode = 1, plot = F, ... )
tdsc |
A TDSC object |
depth |
The length of the sequence of codes to search for |
min_code |
The minimum value of code to include in sequence |
max_code |
The maximum value of code to include in sequence |
colourCode |
If plot is alluvial, colour all codes following this code |
plot |
If "alluvial" plots the found sequences in a river plot |
... |
Arguments to pass to the plotting function |
## Not run: library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) followingCodes(t) followingCodes(t, colourCode=2,plot="alluvial") ## End(Not run)
## Not run: library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) followingCodes(t) followingCodes(t, colourCode=2,plot="alluvial") ## End(Not run)
Normalises the A Matrix of a tdsc object either by scale or by codewords.
normalise.a.matrix(td, method = "scale")
normalise.a.matrix(td, method = "scale")
td |
A tdsc object |
method |
Either scale (default) or codewords |
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) t <- normalise.a.matrix(t) t <- normalise.a.matrix(t, method="codewords")
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) t <- normalise.a.matrix(t) t <- normalise.a.matrix(t, method="codewords")
Function to generate images of sampled waveforms with shapes analysed by Time Domain Signal Coding.
sample_waveform( samples = 3, fig_max_samples = NULL, start_zero = TRUE, invert = FALSE, tdsc_shapes = FALSE, limit_y = TRUE, ... )
sample_waveform( samples = 3, fig_max_samples = NULL, start_zero = TRUE, invert = FALSE, tdsc_shapes = FALSE, limit_y = TRUE, ... )
samples |
The number of samples |
fig_max_samples |
When constructing multiple figures this parameter can be used to ensure the plots are of the same size and are aligned |
start_zero |
If TRUE the waveform starts at zero, if FALSE the zero crossings are between samples |
invert |
If TRUE the shapes are positive with positive minima, if FALSE shapes are negative with negative maxima |
tdsc_shapes |
If TRUE the shapes correspond to TDSC shapes, if FALSE they resemble sampled sine waves |
limit_y |
If TRUE the shape fills the plot, if FALSE the complete range of the y axis is plotted (-1 to 1). |
... |
Further arguments to pass to plot. |
sample_waveform()
sample_waveform()
Performs Time Domain Signal Coding on a Wave object calculating the S-matrix and A-matrix.
tdsc(wave, lag = 1L, coding_matrix = NULL, plot = FALSE, max_D = 25L)
tdsc(wave, lag = 1L, coding_matrix = NULL, plot = FALSE, max_D = 25L)
wave |
A Wave object |
lag |
The lag used to create the A-matrix |
coding_matrix |
A matrix used to code the Duration-Shape pairs |
plot |
If TRUE plots the workings of the coding algorithm |
max_D |
The maximum Duration to code |
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) t <- tdsc(wave, lag=2, max_D=10)
library(tuneR) wave <- readWave(system.file("extdata", "1.wav", package="tdsc")) t <- tdsc(wave) t <- tdsc(wave, lag=2, max_D=10)
Plot the A matrix or S Matrix from a tdsc analysis.
tdsc_plot(td, plotter = "persp", ...)
tdsc_plot(td, plotter = "persp", ...)
td |
A TDSC object |
plotter |
Function used to plot the A matrix (persp or perp3D) or S matrix (hist) |
... |
Parameters to pass to plotting function |
## Not run: tdsc.plot(td) tdsc.plot(td, plotter="persp3D") tdsc.plot(td, plotter="hist") ## End(Not run)
## Not run: tdsc.plot(td) tdsc.plot(td, plotter="persp3D") tdsc.plot(td, plotter="hist") ## End(Not run)
An S4 class to hold results from TDSC
raw
Two column vector of Durations and Shapes
positive
Identify non-negative sections
codelist
Vector of sequential epoch codings
b_matrix
The basic matrix
c_matrix
The coding matrix
s_matrix
The S-matrix
a_matrix
The A-matrix
sample_count
The number of samples in the waveform
epoch_count
The number of identified epochs
stdsc
Statistical TDSC feature vector