| transplantEnv | R Documentation |
Extracts a smoothed amplitude envelope of the donor sound and applies
it to the recipient sound. The sounds can differ in length and
sampling rate. Note that the result depends on the amount of smoothing
(controlled by windowLength) and the chosen method of calculating the
envelope. This is similar to "setenv" from the seewave package, but with a
different smoothing algorithm and with a choice of several types of envelope:
rms, hil, peak, etc. - see flatEnv.
transplantEnv(
donor,
recipient,
samplingRateR = NULL,
samplingRateD = samplingRateR,
windowLength = 30,
method = c("rms", "hil", "peak", "mean"),
killDC = FALSE,
dynamicRange = 30,
plot = FALSE
)
donor |
the sound that "donates" the amplitude envelope |
recipient |
the sound that needs to have its amplitude envelope adjusted |
samplingRateD, samplingRateR |
sampling rate of the donor and recipient, respectively (only needed for vectors, not files); they don't hav to match |
windowLength |
the length of smoothing window, ms |
method |
hil = Hilbert envelope, rms = root mean square amplitude, peak = peak amplitude per window |
killDC |
if TRUE, dynamically removes DC offset or similar deviations of average waveform from zero (see examples) |
dynamicRange |
parts of sound quieter than |
plot |
if TRUE, plots the original sound, the smoothed envelope, and the compressed sound |
The recipient sound with the donor's amplitude envelope - a numeric vector with the same sampling rate and length as the recipient.
flatEnv
donor = c(rep(0, 50), rnorm(500)) * seq(1, 0, length.out = 550)
data('speechEx', package = 'soundgen')
recipient = speechEx@left[1000:4000]
transplantEnv(donor, samplingRateD = 200,
recipient, samplingRateR = 16000,
windowLength = 50, method = 'hil', plot = TRUE)
transplantEnv(donor, samplingRateD = 200,
recipient, samplingRateR = 16000,
windowLength = 10, method = 'peak', plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.