Error(s) in re-building vignettes:
  ...
--- re-building ‘acoustic_analysis.Rmd’ using rmarkdown
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
soundgen
 --- call from context --- 
spectrogram(bout, samplingRate = samplingRate, windowLength = windowLength, 
    overlap = overlap, dynamicRange = dynamicRange, ...)
 --- call from argument --- 
if (class(frameBank) != "matrix") {
    stop("Input format not recognized. Please provide path to .wav or .mp3 file,\n      a vector of amplitudes plus samplingRate, or a preprocessed frameBank")
}
 --- R stacktrace ---
where 1: spectrogram(bout, samplingRate = samplingRate, windowLength = windowLength, 
    overlap = overlap, dynamicRange = dynamicRange, ...)
where 2: soundgen(sylLen = 900, temperature = 0, pitch = list(time = c(0, 
    0.3, 0.8, 1), value = c(300, 900, 400, 2300)), noise = c(-40, 
    -20), subDep = 100, jitterDep = 0.5, nonlinBalance = 100, 
    plot = TRUE, ylim = c(0, 4))
where 3: eval(expr, envir, enclos)
where 4: eval(expr, envir, enclos)
where 5: withVisible(eval(expr, envir, enclos))
where 6: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, 
    error = eHandler, message = mHandler)
where 7: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, 
    enclos)), warning = wHandler, error = eHandler, message = mHandler))
where 8: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, 
    envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
where 9: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
    debug = debug, last = i == length(out), use_try = stop_on_error != 
        2L, keep_warning = keep_warning, keep_message = keep_message, 
    output_handler = output_handler, include_timing = include_timing)
where 10: evaluate::evaluate(...)
where 11: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), 
    keep_message = !isFALSE(options$message), stop_on_error = if (options$error && 
        options$include) 0L else 2L, output_handler = knit_handlers(options$render, 
        options))
where 12: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, 
    keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), 
    stop_on_error = if (options$error && options$include) 0L else 2L, 
    output_handler = knit_handlers(options$render, options)))
where 13: block_exec(params)
where 14: call_block(x)
where 15: process_group.block(group)
where 16: process_group(group)
where 17: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
    error = function(e) {
        setwd(wd)
        cat(res, sep = "\n", file = output %n% "")
        message("Quitting from lines ", paste(current_lines(i), 
            collapse = "-"), " (", knit_concord$get("infile"), 
            ") ")
    })
where 18: process_file(text, output)
where 19: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet, 
    encoding = encoding)
where 20: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(), 
    ...)
