shape_histogram: Create a histogram layer

View source: R/shape-histogram.R

shape_histogramR Documentation

Create a histogram layer

Description

Creates a histogram layer

Usage

  shape_histogram(length = 5, tempo = 240, ...,
    data = NULL, mapping = NULL)

Arguments

length

The overall length, in seconds, of the histogram.

tempo

The tempo, in beats per minute; i.e. the rapidity with which to represent values from the dataset.

...

settings to pass to sonlayer (see Details)

data

The data.frame to be sonified for this layer. If blank, the data from the parent sonify object is used.

mapping

A sonaes object.

Details

The audio histogram is implemented by a simple frequency-modulation synthesis (through csound), representing a univariate view of the data by rapidly playing pitches that are samples from the dataset. Only pitch is intended to be used for mapping.

To compare groups, one can facet by the grouping variable (see sonfacet). All of the examples below use this technique.

The remainder of the sound parameters (the same as those used by shape_scatter) are available for setting to tweak aesthetics for the analyst's ear:

time

The starting time of the note (in seconds).

pitch

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.)

dur

The duration of the note (relative to the total time if relative = TRUE, in seconds otherwise).

amp

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.

attkp

The proportion of the note's length devoted to the initial (linear) attack.

decayp

The proportion of the note's length devoted to the (linear) decay.

indx

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.

mod

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 in shape_scatter).

Value

A sonlayer object that can be added onto a sonify object.

References

S. Ferguson, W. Martens and D. Cabrera, “Statistical Sonification for Exploratory Data Analysis”, in The Sonification Handbook, ed. Hermann, Hunt, Neuhoff. Available: http://sonification.de/handbook/

Examples

x1 <- sonify(iris, sonaes(pitch = Sepal.Length)) + sonfacet(Species) +
   shape_histogram(length = 3, tempo = 1800)
## Not run: x1
x2 <- sonify(iris, sonaes(pitch = Sepal.Length)) + sonfacet(Species) +
  shape_histogram(length = 5, tempo = 1800) # plays the same thing for longer
## Not run: x2
x3 <- sonify(iris, sonaes(pitch = Sepal.Length)) + sonfacet(Species) +
  shape_histogram(length = 3, tempo = 1200) #  same length as original but fewer pitches
## Not run: x3

statisfactions/playitbyr documentation built on Jan. 27, 2024, 1:33 p.m.