shape_scatter {playitbyr} | R Documentation |
Creates a scatterplot layer; the audio analogue of
ggplot2's geom_point
.
shape_scatter(jitter = 0, relative = TRUE, ..., data = NULL, mapping = NULL)
jitter |
The maximum size, in seconds, of how much to jitter time by when there are multiple notes at the same pitch and time (the sonic equivalent of overplotting). The default, 0, means no jitter occurs. |
relative |
Make the duration relative to the overall
length of the sonification? The default, |
... |
settings to pass to |
data |
The |
mapping |
A |
The audio scatterplot is implemented by a simple frequency-modulation synthesis (through Csound). The following parameters are available for setting or mapping:
The starting time of the note (in seconds).
The pitch of the note, in the
Csound
oct
notation notation for pitches, where 8 is middle C and 1
represents an octave, to the corresponding frequency in
Hertz. By default this is scaled to the nearest musical
(chromatic) pitch. (See
scale_pitch_continuous
.)
The
duration of the note (relative to the total time if
relative = TRUE
, in seconds otherwise).
The volume of the note, as a proportion between 0 and 1, where 1 is the maximum volume. Note that a multiple notes that happen at the same time could add up to more than one, causing distortion and clipping.
The proportion of the note's length devoted to the initial (linear) attack.
The proportion of the note's length devoted to the (linear) decay.
The index of modulation. This affects
the distortion of the tone; indx = 0
is a sine
wave, whereas higher indices of modulation give
increasingly complex tones.
The modulating
frequency, given as a multiple of the primary frequency
(i.e. given by pitch
).
To set a sound parameter to a value, you simply
include it as an extra argument in shape_scatter
;
to map a parameter, you set the mapping for the
layer or the sonify
object using
sonaes
(see examples).
A sonlayer
object that can be added onto a
sonify
object.
x1 <- sonify(iris, sonaes(time = Petal.Width, pitch = Petal.Length)) + shape_scatter() # no jitter ## Not run: x1 x2 <- sonify(iris, sonaes(time = Petal.Width, pitch = Petal.Length)) + shape_scatter(jitter = 0.3) # substantial jitter, fuzzes out overlap ## Not run: x2 ## relative = TRUE: rescales duration to fit overall length (usually easier to hear) d <- cbind(airquality, row = rownames(airquality)) x3 <- sonify(d, sonaes(time = row, pitch = Temp)) + shape_scatter(dur = 3) + scale_time_continuous(c(0, 10)) ## Not run: x3 x4 <- sonify(d, sonaes(time = row, pitch = Temp)) + shape_scatter(dur = 3) + scale_time_continuous(c(0, 5)) ## Not run: x4 ## relative = FALSE: duration is in seconds and is not scaled to fit overall length ## (creates lots of overlap) x5 <- sonify(d, sonaes(time = row, pitch = Temp)) + shape_scatter(relative = FALSE, dur = 3) + scale_time_continuous(c(0, 10)) ## Not run: x5 x6 <- sonify(d, sonaes(time = row, pitch = Temp)) + shape_scatter(relative = FALSE, dur = 3) + scale_time_continuous(c(0, 5)) ## Not run: x6 ## Setting the pitch equal to 8 (C), and using iris$Sepal.Width ## to generate the timings of notes##' x7 <- sonify(iris[1:10,], sonaes(time = Sepal.Width)) + shape_scatter(pitch = 9) ## Not run: x7 ## Instead, /mapping/ the pitch to 9. x8 <- sonify(iris[1:10,], sonaes(time = Sepal.Width)) + shape_scatter(pitch = 9) ## Not run: x8 ## If a value in the mapping ## is a vector and is not a name of the data column, playitbyr ## creates a new column with that value. This is then scaled, ## producing an unexpected F# (8.5) here when you might expect the same ## sound as above!