where 21: vweave_rmarkdown(...)
where 22: engine$weave(file, quiet = quiet, encoding = enc)
where 23: doTryCatch(return(expr), name, parentenv, handler)
where 24: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 25: tryCatchList(expr, classes, parentenv, handlers)
where 26: tryCatch({
    engine$weave(file, quiet = quiet, encoding = enc)
    setwd(startdir)
    output <- find_vignette_product(name, by = "weave", engine = engine)
    if (!have.makefile && vignette_is_tex(output)) {
        texi2pdf(file = output, clean = FALSE, quiet = quiet)
        output <- find_vignette_product(name, by = "texi2pdf", 
            engine = engine)
    }
}, error = function(e) {
    OK <<- FALSE
    message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s", 
        file, conditionMessage(e)))
})
where 27: tools:::.buildOneVignette("acoustic_analysis.Rmd", "/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/soundgen.Rcheck/vign_test/soundgen", 
    TRUE, FALSE, "acoustic_analysis", "UTF-8", "/home/hornik/tmp/scratch/Rtmpe2FVeO/file28074310bc1.rds")

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (x, samplingRate = NULL, dynamicRange = 80, windowLength = 50, 
    step = NULL, overlap = 70, wn = "gaussian", zp = 0, normalize = TRUE, 
    scale = NULL, smoothFreq = 0, smoothTime = 0, qTime = 0, 
    percentNoise = 10, noiseReduction = 0, contrast = 0.2, brightness = 0, 
    method = c("spectrum", "spectralDerivative")[1], output = c("original", 
        "processed", "complex")[1], ylim = NULL, yScale = c("linear", 
        "log")[1], plot = TRUE, osc = FALSE, osc_dB = FALSE, 
    heights = c(3, 1), padWithSilence = TRUE, colorTheme = c("bw", 
        "seewave", "heat.colors", "...")[1], units = c("ms", 
        "kHz"), xlab = paste("Time,", units[1]), ylab = paste("Frequency,", 
        units[2]), mar = c(5.1, 4.1, 4.1, 2), main = "", grid = NULL, 
    frameBank = NULL, duration = NULL, pitch = NULL, ...) 
{
    sound = NULL
    if (overlap < 0 | overlap > 100) {
        warning("overlap must be >0 and <= 100%; resetting to 70")
        overlap = 70
    }
    if (is.null(step)) 
        step = windowLength * (1 - overlap/100)
    if (class(x) == "character") {
        extension = substr(x, nchar(x) - 2, nchar(x))
        if (extension == "wav" | extension == "WAV") {
            sound_wav = tuneR::readWave(x)
        }
        else if (extension == "mp3" | extension == "MP3") {
            sound_wav = tuneR::readMP3(x)
        }
        else {
            stop("Input not recognized: must be a numeric vector or wav/mp3 file")
        }
        samplingRate = sound_wav@samp.rate
        windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
            2
        sound = sound_wav@left
        maxAmpl = 2^(sound_wav@bit - 1)
        if (windowLength_points > (length(sound)/2)) {
            windowLength_points = floor(length(sound)/4) * 2
            step = windowLength_points/samplingRate * 1000 * 
                (1 - overlap/100)
        }
        if (windowLength_points == 0) {
            stop("The sound and/or the windowLength is too short for plotting a spectrogram")
        }
        duration = length(sound)/samplingRate
        frameBank = getFrameBank(sound = sound, samplingRate = samplingRate, 
            windowLength_points = windowLength_points, step = step, 
            zp = zp, normalize = normalize, wn = wn, filter = NULL, 
            padWithSilence = padWithSilence)
    }
    else if (class(x) == "numeric" & length(x) > 1) {
        if (is.null(samplingRate)) {
            stop("Please specify samplingRate, eg 44100")
        }
        else {
            sound = x
            if (is.null(scale)) {
                maxAmpl = max(abs(sound))
            }
            else {
                maxAmpl = scale
            }
            duration = length(sound)/samplingRate
            windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
                2
            if (windowLength_points > (length(sound)/2)) {
                windowLength_points = floor(length(sound)/4) * 
                  2
                step = windowLength_points/samplingRate * 1000 * 
                  (1 - overlap/100)
            }
            if (windowLength_points == 0) {
                stop("The sound and/or the windowLength is too short for plotting a spectrogram")
            }
            frameBank = getFrameBank(sound = sound, samplingRate = samplingRate, 
                windowLength_points = windowLength_points, step = step, 
                zp = zp, normalize = normalize, wn = wn, filter = NULL, 
                padWithSilence = padWithSilence)
        }
    }
    if (class(frameBank) != "matrix") {
        stop("Input format not recognized. Please provide path to .wav or .mp3 file,\n      a vector of amplitudes plus samplingRate, or a preprocessed frameBank")
    }
    if (is.null(ylim)) {
        if (units[2] == "kHz") {
            ylim = c(0, samplingRate/2/1000)
        }
        else {
            ylim = c(0, samplingRate/2)
        }
    }
    contrast_exp = exp(3 * contrast)
    brightness_exp = exp(3 * brightness)
    windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
        2
    if (!is.null(sound)) {
        if (windowLength_points > (length(sound)/2)) {
            windowLength_points = floor(length(sound)/4) * 2
            step = windowLength_points/samplingRate * 1000 * 
                (1 - overlap/100)
        }
    }
    if (windowLength_points == 0) {
        stop("The sound and/or the windowLength is too short for plotting a spectrogram")
    }
    z = apply(frameBank, 2, function(x) stats::fft(x)[1:(floor(nrow(frameBank)/2))])
    if (!is.matrix(z)) 
        z = matrix(z, ncol = 1)
    X = as.numeric(colnames(frameBank))
    if (length(X) < 2) {
        message("The sound is too short for plotting a spectrogram")
        return(NA)
    }
    bin_width = samplingRate/2/windowLength_points
    Y = seq(bin_width/2, samplingRate/2 - bin_width/2, length.out = nrow(z))/1000
    if (length(Y) < 2) {
        message("The sound and/or the windowLength is too short for plotting a spectrogram")
        return(NA)
    }
    rownames(z) = Y
    colnames(z) = X
    Z = t(abs(z))
    if (method == "spectralDerivative") {
        dZ_dt = cbind(rep(0, nrow(Z)), t(apply(Z, 1, diff)))
        dZ_df = rbind(rep(0, ncol(Z)), apply(Z, 2, diff))
        Z1 = sqrt(dZ_dt^2 + dZ_df^2)
    }
    else {
        Z1 = Z
    }
    threshold = max(Z1)/10^(dynamicRange/20)
    Z1[Z1 < threshold] = 0
    if (smoothTime > 1) {
        Z1 = t(apply(Z1, 1, function(x) {
            zoo::rollmedian(x, k = smoothTime, fill = 0)
        }))
    }
    if (smoothFreq > 1) {
        Z1 = apply(Z1, 2, function(x) {
            zoo::rollmedian(x, k = smoothFreq, fill = 0)
        })
    }
    if (qTime > 0) {
        Z1 = t(apply(Z1, 1, function(x) {
            x - quantile(x, probs = qTime)
        }))
    }
    positives = which(Z1 > 0)
    nonpositives = which(Z1 <= 0)
    Z1[positives] = log(Z1[positives])
    if (length(positives) > 0 & length(nonpositives) > 0) {
        Z1[nonpositives] = min(Z1[positives])
    }
    Z1 = Z1 - min(Z1)
    if (noiseReduction > 0) {
        entr = apply(Z1, 1, function(x) getEntropy(x))
        q = quantile(entr, probs = 1 - percentNoise/100, na.rm = TRUE)
        idx = as.numeric(which(entr >= q))
        if (length(idx) > 0) {
            noise_spectrum = as.numeric(apply(Z1[idx, , drop = FALSE], 
                2, mean))
            Z1 = t(apply(Z1, 1, function(x) x - noiseReduction * 
                noise_spectrum))
        }
        Z1[Z1 <= 0] = 0
    }
    if (contrast_exp != 1) {
        Z1 = Z1^contrast_exp
    }
    if (any(Z1 != 0)) 
        Z1 = Z1/max(Z1)
    if (brightness_exp != 1) {
        Z1 = Z1/brightness_exp
    }
    if (brightness_exp < 1) {
        Z1[Z1 > 1] = 1
    }
    if (plot) {
        color.palette = switchColorTheme(colorTheme)
        op = par(c("mar", "xaxt", "yaxt", "mfrow"))
        if (osc | osc_dB) {
            if (osc_dB) {
                sound = osc_dB(sound, dynamicRange = dynamicRange, 
                  maxAmpl = maxAmpl, plot = FALSE, returnWave = TRUE)
                ylim_osc = c(-dynamicRange, dynamicRange)
            }
            else {
                ylim_osc = c(-maxAmpl, maxAmpl)
            }
            layout(matrix(c(2, 1), nrow = 2, byrow = TRUE), heights = heights)
            par(mar = c(mar[1:2], 0, mar[4]), xaxt = "s", yaxt = "s")
            if (units[1] == "ms") {
                time_stamps = seq(0, duration * 1000, length.out = length(sound))
            }
            else {
                time_stamps = seq(0, duration, length.out = length(sound))
            }
            plot(time_stamps, sound, type = "l", ylim = ylim_osc, 
                axes = FALSE, xaxs = "i", yaxs = "i", bty = "o", 
                xlab = xlab, ylab = "", main = "", ...)
            box()
            axis(side = 1, ...)
            if (osc_dB) {
                axis(side = 4, at = seq(0, dynamicRange, by = 10), 
                  ...)
                mtext("dB", side = 2, line = 3, ...)
            }
            abline(h = 0, lty = 2)
            par(mar = c(0, mar[2:4]), xaxt = "n", yaxt = "s")
            xlab = ""
        }
        else {
            par(mar = mar)
        }
        min_log_freq = ifelse(units[2] == "kHz", 0.01, 10)
        if (yScale == "log" & ylim[1] < min_log_freq) 
            ylim[1] = min_log_freq
        if (units[1] == "ms") {
            xlim = c(0, duration * 1000)
        }
        else {
            X = X/1000
            xlim = c(0, duration)
        }
        if (units[2] != "kHz") 
            Y = Y * 1000
        filled.contour.mod(x = X, y = Y, z = Z1, levels = seq(0, 
            1, length = 30), color.palette = color.palette, ylim = ylim, 
            main = main, xlab = xlab, ylab = ylab, xlim = xlim, 
            log = ifelse(yScale == "log", "y", ""), ...)
        if (is.numeric(grid)) {
            n_grid_per_kHz = diff(range(ylim)) * grid
            if (units[2] != "kHz") 
                n_grid_per_kHz = n_grid_per_kHz/1000
            grid(nx = n_grid_per_kHz, ny = n_grid_per_kHz, col = rgb(0, 
                0, 0, 0.25, maxColorValue = 1), lty = 3)
        }
        if (!is.null(pitch)) {
            do.call(addPitchCands, pitch)
        }
        par(mar = op$mar, xaxt = op$xaxt, yaxt = op$yaxt, mfrow = op$mfrow)
    }
    if (output == "original") {
        out = t(Z)
    }
    else if (output == "processed") {
        out = t(Z1)
    }
    else if (output == "complex") {
        out = z
    }
    else {
        out = NULL
    }
    invisible(out)
}
<bytecode: 0x563cd708dc20>
<environment: namespace:soundgen>
 --- function search by body ---
