| Version: | 0.1-0 |
| Date: | 2026-10-06 |
| Title: | Data Sonification - Turning Data into Sound |
| Description: | Sonification (or audification) is the process of representing data by sounds in the audible range. This package provides the R function sonify() that transforms univariate data, sampled at regular or irregular intervals, into a continuous sound with time-varying frequency. The ups and downs in frequency represent the ups and downs in the data. Sonify provides a substitute for R's plot function to simplify data analysis for the visually impaired. |
| Maintainer: | Stefan Siegert <s.siegert@exeter.ac.uk> |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| Depends: | R (≥ 3.0.0) |
| Imports: | tuneR (≥ 1.3.1) |
| RoxygenNote: | 7.2.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-06 21:22:19 UTC; stefan |
| Author: | Stefan Siegert [aut, cre], Robin Williams [aut] |
| Repository: | CRAN |
| Date/Publication: | 2026-10-06 22:20:02 UTC |
Data sonification
Description
Sonification (or audification) is the process of representing data by sounds in the audible range. This package provides the R function ‘sonify' that transforms univariate data, sampled at regular or irregular intervals, into a continuous sound with time-varying frequency. The ups and downs in frequency represent the ups and downs in the data. Sonify provides a substitute for R’s plot function to simplify data analysis for the visually impaired.
Usage
sonify(
x = NULL,
y = NULL,
waveform = c("sine", "square", "triangle", "sawtooth"),
interpolation = c("spline", "linear", "constant"),
duration = 5,
flim = c(440, 880),
pitch_mapping = c("linear", "logarithmic"),
ticks = NULL,
tick_len = 0.05,
pulse_len = 0,
pulse_amp = 0.2,
noise_interval = c(0, 0),
noise_amp = 0.5,
amp_level = 1,
na_freq = 300,
stereo = TRUE,
smp_rate = 44100,
play = TRUE,
player = NULL,
player_args = NULL
)
Arguments
x |
The x values. Can be used when y values are unevenly spaced. Default is -length(y)/2:length(y)/2 |
y |
The data values used to modulate the frequency. |
waveform |
The waveform used for the sound. One of 'sine', 'square', 'triangle', 'sawtooth'. Default is 'sine'. |
interpolation |
The interpolation method to connect the y-values before generating the sound. One of 'spline', 'linear', 'constant'. 'spline' and 'linear' generate continous transitions between frequencies, 'constant' changes frequencies abruptly. Note: If 'interpolation=constant', y[1] is played from x[1] to x[2], y[2] is played from x[2] to x[3], etc, and the last y-value y[n] is played for the duration x[n] - x[n-1]. Default is 'spline'. |
duration |
Total duration of the generated sound in seconds. Default is 5. |
flim |
The frequency range in Hz to which the data is mapped. Default is c(440, 880). |
pitch_mapping |
How 'y' is mapped onto 'flim'. '"linear"' maps linearly in Hz, so equal steps in the data give equal steps in Hz. '"logarithmic"' maps linearly in log-frequency, so equal steps in the data give equal steps in perceived pitch. Default is '"linear"'. |
ticks |
The location of x-axis ticks. The ticks are indicated by short bursts of a sawtooth wave (duration set by 'tick_len'). The default is NULL (no ticks). |
tick_len |
The duration of each tick sound. |
pulse_len |
Length of white-noise pulses (in seconds) to mark the individual x-values. Ignored if all (non-'NA') x-values are identical. Default is 0. |
pulse_amp |
Amplitude of pulses between 0 and 1. Default is 0.2. |
noise_interval |
A numeric vector of length (at least) 2; only the first two elements are used. White noise is overlayed whenever y is inside this interval (if noise_amp > 0) or outside this interval (if noise_amp < 0). For example, set to c(-Inf, 0) to indicate data in the negative range. Default is c(0,0) (no noise). |
noise_amp |
Amplitude (between 0 and 1) of the noise used for noise_interval. Negative values (between 0 and -1) invert noise_interval, i.e. noise is overlaid whenever y falls outside 'noise_interval'. Default is 0.5. |
amp_level |
Amplitude level between 0 and 1 to adjust the volume. Default is 1. |
na_freq |
Frequency in Hz that is used for NA data. Default is 300. |
stereo |
If TRUE a left-to-right transition is simulated, using equal power panning. Default is TRUE. |
smp_rate |
The sampling rate of the wav file. Default is 44100 (CD quality) |
play |
If TRUE, the sound is played. Default is TRUE. |
player |
(Path to) a program capable of playing a wave file from the command line. Under windows, the default is "mplay32.exe" or "wmplayer.exe" (as specified in '?tuneR::play'). Under Linux, the default is "mpv" if found on the PATH, otherwise "mplayer"; if neither is found, a warning is issued and no sound is played. Under OS X, the default is "afplay". See '?tuneR::play' for details. |
player_args |
Further arguments passed to the wav player, as a single string (e.g. '"-novideo -really-quiet"'). Ignored when 'player' is unspecified. Under Windows the default is '"/play /close"'. Under Linux the default is '"> /dev/null 2>&1"'. Under OS X the default is "". See '?tuneR::play' for details. |
Value
The synthesized sound saved as a 'tuneR::WaveMC' object.
Licence
GPL (>=2)
Author(s)
Stefan Siegert s.siegert@exeter.ac.uk (please report bugs!)
See Also
tuneR::play, tuneR::WaveMC
Examples
obj = sonify(dnorm(seq(-3,3,.1)), duration=1, play=FALSE)
## Not run: sonify(dnorm(seq(-3,3,.1)), duration=1)