Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions R/generateNoise.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ generateNoise <- function(
noise,
duration=duration,
samp.rate=wave@samp.rate,
bit=wave@bit
bit=wave@bit,
pcm=wave@pcm
)
} else {
n <- tuneR::silence(duration=duration, samp.rate=wave@samp.rate, bit=wave@bit)
n <- tuneR::silence(duration=duration, samp.rate=wave@samp.rate, bit=wave@bit, pcm=wave@pcm)
for (i in 1:length(noise)) {
nw <- tuneR::noise(noise[i], duration=duration, samp.rate=wave@samp.rate, bit=wave@bit)
nw <- tuneR::noise(noise[i], duration=duration, samp.rate=wave@samp.rate, bit=wave@bit, pcm=wave@pcm)
n@left <- n@left + nw@left
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/reticulate-virtualenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pythonInstall <- function(unattended=FALSE) {

.useUtf8Locale()
if (!reticulate::virtualenv_exists(envname = "sonicscrewdriver")) {
reticulate::virtualenv_create(envname = "sonicscrewdriver", packages=NULL)
reticulate::virtualenv_create(envname = "sonicscrewdriver", packages=NULL, version="3.12")
}
reticulate::virtualenv_install("sonicscrewdriver", c("scikit-maad", "numpy==1.26.4", "librosa", "tensorflow", "birdnetlib"))
}
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-generateNoise.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ test_that("generateNoise outputs something Wave-like", {
expect_s4_class(generateNoise(w, "white", FALSE, 0.5, output="list")[[2]], "WaveMC")
})

test_that("generateNoise preserves PCM settings from audio read through av", {
skip_if_not_installed("av")

w <- readAudio(system.file("extdata/AUDIOMOTH.flac", package="sonicscrewdriver"))
expect_silent(generateNoise(w, "white", FALSE, 0.1, output="list"))
})

# The thresholds below were set when a pulse peaked at 2^32 rather than at the 1
# a floating point wave allows, and noise was referenced to that same wrong scale.
# At a noise ratio of 0.25 the noise now sits near 0.05 of full scale.
Expand Down
Loading