# Waveforms: Create Wave Objects of Special Waveforms In tuneR: Analysis of Music and Speech

 Waveforms R Documentation

## Create Wave Objects of Special Waveforms

### Description

Create a `Wave` object of special waveform such as silcence, power law (white, red, pink, ...) noise, sawtooth, sine, square, and pulse.

### Usage

```noise(kind = c("white", "pink", "power", "red"), duration = samp.rate,
samp.rate = 44100, bit = 1, stereo = FALSE,
xunit = c("samples", "time"), alpha = 1, ...)

pulse(freq, duration = samp.rate, from = 0, samp.rate = 44100,
bit = 1, stereo = FALSE, xunit = c("samples", "time"),
width = 0.1, plateau = 0.2, interval = 0.5, ...)

sawtooth(freq, duration = samp.rate, from = 0, samp.rate = 44100,
bit = 1, stereo = FALSE, xunit = c("samples", "time"),
reverse = FALSE, ...)

silence(duration = samp.rate, from = 0, samp.rate = 44100,
bit = 1, stereo = FALSE, xunit = c("samples", "time"), ...)

sine(freq, duration = samp.rate, from = 0, samp.rate = 44100,
bit = 1, stereo = FALSE, xunit = c("samples", "time"), ...)

square(freq, duration = samp.rate, from = 0, samp.rate = 44100,
bit = 1, stereo = FALSE, xunit = c("samples", "time"),
up = 0.5, ...)
```

### Arguments

 `kind` The kind of noise, “white”, “pink”, “power”, or “red” (these are not dB adjusted (!) but all except for “white” are linear decreasing on a log-log scale). Algorithm for generating power law noise is taken from Timmer and König (1995). `freq` The frequency (in Hertz) to be generated. `duration` Duration of the `Wave` in `xunit`. `from` Starting value of the `Wave` in `xunit`. `samp.rate` Sampling rate of the `Wave`. `bit` Resolution of the `Wave` and rescaling unit. This may be `1` (default) for rescaling to numeric values in [-1,1], `8` (i.e. 8-bit) for rescaling to integers in [0, 254], `16` (i.e. 16-bit) for rescaling to integers in [-32767, 32767], `24` (i.e. 24-bit) for rescaling to integers in [-8388607, 8388607], `32` (i.e. 32-bit) for rescaling either to integers in [-2147483647, 2147483647] (PCM Wave format if `pcm = TRUE`) or to numeric values in [-1, 1] (FLOAT_IEEE Wave format if `pcm = FALSE`), `64` (i.e. 64-bit) for rescaling to numeric values in [-1, 1] (FLOAT_IEEE Wave format), and `0` for not rescaling at all. These numbers are internally passed to `normalize`. The `Wave` slot `bit` will be set to 32 if `bit = 0`, `bit = 1` or `bit = 32`. `stereo` Logical, if `TRUE`, a stereo sample will be generated. The right channel is identical to the left one for `sawtooth`, `silence`, `sine`, and `square`. For `noise`, both channel are independent. `xunit` Character indicating which units are used (both in arguments `duration` and `from`). If `xunit = "time"`, the unit is time in seconds, otherwise the number of samples. `alpha` The power for the power law noise (defaults are 1 for pink and 1.5 for red noise) (1/f)^alpha. `reverse` Logical, if `TRUE`, the waveform will be mirrored vertically. `up` A number between 0 and 1 giving the percentage of the waveform at max value (= 1 - percentage of min value). `width` Relative pulses width: the proportion of time the amplitude is non-zero. `plateau` Relative plateau width: the proportion of the pulse width where amplitude is ±1. `interval` Relative interval between the up-going and down-going pulses with respect to the center of the wave period (0: immediatly after up-going, 1: center of the wave period). `...` Further arguments to be passed to `Wave` through the internal function `postWaveform`.

### Value

A `Wave` object.

### Author(s)

Uwe Ligges ligges@statistik.tu-dortmund.de, partly based on code from Matthias Heymann's former package ‘sound’, Anita Thieler, Guillaume Guénard

### References

J. Timmer and M. König (1995): On generating power law noise. Astron. Astrophys. 300, 707-710.

Wave-class, `Wave`, `normalize`, `noSilence`

### Examples

```Wobj <- sine(440, duration = 1000)
Wobj2 <- noise(duration = 1000)
Wobj3 <- pulse(220, duration = 1000)
plot(Wobj)
plot(Wobj2)
plot(Wobj3)
```

tuneR documentation built on Jan. 18, 2023, 1:10 a.m.