View source: R/postprocessing.R
| reverb | R Documentation |
Adds reverberation and/or echo to a sound parametrically or based on the impulse response recorded in a particular real environment. Algorithm for parametric reverb: adds time-shifted copies of the signal weighted by a decay function. In simple terms: we specify how much and when the sound rebounds back (e.g., from the walls of a room) and add these time-shifted copies to the original - optionally, with some spectral filtering.
reverb(
x,
samplingRate = NULL,
echoDelay = 200,
echoLevel = -20,
reverbDelay = 70,
reverbSpread = 130,
reverbLevel = -25,
reverbDensity = 50,
reverbType = "gaussian",
IR = NULL,
filter = list(),
dynamicRange = 80,
output = c("audio", "detailed"),
play = FALSE,
saveAudio = FALSE,
reportEvery = NULL,
cores = 1,
seed = NULL
)
x |
path to a folder, one or more wav or mp3 files c('file1.wav', 'file2.mp3'), Wave object, numeric vector, or a list of Wave objects or numeric vectors |
samplingRate |
sampling rate of |
echoDelay |
the delay at which the echo appears, ms |
echoLevel |
the rate at which the echo weakens at each repetition, dB (NULL = no echo) |
reverbDelay |
the time of maximum reverb density, ms |
reverbSpread |
standard deviation of reverb spread around time
|
reverbLevel |
the maximum amplitude of reverb, dB below input (NULL = no reverb) |
reverbDensity |
the number of echos or "voices" added |
reverbType |
so far only "gaussian" has been implemented |
IR |
recording of an impulse response in a particular environment - ideally, an instant loud click, but just clapping your hands or snapping your fingers also works as a first approximation |
filter |
(optional) a spectral filter to apply to the created reverb and
echo (see |
dynamicRange |
the precision with which the reverb and echo are calculated, dB |
output |
"audio" = returns just the processed audio, "detailed" = returns a list with reverb window, the added reverb/echo, etc. |
play |
if TRUE, plays the output audio using the default player on your
system. If a character string, it is passed to |
saveAudio |
if TRUE, saves the processed audio in a subdirectory named after the function and created in the input directory (if input is a file or folder) or in the working directory |
reportEvery |
when processing multiple inputs, report estimated time
left every |
cores |
number of cores for parallel processing |
seed |
if NULL, the algorithm is stochastic; provide a positive integer for reproducibility |
If output = "audio", returns the processed waveform as a
numeric vector. If output = "detailed", returns a list: $rvb_win =
Gaussian window used to create the reverberation, $rvb = reverberation
effect, $echo = echo effect, $effect = both reverb and echo mixed together,
$audio = processed audio.
data('speechEx', package = 'soundgen')
sr = speechEx@samp.rate
s = speechEx@left[1:16000]
# playme(s)
# parametric reverb
s_rev = reverb(s, sr)
# playme(s_rev)
# reverb of a particular real place based on its recorded IR
data('IR', package = 'soundgen')
s_ir = reverb(s, sr, IR = IR)
# playme(s_ir)
## Not run:
# double echo, no reverb
s1 = reverb(s, sr, reverbLevel = NULL,
echoDelay = c(250, 800), echoLevel = c(-15, -25))
playme(s1)
spectrogram(s1, 16000, ylim = c(0, 4))
# only reverb (indoors)
s2 = reverb(s, sr, echoDelay = NULL,
reverbDelay = 70, reverbSpread = 130,
reverbLevel = -20, reverbDensity = 20)
playme(s2)
spectrogram(s2, 16000, ylim = c(0, 4))
# reverb (caves)
s3 = reverb(s, sr, echoDelay = NULL,
reverbDelay = 600, reverbSpread = 1500,
reverbLevel = -10, reverbDensity = 100)
playme(s3)
spectrogram(s3, 16000, ylim = c(0, 4))
# both echo and reverb with high frequencies emphasized
s4 = reverb(s, sr,
echoDelay = 250, echoLevel = -20,
reverbDelay = 70, reverbSpread = 120,
reverbLevel = -25, reverbDensity = 50,
filter = list(formants = NULL, lipRad = 3))
playme(s4)
spectrogram(s4, 16000, ylim = c(0, 4))
# recorded IR
s5 = soundgen(nSyl = 2, sylLen = 250, pitch = c(500, 300))
playme(s5)
spectrogram(s5, 16000, yScale = 'ERB')
s5r = reverb(s5, 16000, IR = IR)
playme(s5r)
spectrogram(s5r, 16000, yScale = 'ERB')
# add reverb to all files in a folder, save the result
reverb('~/Downloads/temp', saveAudio = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.