Learn R Programming

soundgen (version 1.1.0)

fadeInOut: Fade-in and fade-out

Description

Internal soundgen function.

Usage

fadeInOut(ampl, do_fadeIn = TRUE, do_fadeOut = TRUE, length_fade = 1000)

Arguments

ampl

numeric vector such as a waveform

do_fadeIn, do_fadeOut

(logical) perform linear fade-in / fade-out?

length_fade

the length of affected region, in points (expects an integer > 1, otherwise just returns the original vector with no modifications)

Value

Returns a numeric vector of the same length as input

Details

Applies linear fade-in and fade-out of length 'length_fade' points to one or both ends of input vector.

Examples

Run this code
# NOT RUN {
ampl = sin(1:1000)
plot(soundgen:::fadeInOut(ampl, length_fade = 100), type = 'l')
plot(soundgen:::fadeInOut(ampl, length_fade = 300,
  do_fadeOut = FALSE), type = 'l')
# if the vector is shorter than twice the specified length_fade,
# fade-in/out regions overlap
plot(soundgen:::fadeInOut(ampl, length_fade = 700), type = 'l')
# }

Run the code above in your browser using DataLab