# Waveforms

##### Create Wave Objects of Special Waveforms

Create a `Wave`

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

- Keywords
- datagen

##### 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<U+001AEA67> (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 <U+00B1>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.

##### References

J. Timmer and M. K<U+001AEA67> (1995): On generating power law noise. Astron. Astrophys. 300, 707-710.

##### See Also

##### Examples

```
# NOT RUN {
Wobj <- sine(440, duration = 1000)
Wobj2 <- noise(duration = 1000)
Wobj3 <- pulse(220, duration = 1000)
plot(Wobj)
plot(Wobj2)
plot(Wobj3)
# }
```

*Documentation reproduced from package tuneR, version 1.3.3, License: GPL-2 | GPL-3*