applyEnvelope: Apply an envelope

View source: R/class_envelope.R

applyEnvelopeR Documentation

Apply an envelope

Description

Apply a volume envelope to a sound sample.

Usage

applyEnvelope(sample, env)

Arguments

sample

Sound sample object.

env

Envelope object. Envelope values should all be between 0 and 1.

Value

A sound sample object.

Examples

# Define the sound sample
sam <- soundSample(sin(2*pi*seq(0,0.5,1/44100)*220)) # 0.5-second A (220 Hz)
# Define the envelope
env <- envelope(t=c(0,0.03,1),v=c(0,1,0))
# Apply it
res <- applyEnvelope(sam,env)
# Compare waveforms
plot(sam,main='before')
plot(res,main='after')
## Not run: 
# This line of code is wrapped in \dontrun{} since it relies
# on an external audio player to listen to the audio sample.
# See ?tuneR::setWavPlayer for setting a default player.
listen(res)
## End(Not run)

benRenard/sequenceR documentation built on Jan. 11, 2025, 2:33 a.m.