Function spectrogram in namespace soundgen has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1
--- re-building ‘sound_generation.Rmd’ using rmarkdown
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
soundgen
 --- call from context --- 
spectrogram(bout, samplingRate = samplingRate, windowLength = windowLength, 
    overlap = overlap, dynamicRange = dynamicRange, ...)
 --- call from argument --- 
if (class(frameBank) != "matrix") {
    stop("Input format not recognized. Please provide path to .wav or .mp3 file,\n      a vector of amplitudes plus samplingRate, or a preprocessed frameBank")
}
 --- R stacktrace ---
where 1: spectrogram(bout, samplingRate = samplingRate, windowLength = windowLength, 
    overlap = overlap, dynamicRange = dynamicRange, ...)
where 2: soundgen(nSyl = 5, sylLen = c(300, 100), pauseLen = c(50, 150), 
    plot = TRUE, osc = TRUE, play = playback)
where 3: eval(expr, envir, enclos)
where 4: eval(expr, envir, enclos)
where 5: withVisible(eval(expr, envir, enclos))
where 6: withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, 
    error = eHandler, message = mHandler)
where 7: handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, 
    enclos)), warning = wHandler, error = eHandler, message = mHandler))
where 8: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, 
    envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
where 9: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
    debug = debug, last = i == length(out), use_try = stop_on_error != 
        2L, keep_warning = keep_warning, keep_message = keep_message, 
    output_handler = output_handler, include_timing = include_timing)
