# \donttest{
oldpar <- par(no.readonly = TRUE)
### Downloading audiofiles from public Zenodo library
dir <- paste(tempdir(), "forExample", sep = "/")
dir.create(dir)
recName <- paste0("GAL24576_20250401_", sprintf("%06d", seq(0, 200000, by = 50000)), ".wav")
recDir <- paste(dir, recName, sep = "/")
for (rec in recName) {
print(rec)
url <- paste0("https://zenodo.org/records/17575795/files/",
rec,
"?download=1")
download.file(url, destfile = paste(dir, rec, sep = "/"), mode = "wb")
}
### Running the function
sat <- soundMat(dir)
### Plotting results
sides <- sat$info$CHANNEL
thresholds <- colnames(sat$values)
split <- strsplit(thresholds, "/")
shapNorm <- apply(sat$values, 2, function(x)
if (var(x) == 0) {
0
} else {
shapiro.test(x)$statistic
})
shapPos <- which.max(shapNorm)
par(mfrow = c(3, 2))
plot(
sat$values[sides == "left", 1],
main = paste0("POW = ", split[[1]][1], "dB | BGN = ", split[[1]][2], "%"),
type = "b",
ylim = c(0,1),
xlab = "Time Index", ylab = "Soundsacpe Saturation (%)", col = "goldenrod"
)
points(sat$values[sides == "right", 1], col = "maroon", type = "b")
hist(sat$values[,1], main = paste("Histogram of POW = ", split[[1]][1],
"dB | BGN = ", split[[1]][2], "%"), xlab = "Soundscape Saturation (%)")
plot(
sat$values[sides == "left", 144],
main = paste0("POW = ", split[[144]][1], "dB | BGN = ", split[[144]][2], "%"),
type = "b",
ylim = c(0,1),
xlab = "Time Index", ylab = "Soundsacpe Saturation (%)", col = "goldenrod"
)
points(sat$values[sides == "right", 144], col = "maroon", type = "b")
hist(sat$values[,144], main = paste("Histogram of POW = ", split[[144]][1],
"dB | BGN = ", split[[144]][2], "%"), xlab = "Soundscape Saturation (%)")
plot(
sat$values[sides == "left", shapPos],
main = paste0(
"POW = ",
split[[shapPos]][1],
"dB | BGN = ",
split[[shapPos]][2],
"%",
"\nshapiro.test. statistic (W): ",
which.max(shapNorm)
),
type = "b",
ylim = c(0,1),
xlab = "Time Index", ylab = "Soundsacpe Saturation (%)", col = "goldenrod"
)
points(sat$values[sides == "right", shapPos], col = "maroon", type = "b")
hist(sat$values[,shapPos], main = paste("Histogram of POW = ",
split[[shapPos]][1], "dB | BGN = ", split[[shapPos]][2], "%"),
xlab = "Soundscape Saturation (%)")
unlink(dir, recursive = TRUE)
par(oldpar)
# }
Run the code above in your browser using DataLab