# NOT RUN {
a = rnorm(500) * seq(1, 0, length.out = 500)
b = flatEnv(a, plot = TRUE, windowLength_points = 5) # too short
c = flatEnv(a, plot = TRUE, windowLength_points = 250) # too long
d = flatEnv(a, plot = TRUE, windowLength_points = 50) # about right
# }
# NOT RUN {
s = soundgen(sylLen = 1000, ampl = c(0, -40, 0), plot = TRUE, osc = TRUE)
# playme(s)
s_flat1 = flatEnv(s, plot = TRUE, windowLength = 50, method = 'hil')
s_flat2 = flatEnv(s, plot = TRUE, windowLength = 10, method = 'rms')
s_flat3 = flatEnv(s, plot = TRUE, windowLength = 10, method = 'peak')
# playme(s_flat2)
# Remove DC offset
s1 = c(rep(0, 50), runif(1000, -1, 1), rep(0, 50)) +
seq(.3, 1, length.out = 1100)
s2 = flatEnv(s1, plot = TRUE, windowLength_points = 50, killDC = FALSE)
s3 = flatEnv(s1, plot = TRUE, windowLength_points = 50, killDC = TRUE)
# }
Run the code above in your browser using DataLab