clumper: Clump a sequence into large segments

Description Usage Arguments Details Value Examples

View source: R/utilities_math.R

Description

Internal soundgen function.

Usage

1
clumper(s, minLength)

Arguments

s

a vector (soundgen supplies integers, but clumper also works on a vector of floats, characters or booleans)

minLength

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)

Details

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!

Value

Returns the original sequence s transformed to homogeneous segments of required length.

Examples

1
2
3
4
5
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)

tatters/soundgen_beta documentation built on May 14, 2019, 9 a.m.