Internal soundgen function.
clumper(s, minLength)
a vector (soundgen supplies integers, but clumper
also works
on a vector of floats, characters or booleans)
an integer or vector of integers indicating the desired length of a segment at each position (can vary with time, e.g., if we are processing pitch_per_gc values)
Returns the original sequence s transformed to homogeneous segments of required length.
clumper
makes sure each homogeneous segment in a sequence is at least
minLength long. Called by getIntegerRandomWalk() and getVocalFry(). Algorithm:
go through the sequence once. If a short segment is encountered, it is pooled
with the previous one (i.e., the currently evaluated segment grows until it
is long enough, which may shorten the following segment). Finally, the last
segment is checked separately. This is CRUDE - a smart implementation is
pending!
# NOT RUN {
s = c(1,3,2,2,2,0,0,4,4,1,1,1,1,1,3,3)
soundgen:::clumper(s, 2)
soundgen:::clumper(s, 3)
soundgen:::clumper(s, seq(1, 3, length.out = length(s)))
soundgen:::clumper(c('a','a','a','b','b','c','c','c','a','c'), 4)
# }
Run the code above in your browser using DataLab