wiggleAnchors: Randomly modify anchors

Description Usage Arguments Details Value Examples

View source: R/utilities_soundgen.R

Description

Internal soundgen function.

Usage

1
wiggleAnchors(df, temperature, temp_coef, low, high, wiggleAllRows = FALSE)

Arguments

df

dataframe of anchors, for ex. data.frame(time = c(0, .1, .8, 1), value = c(100, 230, 180, 90))

temperature, temp_coef

regulate the amount of stochasticity ("wiggling"). Since temperature is used in several functions, temp_coef gives more flexibility by controlling how much temperature affects this particular aspect, namely random variation in anchors. These two are multiplied, so temp_coef of 0.5 halves the effect of temperature.

low, high

bounds on possible variation. Both low and high should be vectors of length 2: the first element specifies the boundary for df$time and the second for df$value. Ex.: low = c(0,1) - low bound on "time"=0, low bound on "value"=1

wiggleAllRows

should the firts and last time anchors be wiggled? (TRUE for breathing, FALSE for other anchors)

Details

A helper function for introducing random variation into any anchors (for pitch / breathing / amplitude / ...). At higher temperatures can also add or delete an anchor. NB: make sure the lower and upper bounds are reasonable given the scale of df$value!

Value

Modified original dataframe.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
soundgen:::wiggleAnchors(df = data.frame(
  time = c(0, .1, .8, 1), value = c(100, 230, 180, 90)),
  temperature = .2, temp_coef = .1, low = c(0, 50), high = c(1, 1000),
  wiggleAllRows = FALSE) # pitch
soundgen:::wiggleAnchors(df = data.frame(time = 0, value = 240),
  temperature = .2, temp_coef = .1, low = c(0, 50), high = c(1, 1000),
  wiggleAllRows = FALSE) # pitch, sinle anchor
soundgen:::wiggleAnchors(df = data.frame(
  time = c(-100, 100, 600, 900), value = c(-120, -80, 0, -120)),
  temperature = .4, temp_coef = .5, low = c(-Inf, -120), high = c(+Inf, 30),
  wiggleAllRows = TRUE) # noise
# formants
formants = list(f1 = list(time = 0, freq = 860, amp = 30, width = 120),
                f2 = list(time = c(0,1), freq = 1280,
                amp = c(10,40), width = 120))
for (f in 1:length(formants)) {
  formants[[f]] = soundgen:::wiggleAnchors(
    df = formants[[f]],
    temperature = .4, temp_coef = .5,
    low = c(0, 50, 0, 1),
    high = c(1, 8000, 120, 2000),
    wiggleAllRows = FALSE
  )
}
print(formants)

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