scaleShortcuts: Shortcut functions to set linear scales for 'sonify' objects

Description Usage Arguments Details Value See Also Examples

Description

These shortcut functions (with the notation scale_[data parameter]_[scaling function]) are intended to be added onto a sonify object to specify how [data parameter] from the data (a column of the data) is to be mapped to sonic parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

Arguments

min

The desired minimum value, a numeric of length 1

max

The desired maximum value, a numeric of length 1

Details

The syntax of specifying a full sonify object can be rather verbose. Inspired by the ggplot2 package, playitbyr provides shortcut functions to make the process easier and more intuitive.

These functions are intended to be added onto a pre-existing sonify object, as shown in the examples.

Value

A sonscaling object, to be used in sonify or added onto a sonify object.

See Also

sonscaling for the full syntax and range of possibilities for specifying scaling of sonify objects; linear.scale for the pre-defined linear scaling function which this incorporates; +.sonify for the addition onto sonify objects.

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
26
27
28
29
30
## A verbose way of specifying a sonify object,
## without using the shortcuts
x <- sonify(data=iris,
sonaes(time=Petal.Width, pitch=Petal.Length, dur=5, vol=0.75),
scales = sonscaling(
time = list(min=0, max=3,
scaling.function = linear.scale),
pitch = list(min=3, max=13,
scaling.function = linear.scale)),
sonlayers = shape_notes())
summary(x)
## Not run: x

## An equivalent and much more readable way, with
## the shortcut functions
y <- sonify(iris, sonaes(time=Petal.Width, pitch=Petal.Length, dur=5, vol=0.75))
y <- y + shape_notes()
y <- y + scale_time_linear(0, 3)
y <- y + scale_pitch_linear(3, 13)
summary(y)
## Not run: y

## You can also change a mapping incrementally.
## New parameters overwrite old ones, so now
## the sonification is stretched to 12 seconds
## long instead of 3, and the pitch is mapped to
## a much narrower range, the octave below tuning A (440 Hz)
y <- y + scale_time_linear(0, 12) + scale_pitch_linear(7, 8)
summary(y)
## Not run: y

playitbyr documentation built on May 2, 2019, 6:08 p.m.