Description Usage Arguments Value Warning Author(s) See Also Examples
each event in the sound file is represented by the same number of landmarks.
1 | soundpoints(file.name, time.res, freq.res, passband, amplitude.cutoff, loudness.column, half.life, initial.amplitude, amplitude.threshold, var.columns, var.weights, n.landmarks)
|
file.name |
the location of a file in WAV format |
time.res |
the desired time resolution of the spectrogram |
freq.res |
the desired frequency resolution of the spectrogram – this will be converted to the nearest power of two, based upon the sample rate of the input file |
passband |
a two-element vector that defines the frequency range within the spectrogram that will contain the landmarks |
amplitude.cutoff |
the area under the peak at each instant of the spectrogram |
loudness.column |
the variable to use when separating signal vs. noise. see |
half.life |
this tunes the sensitivity of the amplitude smoother. smaller values means the moving average is more sensitive to sudden changes in amplitude. a good starting guess for this parameter is the time from one element to the next. |
initial.amplitude |
the starting amplitude of the signal vs. noise smooth. Large values exclude more noise at the beginning |
amplitude.threshold |
peaks are only counted as signal if they exceed the moving average by at least this much. If you set it at -1, for example, everything at least 10 dB quieter than the moving average will be included. |
var.columns |
the columns of the frequency contour that will be included in the
landmark analysis. see |
var.weights |
when calculating the difference between successive peaks, these are the
weights of each of the |
n.landmarks |
the number of landmarks per event. Events that include fewer than
|
file |
the name of the audio file, without path information |
spg |
the spectrogram object showing the whole file |
peaks |
the frequency contour of the whole file |
landmarks |
a data frame with one row per event, holding envelope and landmark measurements (e.g. duration, mean time, time1, time2, etc.) |
This function makes a spectrogram from the WHOLE file, so don't use it on long recordings!
Benjamin N. Taft ben.taft@landmarkacoustics.com
detect.events
make.peaks
smooth.average
plot.spg
landmark.plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (file.name, time.res, freq.res, passband, amplitude.cutoff,
loudness.column, half.life, initial.amplitude, amplitude.threshold,
var.columns, var.weights, n.landmarks)
{
spg <- spectrogram(file.name, time.res, freq.res)
peaks <- make.peaks(spg, passband, amplitude.cutoff)
peaks$smooth.amplitude <- smooth.average(peaks[, loudness.column],
get.time.res(spg), half.life, initial.amplitude)
not.noise <- peaks[, loudness.column] > peaks$smooth.amplitude +
amplitude.threshold
ids <- data.frame(event = rep(NA, nrow(peaks)), landmark = NA)
ids$event[not.noise] = detect.events(peaks[not.noise, var.columns],
var.weights)
ids$landmark[not.noise] <- assign.to.landmarks(ids$event[not.noise],
n.landmarks)
no.smooth <- -ncol(peaks)
landmarks <- aggregate(peaks[not.noise, no.smooth], list(event = ids$event[not.noise]),
mean)
names(landmarks)[-1] <- paste("mean", names(landmarks)[-1],
sep = ".")
landmarks$duration <- aggregate(peaks$time[not.noise], list(event = ids$event[not.noise]),
function(x) {
diff(range(x))
})$x
for (j in 1:n.landmarks) {
f <- not.noise & ids$landmark == j
if (any(f)) {
temp <- aggregate(peaks[f, no.smooth], list(event = ids$event[f]),
mean)
names(temp)[-1] <- paste(names(temp)[-1], j, sep = ".")
landmarks <- cbind(landmarks, temp[match(landmarks$event,
temp$event), -1])
}
}
landmarks <- landmarks[is.finite(apply(landmarks, 1, sum)),
]
ix <- grep("time", names(landmarks))[-1]
landmarks[, ix] <- landmarks[, ix] - landmarks$mean.time
peaks$event <- ids$event
peaks$landmark <- ids$landmark
answer <- list(file = basename(file.name), spg = spg, peaks = peaks,
landmarks = landmarks)
return(invisible(answer))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.