View source: R/soundgen_utilities.R
wiggleAnchors | R Documentation |
Internal soundgen function.
wiggleAnchors(
df,
temperature = 0.05,
temp_coef = 1,
low = c(0, -Inf),
high = c(1, Inf),
wiggleAllRows = FALSE,
sd_values = NULL,
roundToInteger = FALSE,
invalidArgAction = c("adjust", "abort", "ignore")[1]
)
df |
dataframe of anchors, for ex. |
temperature , temp_coef |
regulate the amount of stochasticity
("wiggling"). Since |
low , high |
bounds on possible variation. Both |
wiggleAllRows |
should the first and last time anchors be wiggled? (TRUE for breathing, FALSE for other anchors) |
sd_values |
(optional) the exact value of sd used by rnorm_truncated in columns 2 and beyond |
roundToInteger |
if TRUE, rounds the values (not time points) |
invalidArgAction |
what to do if an argument is invalid or outside the
range in |
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!
Modified original dataframe.
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, single 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)
# manually provided sd (temp only affects prob of adding/dropping anchors)
soundgen:::wiggleAnchors(df = data.frame(
time = c(0, .1, .8, 1), value = c(100, 230, 180, 90)),
wiggleAllRows = FALSE, sd_values = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.