Extracts a smoothed amplitude envelope of the donor
sound and applies
it to the recipient
sound. Both sounds are provided as numeric
vectors; they 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. Very similar to
setenv
, but with a different smoothing algorithm and
with a choice of several types of envelope: hil, rms, or peak.
transplantEnv(
donor,
samplingRateD = NULL,
recipient,
samplingRateR = samplingRateD,
windowLength = 50,
method = c("hil", "rms", "peak")[3],
killDC = FALSE,
dynamicRange = 80,
plot = FALSE
)
Returns the recipient sound with the donor's amplitude envelope - a numeric vector with the same sampling rate as the recipient
the sound that "donates" the amplitude envelope
sampling rate of the donor and recipient, respectively (only needed for vectors, not files)
the sound that needs to have its amplitude envelope adjusted
the length of smoothing window, ms
hil = Hilbert envelope, rms = root mean square amplitude, peak = peak amplitude per window
if TRUE, dynamically removes DC offset or similar deviations of average waveform from zero (see examples)
parts of sound quieter than -dynamicRange
dB will
not be amplified
if TRUE, plots the original sound, the smoothed envelope, and the compressed sound
flatEnv
setenv
donor = rnorm(500) * seq(1, 0, length.out = 500)
recipient = soundgen(sylLen = 600, addSilence = 50)
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)
Run the code above in your browser using DataLab