where 10: evaluate::evaluate(...)
where 11: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), 
    keep_message = !isFALSE(options$message), stop_on_error = if (options$error && 
        options$include) 0L else 2L, output_handler = knit_handlers(options$render, 
        options))
where 12: in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, 
    keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), 
    stop_on_error = if (options$error && options$include) 0L else 2L, 
    output_handler = knit_handlers(options$render, options)))
where 13: block_exec(params)
where 14: call_block(x)
where 15: process_group.block(group)
where 16: process_group(group)
where 17: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), 
    error = function(e) {
        setwd(wd)
        cat(res, sep = "\n", file = output %n% "")
        message("Quitting from lines ", paste(current_lines(i), 
            collapse = "-"), " (", knit_concord$get("infile"), 
            ") ")
    })
where 18: process_file(text, output)
where 19: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet, 
    encoding = encoding)
where 20: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(), 
    ...)
where 21: vweave_rmarkdown(...)
where 22: engine$weave(file, quiet = quiet, encoding = enc)
where 23: doTryCatch(return(expr), name, parentenv, handler)
where 24: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 25: tryCatchList(expr, classes, parentenv, handlers)
where 26: tryCatch({
    engine$weave(file, quiet = quiet, encoding = enc)
    setwd(startdir)
    output <- find_vignette_product(name, by = "weave", engine = engine)
    if (!have.makefile && vignette_is_tex(output)) {
        texi2pdf(file = output, clean = FALSE, quiet = quiet)
        output <- find_vignette_product(name, by = "texi2pdf", 
            engine = engine)
    }
}, error = function(e) {
    OK <<- FALSE
    message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s", 
        file, conditionMessage(e)))
})
where 27: tools:::.buildOneVignette("sound_generation.Rmd", "/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/soundgen.Rcheck/vign_test/soundgen", 
    TRUE, FALSE, "sound_generation", "UTF-8", "/home/hornik/tmp/scratch/Rtmpe2FVeO/file28075161b3d2.rds")

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (x, samplingRate = NULL, dynamicRange = 80, windowLength = 50, 
    step = NULL, overlap = 70, wn = "gaussian", zp = 0, normalize = TRUE, 
    scale = NULL, smoothFreq = 0, smoothTime = 0, qTime = 0, 
    percentNoise = 10, noiseReduction = 0, contrast = 0.2, brightness = 0, 
    method = c("spectrum", "spectralDerivative")[1], output = c("original", 
        "processed", "complex")[1], ylim = NULL, yScale = c("linear", 
        "log")[1], plot = TRUE, osc = FALSE, osc_dB = FALSE, 
    heights = c(3, 1), padWithSilence = TRUE, colorTheme = c("bw", 
        "seewave", "heat.colors", "...")[1], units = c("ms", 
        "kHz"), xlab = paste("Time,", units[1]), ylab = paste("Frequency,", 
        units[2]), mar = c(5.1, 4.1, 4.1, 2), main = "", grid = NULL, 
    frameBank = NULL, duration = NULL, pitch = NULL, ...) 
{
    sound = NULL
    if (overlap < 0 | overlap > 100) {
        warning("overlap must be >0 and <= 100%; resetting to 70")
        overlap = 70
    }
    if (is.null(step)) 
        step = windowLength * (1 - overlap/100)
    if (class(x) == "character") {
        extension = substr(x, nchar(x) - 2, nchar(x))
        if (extension == "wav" | extension == "WAV") {
            sound_wav = tuneR::readWave(x)
        }
        else if (extension == "mp3" | extension == "MP3") {
            sound_wav = tuneR::readMP3(x)
        }
        else {
            stop("Input not recognized: must be a numeric vector or wav/mp3 file")
        }
        samplingRate = sound_wav@samp.rate
        windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
            2
        sound = sound_wav@left
        maxAmpl = 2^(sound_wav@bit - 1)
        if (windowLength_points > (length(sound)/2)) {
            windowLength_points = floor(length(sound)/4) * 2
            step = windowLength_points/samplingRate * 1000 * 
                (1 - overlap/100)
        }
        if (windowLength_points == 0) {
            stop("The sound and/or the windowLength is too short for plotting a spectrogram")
        }
        duration = length(sound)/samplingRate
        frameBank = getFrameBank(sound = sound, samplingRate = samplingRate, 
            windowLength_points = windowLength_points, step = step, 
            zp = zp, normalize = normalize, wn = wn, filter = NULL, 
            padWithSilence = padWithSilence)
    }
    else if (class(x) == "numeric" & length(x) > 1) {
        if (is.null(samplingRate)) {
            stop("Please specify samplingRate, eg 44100")
        }
        else {
            sound = x
            if (is.null(scale)) {
                maxAmpl = max(abs(sound))
            }
            else {
                maxAmpl = scale
            }
            duration = length(sound)/samplingRate
            windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
                2
            if (windowLength_points > (length(sound)/2)) {
                windowLength_points = floor(length(sound)/4) * 
                  2
                step = windowLength_points/samplingRate * 1000 * 
                  (1 - overlap/100)
            }
            if (windowLength_points == 0) {
                stop("The sound and/or the windowLength is too short for plotting a spectrogram")
            }
            frameBank = getFrameBank(sound = sound, samplingRate = samplingRate, 
                windowLength_points = windowLength_points, step = step, 
                zp = zp, normalize = normalize, wn = wn, filter = NULL, 
                padWithSilence = padWithSilence)
        }
    }
    if (class(frameBank) != "matrix") {
        stop("Input format not recognized. Please provide path to .wav or .mp3 file,\n      a vector of amplitudes plus samplingRate, or a preprocessed frameBank")
    }
    if (is.null(ylim)) {
        if (units[2] == "kHz") {
            ylim = c(0, samplingRate/2/1000)
        }
        else {
            ylim = c(0, samplingRate/2)
        }
    }
    contrast_exp = exp(3 * contrast)
    brightness_exp = exp(3 * brightness)
    windowLength_points = floor(windowLength/1000 * samplingRate/2) * 
        2
    if (!is.null(sound)) {
        if (windowLength_points > (length(sound)/2)) {
            windowLength_points = floor(length(sound)/4) * 2
            step = windowLength_points/samplingRate * 1000 * 
                (1 - overlap/100)
        }
    }
    if (windowLength_points == 0) {
        stop("The sound and/or the windowLength is too short for plotting a spectrogram")
    }
    z = apply(frameBank, 2, function(x) stats::fft(x)[1:(floor(nrow(frameBank)/2))])
    if (!is.matrix(z)) 
        z = matrix(z, ncol = 1)
    X = as.numeric(colnames(frameBank))
    if (length(X) < 2) {
        message("The sound is too short for plotting a spectrogram")
        return(NA)
    }
    bin_width = samplingRate/2/windowLength_points
    Y = seq(bin_width/2, samplingRate/2 - bin_width/2, length.out = nrow(z))/1000
    if (length(Y) < 2) {
        message("The sound and/or the windowLength is too short for plotting a spectrogram")
        return(NA)
    }
    rownames(z) = Y
    colnames(z) = X
    Z = t(abs(z))
    if (method == "spectralDerivative") {
        dZ_dt = cbind(rep(0, nrow(Z)), t(apply(Z, 1, diff)))
        dZ_df = rbind(rep(0, ncol(Z)), apply(Z, 2, diff))
        Z1 = sqrt(dZ_dt^2 + dZ_df^2)
    }
    else {
        Z1 = Z
    }
    threshold = max(Z1)/10^(dynamicRange/20)
    Z1[Z1 < threshold] = 0
    if (smoothTime > 1) {
        Z1 = t(apply(Z1, 1, function(x) {
            zoo::rollmedian(x, k = smoothTime, fill = 0)
        }))
    }
    if (smoothFreq > 1) {
        Z1 = apply(Z1, 2, function(x) {
            zoo::rollmedian(x, k = smoothFreq, fill = 0)
        })
    }
    if (qTime > 0) {
        Z1 = t(apply(Z1, 1, function(x) {
            x - quantile(x, probs = qTime)
        }))
    }
    positives = which(Z1 > 0)
    nonpositives = which(Z1 <= 0)
    Z1[positives] = log(Z1[positives])
    if (length(positives) > 0 & length(nonpositives) > 0) {
        Z1[nonpositives] = min(Z1[positives])
    }
    Z1 = Z1 - min(Z1)
    if (noiseReduction > 0) {
        entr = apply(Z1, 1, function(x) getEntropy(x))
        q = quantile(entr, probs = 1 - percentNoise/100, na.rm = TRUE)
        idx = as.numeric(which(entr >= q))
        if (length(idx) > 0) {
            noise_spectrum = as.numeric(apply(Z1[idx, , drop = FALSE], 
                2, mean))
            Z1 = t(apply(Z1, 1, function(x) x - noiseReduction * 
                noise_spectrum))
        }
        Z1[Z1 <= 0] = 0
    }
    if (contrast_exp != 1) {
        Z1 = Z1^contrast_exp
    }
    if (any(Z1 != 0)) 
        Z1 = Z1/max(Z1)
    if (brightness_exp != 1) {
        Z1 = Z1/brightness_exp
    }
    if (brightness_exp < 1) {
        Z1[Z1 > 1] = 1
    }
    if (plot) {
        color.palette = switchColorTheme(colorTheme)
        op = par(c("mar", "xaxt", "yaxt", "mfrow"))
        if (osc | osc_dB) {
            if (osc_dB) {
                sound = osc_dB(sound, dynamicRange = dynamicRange, 
                  maxAmpl = maxAmpl, plot = FALSE, returnWave = TRUE)
                ylim_osc = c(-dynamicRange, dynamicRange)
            }
            else {
                ylim_osc = c(-maxAmpl, maxAmpl)
            }
            layout(matrix(c(2, 1), nrow = 2, byrow = TRUE), heights = heights)
            par(mar = c(mar[1:2], 0, mar[4]), xaxt = "s", yaxt = "s")
            if (units[1] == "ms") {
                time_stamps = seq(0, duration * 1000, length.out = length(sound))
            }
            else {
                time_stamps = seq(0, duration, length.out = length(sound))
            }
            plot(time_stamps, sound, type = "l", ylim = ylim_osc, 
                axes = FALSE, xaxs = "i", yaxs = "i", bty = "o", 
                xlab = xlab, ylab = "", main = "", ...)
            box()
            axis(side = 1, ...)
            if (osc_dB) {
                axis(side = 4, at = seq(0, dynamicRange, by = 10), 
                  ...)
                mtext("dB", side = 2, line = 3, ...)
            }
            abline(h = 0, lty = 2)
            par(mar = c(0, mar[2:4]), xaxt = "n", yaxt = "s")
            xlab = ""
        }
        else {
            par(mar = mar)
        }
        min_log_freq = ifelse(units[2] == "kHz", 0.01, 10)
        if (yScale == "log" & ylim[1] < min_log_freq) 
            ylim[1] = min_log_freq
        if (units[1] == "ms") {
            xlim = c(0, duration * 1000)
        }
        else {
            X = X/1000
            xlim = c(0, duration)
        }
        if (units[2] != "kHz") 
            Y = Y * 1000
        filled.contour.mod(x = X, y = Y, z = Z1, levels = seq(0, 
            1, length = 30), color.palette = color.palette, ylim = ylim, 
            main = main, xlab = xlab, ylab = ylab, xlim = xlim, 
            log = ifelse(yScale == "log", "y", ""), ...)
        if (is.numeric(grid)) {
            n_grid_per_kHz = diff(range(ylim)) * grid
            if (units[2] != "kHz") 
                n_grid_per_kHz = n_grid_per_kHz/1000
            grid(nx = n_grid_per_kHz, ny = n_grid_per_kHz, col = rgb(0, 
                0, 0, 0.25, maxColorValue = 1), lty = 3)
        }
        if (!is.null(pitch)) {
            do.call(addPitchCands, pitch)
        }
        par(mar = op$mar, xaxt = op$xaxt, yaxt = op$yaxt, mfrow = op$mfrow)
    }
    if (output == "original") {
        out = t(Z)
    }
    else if (output == "processed") {
        out = t(Z1)
    }
    else if (output == "complex") {
        out = z
    }
    else {
        out = NULL
    }
    invisible(out)
}
<bytecode: 0x5573ff74c680>
<environment: namespace:soundgen>
 --- function search by body ---
Function spectrogram in namespace soundgen has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1
SUMMARY: processing the following files failed:
  ‘acoustic_analysis.Rmd’ ‘sound_generation.Rmd’

Error: Vignette re-building failed.
Execution halted