ssm: Self-similarity matrix

Description Usage Arguments Value References Examples

View source: R/SSM.R

Description

Calculates the self-similarity matrix and novelty vector of a sound.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ssm(x, samplingRate = NULL, windowLength = 40, overlap = 75,
  step = NULL, ssmWin = 40, maxFreq = NULL, nBands = NULL,
  MFCC = 2:13, input = c("mfcc", "audiogram", "spectrum")[1],
  norm = FALSE, simil = c("cosine", "cor")[1], returnSSM = TRUE,
  kernelLen = 200, kernelSD = 0.2, plot = TRUE, specPars = list(levels =
  seq(0, 1, length = 30), color.palette = seewave::spectro.colors, xlab =
  "Time, s", ylab = "kHz", ylim = c(0, maxFreq/1000)), ssmPars = list(levels =
  seq(0, 1, length = 30), color.palette = seewave::spectro.colors, xlab =
  "Time, s", ylab = "Time, s", main = "Self-similarity matrix"),
  noveltyPars = list(type = "b", pch = 16, col = "black", lwd = 3))

Arguments

x

path to a .wav file or a vector of amplitudes with specified samplingRate

samplingRate

sampling rate of x (only needed if x is a numeric vector, rather than a .wav file)

windowLength

length of FFT window, ms

overlap

overlap between successive FFT frames, %

step

you can override overlap by specifying FFT step, ms

ssmWin

window for averaging SSM, ms

maxFreq

highest band edge of mel filters, Hz. Defaults to samplingRate / 2. See melfcc

nBands

number of warped spectral bands to use. Defaults to 100 * windowLength / 20. See melfcc

MFCC

which mel-frequency cepstral coefficients to use; defaults to 2:13)

input

either MFCCs ("cepstrum") or mel-filtered spectrum ("audiogram")

norm

if TRUE, each FFT frame is normalized by max power

simil

method for comparing frames: "cosine" = cosine similarity, "cor" = Pearson's correlation

returnSSM

if TRUE, returns the SSM

kernelLen

length of checkerboard kernel for calculating novelty, ms (the larger, the more global vs. local the novelty)

kernelSD

SD of checkerboard kernel for calculating novelty

plot

if TRUE, plots the SSM

specPars

graphical parameters passed to seewave::filled.contour.modif2 and affecting the spectrogram

ssmPars

graphical parameters passed to seewave::filled.contour.modif2 and affecting the plot of SSM

noveltyPars

graphical parameters passed to lines and affecting the novelty contour

Value

If returnSSM is TRUE, returns a list of two components: $ssm contains the self-similarity matrix, and $novelty contains the novelty vector. If returnSSM is FALSE, only produces a plot.

References

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
sound = c(soundgen(), soundgen(nSyl = 4, sylLen = 50, pauseLen = 70,
          formants = NA, pitchAnchors = list(time = c(0, 1),
          value = c(500, 330))))
# playme(sound)
m1 = ssm(sound, samplingRate = 16000,
         input = 'audiogram', simil = 'cor', norm = FALSE,
         ssmWin = 10, kernelLen = 150)  # detailed, local features
m2 = ssm(sound, samplingRate = 16000,
         input = 'mfcc', simil = 'cosine', norm = TRUE,
         ssmWin = 50, kernelLen = 600)  # more global
# plot(m2$novelty, type='b')  # use for peak detection, etc

## End(Not run)

tatters/soundgen_beta documentation built on May 14, 2019, 9 a.m.