a = rnorm(500) * seq(1, 0, length.out = 500)
b = flatEnv(a, 1000, plot = TRUE, windowLength_points = 5) # too short
c = flatEnv(a, 1000, plot = TRUE, windowLength_points = 450) # too long
d = flatEnv(a, 1000, plot = TRUE, windowLength_points = 100) # about right
if (FALSE) {
s = soundgen(sylLen = 1000, ampl = c(0, -40, 0), plot = TRUE)
# playme(s)
s_flat1 = flatEnv(s, 16000, dynamicRange = 60, plot = TRUE,
windowLength = 50, method = 'hil')
s_flat2 = flatEnv(s, 16000, dynamicRange = 60, plot = TRUE,
windowLength = 10, method = 'rms')
s_flat3 = flatEnv(s, 16000, dynamicRange = 60, 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, 16000, plot = TRUE, windowLength_points = 50, killDC = FALSE)
s3 = flatEnv(s1, 16000, plot = TRUE, windowLength_points = 50, killDC = TRUE)
# Compress and save all audio files in a folder
s4 = flatEnv('~/Downloads/temp',
method = 'peak', compression = .5,
saveAudio = '~/Downloads/temp/compressed',
savePlots = '~/Downloads/temp/compressed',
col = 'green', lwd = 5)
osc(s4[[1]])
}
Run the code above in your browser using DataLab